LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 11-17-2013, 09:49 PM   #1
thebombzen
Member
 
Registered: Dec 2010
Location: Noneya Business
Distribution: Linux Mint
Posts: 56

Rep: Reputation: 5
Question 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?
 
Old 11-18-2013, 12:51 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,121

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by thebombzen View Post
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.
 
Old 11-18-2013, 08:06 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
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.

See the example at http://www.nextstep4it.com/categorie...lvm-partition/ .

Last edited by rknichols; 11-18-2013 at 08:11 AM.
 
Old 11-19-2013, 07:02 AM   #4
thebombzen
Member
 
Registered: Dec 2010
Location: Noneya Business
Distribution: Linux Mint
Posts: 56

Original Poster
Rep: Reputation: 5
Thumbs up

Quote:
Originally Posted by syg00 View Post
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!
 
  


Reply

Tags
filesystem, lvm, partition, resize2fs, shrink



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Recover Accidentally formatted encrypted raid partition pazzport Linux - Desktop 1 10-15-2010 03:49 AM
XFS filesystem spontaneously shrunk by 12TB elimorris Linux - Software 1 07-10-2010 08:37 AM
[SOLVED] accidentally overwrote 1TB partition... any way to recover data? :( zuzoa Linux - Newbie 4 09-13-2009 12:59 PM
Oops, I accidentally deleted my NTFS partition!!! How to recover? WindowBreaker Linux - Newbie 1 07-03-2009 07:28 PM
Accidentally Formatted NTFS Partition... Looking to Recover Data Adam A Flynn Linux - Software 5 08-13-2006 11:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration