[SOLVED] Accidentally shrunk partition before filesystem, how to recover
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Accidentally shrunk partition before filesystem, how to recover
Hello, I was moving some physical extents from one drive in an LVM system to another. In order to do this, I had to shrink one of the logical volumes to make room on this drive.
Of course, I made the silly mistake of forgetting to shrink the filesystem on the logical volume (named lv_home) before I shrunk the logical volume.
Attempting to shrink the filesystem afterward with resize2fs tells me I need to check the filesystem first. However, even after I run e2fsck -fy /dev/vg_chessman/lv_home, the error persists. Checking the filesystem with e2fsck -fy doesn't fix the problem and resize2fs tells me it won't resize it until I fix it with e2fsck -fy.
I'm not too worried about the files on that small portion I cropped off of lv_home (my important files are backed up), but I'd rather not have the rest of the filesystem go down with it. Is there a way I can just tell the operating system to shrink the filesystem to the space it actually has?
Is there a way I can just tell the operating system to shrink the filesystem to the space it actually has?
Nope - there is no way to determine what is missing.
Normal resolution is to (quickly) recreate the partition (lv in your case) to (at least) the same size, and run the fsck again. This is predicated on you not having reassigned that space elsewhere. LVM adds the extra complication that the space for a lv is not necessarily contiguous, so enlarging the lv again may (or may not work). Worth a try.
The information about what extents were previously allocated to that LV is present in the files in /etc/lvm/archive. The comments at the top of each file tell what action was going to be performed after that backup file was made. Find the right file, and use the vgcfgrestore command with the "--file filename" option to restore that configuration.
Nope - there is no way to determine what is missing.
Normal resolution is to (quickly) recreate the partition (lv in your case) to (at least) the same size, and run the fsck again. This is predicated on you not having reassigned that space elsewhere. LVM adds the extra complication that the space for a lv is not necessarily contiguous, so enlarging the lv again may (or may not work). Worth a try.
I tried that. I re-created space on the physical volume, grew the logical volume, ran e2fsck -f, then shrunk it with resize2fs, and re-shrunk the LV. This allowed me to mount it without losing the rest of the filesystem.
As it turns out, I didn't have any files stored on the lost portion. Didn't even have to restore from backup . Thanks!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.