I have a completely standard, single hard drive Fedora 23 desktop. The dual-boot installer set up the Linux partition as LVM, with root, swap and home logical volumes; root and home were both ext4. Having recently added an additional 4 GB of ram, I decided to expand the swap volume by shrinking the home volume by 4 GB and then adding that to swap. Everything seemed to go fine, and my computer ran for several days with no problems.

However, I didn't reboot or shutdown after doing the above, and then there was a power failure. When I next booted up I was dropped into emergency recovery mode as the home ext4 volume was corrupted. I tried using fsck several times, but was unable to fully repair the problem. I ended up reformatting the home volume and restoring from a recent backup.

My questions:

  1. Was the corruption due to me screwing up the swap resizing, or due to not rebooting right after the resizing? The home filesystem had around 240 GB free when I shrank it by 4 GB, and it continued to be usable for several days afterwards, so I think I didn't screw it up, but that was the first time I've ever used LVM.

  2. If I did the LVM stuff right and the problem was due to the power failure, was there any LVM command I could have issued to flush the changes to the hard drive, or is the only proper way to do it to reboot after the change?

  • Did you do a resize2fs on your home ext4 before shrinking it with lvresize? – Anthon Apr 26 '16 at 4:46
  • No, I didn't. Don't remember seeing resize2fs in any of the LVM how-tos I read. – Matthew Cline Apr 26 '16 at 6:28
  • The problem is LVM doesn't know about filesystems and how they use the space in the logical volume once it is fully allocated to the filesystem. – Anthon Apr 26 '16 at 6:41

You don't have to run anything after resizing, but you cannot just resize the logical volume even if you have unmounted the filesystem on it. You have the resize the filesystem first (for ext4 you can use resize2fs), to make sure there are unused blocks in the logical volume that can be freed up (to transfer to swap). This normally requires some calculation and you should not shrink the filesystem with less Gb than you are going to shrink the LV.

To prevent the calculation and the possible errors, what I would do is the following. If the filesystem is originally 100Gb and you want to shrink it by 4Gb:

resize2fs /dev/mapper/vg0-home 95G
lvreduce -L 96G /dev/mapper/vg0-home
# resize to fill available space
resize2fs -p /dev/mapper/vg0-home

(adjust vg0-home to your actual LV)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.