Heads Up :
The post you are writing will appear in a public forum. Please ensure all content is appropriate for public consumption. Review the employee guidelines for the community here.
I found the reason why we get this error. The problem is not having sufficient space in bootflash:. I deleted the unwanted files and retried and it worked.