Pick a Free OS

User login

Navigation

LVM: The logical way to manage space

#pvcreate /dev/hda7

pvcreate -- —physical volume “/dev/hda7” successfully created

# pvcreate /dev/hda8

pvcreate— -- physical volume “/dev/hda8” successfully created

The above command creates a volume group descriptor at the start of the partition. The allocation of the physical extents is stored here.

Create a new volume group and add the two physical volumes to it.

# vgcreate freeos /dev/hda7 /dev/hda8

vgcreate— -- INFO: using default physical extent size 4 MB

vgcreate— -- INFO: maximum logical volume size is 255.99 Gigabyte

vgcreate— -- doing automatic backup of volume group “freeos”

vgcreate— -- volume group “freeos” successfully created and activated

This will create a volume group named freeos containing the physical volumes /dev/hda7 and /dev/hda8.

Now you can go on to create the logical volumes within the volume group.

# lvcreate -L 2G -n lv1 freeos

lvcreate— -- doing automatic backup of “freeos”

lvcreate -- —logical volume “/dev/freeos/lv1” successfully created

This will create a logical volume of size 2GB named lv1 in the volume group freeos.

Use the command “vgdisplay” to see the details regarding the volume groups present in your system.

# vgdisplay

--- Volume group ---

VG Name freeos

VG Access read/write

VG Status available/resizable

VG # 0

MAX LV 256

Cur LV 1

Open LV 0

MAX LV Size 255.99 GB

Max PV 256

Cur PV 2

Act PV 2

VG Size 3.91 GB

PE Size 4 MB

Total PE 1000

Alloc PE / Size 256 / 1 GB

Free PE / Size 744 / 2.91 GB

VG UUID TB8zIU-MGPs-uo6r-cB5T-Uj3q-SzPB-fDfFEE

Now you need to build a filesystem on this logical volume. Here, we’re using reiserfs.

#mkreiserfs /dev/freeos/lv1

Mount the newly created filesystem. We found that we had to specify the filesystem type.

#mount -t reiserfs /dev/freeos/lv1 /mnt/lv1

Now you can copy all your data here or move some partition running short of space here. If there are no problems and the working is perfect, you can add an entry to /etc/fstab so that the filesystem is mounted at boot.

/dev/freeos/lv1 /mnt/lv1 reiserfs defaults 1 2

Resizing!