Rescuing a partition in Debian when something went wrong

Good afternoon dear
It was Thursday evening and one of our admins had to do a disk resize on one of the KVM virtual machines. It would seem a completely trivial task, but it can lead to data loss in general ... And so ... the whole story is already under the cut

As I said, on Thursday evening (there seemed to be no rain), one of our admins decided to complete a long-standing task and increase the size of the file system inside the KVM virtual machine.

Previously, I had already increased the size of the disk itself from 14 GB to 60 GB, and the admin just had to increase the size of the file system inside the virtual machine.

At about 12 at night, the admin sends a message - where he asks if there should be an extented or primary section ... In response, I wrote to him that I need to do it the way it was before on the virtual machine itself.

Time passed ... and the admin throws off that he had errors, that he can’t expand the partition ... and he stopped mounting ... it’s already 2 am on the clock ...

I wrote to him so that he would not do anything anymore and leave the virtual machine alone and go himself to make a copy of the VM disk image - calling vmname_bad

It was still complicated by the fact that the admin did not take a snapshot and did not copy the markup before his actions ... Having this information, one could roll back and try again.

In the morning, with fresh thoughts, I raise a virtual machine with the same OS (Debian 9) and connect the disk. through fdisk, I see this disk already expanded to 60GB and a partition ... which is actually a bit broken.

I'm trying to find the previous markup from the screenshots that the admin provided, but alas, in vain. I'm trying to pick up the values ​​​​through fdisk, but alas, all attempts have failed.

Since fdisk can't help me... I call on parted to help. Let's load parted - I delete the old rm 2 partition and, knowing the approximate values ​​​​of the breakdown, I do rescue - I indicate the initial value and the final value, where there may be a pratice. Waiting for a minute and parted finds the partition and offers to add information about it to the system - I agreed and left parted.

I mount the partition - everything is OK. The files are in place, everything is fine, but the size is still the old 14GB. I unmounted / dev / sdd1 and do resize2fs / dev / sdd1, then e2fsck / dev / sdd1 and mount it again and I see an already extended partition with all the files and it’s quite alive.

Everything ended well for me and for the admin.

Source: habr.com

Add a comment