How to resize or expand LVM partitions
A few week ago, I installed FC6 on my laptop and my slash (/) partition started to run out of space. So I decided that I would shrink my big partition and expand my / partition. Fortunately, I installed FC6 using LVM2 (Logical Volume Manager) which makes it very easy to resize partitions without even rebooting.
Here is how I did.
My partition was like this:
My / partition is about 8 Gb and my /home partition is about 71 Gb.Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 7935392 6773500 752292 91% / /dev/sda5 497829 20904 451223 5% /boot tmpfs 1037084 0 1037084 0% /dev/shm /dev/mapper/VolGroup00-LogVol01 70877776 14988144 51045372 23% /home
For /home, I did:
- umount /home
- e2fsck -f /dev/VolGroup00/LogVol01
- resize2fs /dev/VolGroup00/LogVol01 69G
- lvreduce -L-2G /dev/VolGroup00/LogVol01
- mount /home
- lvextend -L+2G /dev/VolGroup00/LogVol00
- resize2fs /dev/VolGroup00/LogVol00
resize2fs has the ability to resize mounted partitions.
From the manual of resize2fs:
[...] If the filesystem is mounted, it can be used to expand the size of the mounted filesystem, assuming the kernel supports on-line resizing. (As of this writing, the Linux 2.6 kernel supports on-line resize for filesystems mounted using ext3 only.). [...][root@tosca ~]# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 2400256 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 2400256 blocks long.
I finaly end up with the following partionning:
| Filesystem | 1K-blocks | Used | Available | Use% | Mounted on |
| /dev/mapper/VolGroup00-LogVol00 | 9299624 | 6779304 | 2043564 | 77% | / |
| /dev/sda5 | 497829 | 20904 | 451223 | 5% | /boot |
| tmpfs | 1037084 | 0 | 1037084 | 0% | /dev/shm |
| /dev/mapper/VolGroup00-LogVol01 | 68877776 | 14999888 | 51033628 | 23% | /home |
Some useful LVM commands (package lvm2-2.02.06-4):
- lvmdiskscan
- vgdisplay
- pvdisplay
- lvdispay
- vgcreate
- pvcreate
- lvscan
- pvscan
- vgscan

2 comments:
Perfect - just the info I needed in a nice, concise little package. Thanks! ;]
Great post. A big THANK YOU.
Post a Comment