Search My Blog

Saturday, December 11, 2010

All about Fedora: How to resize or expand LVM partitions

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:

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
My / partition is about 8 Gb and my /home partition is about 71 Gb.

For /home, I did:

  1. umount /home
  2. e2fsck -f /dev/VolGroup00/LogVol01
  3. resize2fs /dev/VolGroup00/LogVol01 69G
  4. lvreduce -L-2G /dev/VolGroup00/LogVol01
  5. mount /home
For / partition, I did:
  1. lvextend -L+2G /dev/VolGroup00/LogVol00
  2. resize2fs /dev/VolGroup00/LogVol00
e2fsck and resize2fs belong to package e2fsprogs-1.39-7.fc6.

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
Some useful links:

Go there...

How to resize lvm
how to resize lvm - Google Search
All about Fedora: How to resize or expand LVM partitions
LVM Resize - After logical resize, FS size does not match physical size.
Unix/Linux Administration - Logical Volume Management Guide
Introduction to LVM
More Articles on All about Fedora...
32 bits acroread adobe authentication bonding boot bootchart bug checkgmail chocolate chromium compiz comps-f8.xml conversion dell dhcp dispatcher distribution dual core environment variables ethernet expand ext3 f10 f11 f12 F7 f8 F9 fdisk features fedora format ghost git gmail google chrome google wave google-droid gparted grub history inspiron 9400/E1705 intel ipw3945 japanese ldap linux live live upgrade lvm m109s module motor oil multimedia keys network networkmanager nscd nvidia partition pdf preupgrade pxeboot red hat repository rpm service sha1sum shrink ssh tftp timeline tunneling usb video projector vmware wifi windows wireless wrong predictions xorg xvideo yum yumex


No comments: