Just a short reference:
Keep in mind: There is no longer a need to convert the filesystem to ext2 to resize it. resize2fs can handle ext3 just fine.
First, unmount the filesystem in question, unless you have and trust online resizing (I can’t subscribe to either). Then check it for errors like this:
# e2fsck -f /dev/VolGroup00/LogVol00
(replace the path with that of the device you just unmounted)
Get an overview of what you currently have allocated
# lvs
Save said overview
# lvs > maybe_useful.txt
Resize a given filesystem to 50 gigs (read man lvreduce/lvextend to learn how to resize using relative sizes, like reducing the filesystem by 5 gigs)
# resize2fs -p /dev/VolGroup00/LogVol00 50G
Run a new check on the filesystem, just to be sure it worked well
# e2fsck -f /dev/VolGroup00/LogVol00
Resize the lvm partition to fit the filesystem (I usually go a bit higher than the filesystem, just to make sure there’s room for it, then resize the filesystem again to fill the partition afterwards)
# lvreduce -L55G /dev/VolGroup00/LogVol00
Expand the other partition to use the space you just freed up (this will use all available space. again, read manual for how to use only part of the space if you want to extend more lvm’s to fit the space you just made available)
# lvextend /dev/VolGroup00/LogVol01 /dev/md1
(md1 is the physical device I wish to fill)
Extend both filesystems to fit their partitions and check them both afterwards
# e2fsck -f /dev/VolGroup00/LogVol01 # resize2fs -p /dev/VolGroup00/LogVol00 # resize2fs -p /dev/VolGroup00/LogVol01 # e2fsck -f /dev/VolGroup00/LogVol00 # e2fsck -f /dev/VolGroup00/LogVol01
Re-mount your filesystems, and hopefully everything went well 🙂
6 Comments
Hi
I hope you can help me. I have a problem with an upgrade from Fedora 21 to 22 on my server. When I installed Fedora 21, I left my /boot partition (which is ext3) with 200 Mb. AS it turns out, this is now insufficient to run the network upgrade to F22 with fedup. The rest of the drive is an LVM partition. Here is the Fdisk -l result:
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000261fa
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 63 401624 401562 196.1M 83 Linux
/dev/sda2 401625 976768064 976366440 465.6G 8e Linux LVM
Disk /dev/mapper/VolGroup00-LogVol00: 457.6 GiB, 491303993344 bytes, 959578112 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/VolGroup00-LogVol01: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Is there a way to resize the /boot (ext3) to increase its size, at the expense of the LVM partition? I look forward to yuor input
The later versions of GParted can do this. You free up space in the LVM by shrinking a logical volume, then boot a CD or USB stick with GParted on it and reduce the size of the LVM physical volume. You then move the volume to the end of the drive and increase the size of the /boot partition. Of course you want to take a full backup of at least your most important stuff before doing this. You also want to make sure your machine has a stable power source, preferably a UPS.
Hi BOlt:
Well, I must have done something wrong, I tried to shrink the LVM by 1G (lvreduce -L -1G /dev/myVG/myLVd). Later, I booted with a LiveCD with Gparted, and this program recognized a 1G unassigned partition. When I tried to move the LVM, it gave an error saying it couldn’t move the files. When I rebooted from the harddrive, total disaster, it went into emergency mode. Luckily, I could back pedal giving a lvresize with +1G, and now I got the system back up. What am I doing wrong?
Did you read the manual for lvreduce before using it?
http://linux.die.net/man/8/lvreduce
It’s vitally important to first shrink and move file systems before reducing the size of the volume itself, as lvreduce will happily disown any data on the reduced parts of the drive.
I’m afraid the LVM2 suite escapes me. So how do I go about shrinking, moving files, and finally reducing the size of the LVM?
Use resize2fs (read the manual) to resize the file system before shrinking the volume it’s on. When the file system and the volume are smaller, you should be able to shrink the physical volume with gparted.