Sáb. Abr 20th, 2024

Sometimes we have a LVM filesystem where we have installed the operating system and then we have to create new logical volumes without add new hard disks,  ergo we have to reduce the current logical volume to create the new logical volumes.

For example we may need a new logical volume to separate service data and operating system, to make backups, to avoid the filling of root partition …

This procedure it’s easy in a logical volume that not  contain root partition due to you can unmount the partition and resize its.

In the case you need to resize the logical volume that contain the root partition you have to do the following steps:

You need a live distro of some Linux flavour. We are going to use  Ubuntu 11.04.

Next step is boot the pc from cd device and select the option «Try Ubuntu». When it finishs to boot open a terminal and install lvm utils:

#apt-get install lvm2

After this, you have to mount the logical volume which you want to resize with the following command:

#lvm vgchange -a y

Check the disk space ocupated by the partition:

#df -h
S.ficheros Tamaño Usado disp Uso% Montado en
/dev/mapper/root     60G         30G          50%        50%    /

Before you resize the logical volume check the correct state of it.

#e2fsck -f /dev/VolGroup00/LogVol00

After the check,  resize2fs can be used to reduce the size of  the logical volume’s filesystem. This step is essential to ensure the data integrity.

#resize2fs -f /dev/mapper/root 35G
In the next step, we reduce the logical volume with the same size than logical volumes’s filesystem.
#lvm lvreduce -L35G /dev/mapper/root
Then we check the free space available to create the new logical volume:
#vgdisplay
and the current state of them:
#lvdisplay
Finally we create the new logical volume:
#lvcreate -L 25G -n backup VG Name

And it’s ready! unmount all volumes and reboot!

Referencias

http://equivocation.org/node/103

http://www.tcpdump.com/kb/os/linux/lvm-resizing-guide/shrink.html

0 comentario en “Resizing Logical Volumes in Linux (LVM)”

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *