This article describes a basic logic behind a Linux logical volume manager by showing real examples of configuration and usage. Although Debian Linux will be used for this tutorial, you can also apply the same command line syntax with other Linux distributions such as Red Hat, Mandriva, SuSe Linux and others
Step 1: Create Partitions
I have got 2 hard disks of 2GB size each –
# fdisk -l 2>/dev/null | grep '/dev/sd[a-b]' Disk /dev/sda: 2147 MB, 2147483648 bytes Disk /dev/sdb: 2147 MB, 2147483648 bytes The following steps will show you how to create logical volumes on these hard disks.
Step 2: Initialize the disks to be used as a physical volume
To initialize the disks to be used as a physical volume, you use
# pvcreate /dev/sda Writing physical volume data to disk "/dev/sda" Physical volume "/dev/sda" successfully created
# pvcreate /dev/sdb Writing physical volume data to disk "/dev/sdb" Physical volume "/dev/sdb" successfully created
Step 3: Create the volume group
To create a volume group, you run the
vgcreate as follows.
# vgcreate vg_sda /dev/sda Volume group "vg_sda" successfully created
# vgcreate vg_sdb /dev/sdb Volume group "vg_sdb" successfully created This creates a volume group descriptor at the start of each disk.
Step 4: Create the logical volumes
create a logical volume of size 400 MB -L 400
lvcreate -L 400 -n vol01 vg_sda Step 5: Create File system on logical volumes
The logical volume is almost ready to use. All you need to do is to create a filesystem.:
# mkfs.ext3 -m 0 /dev/vg_sda/vol01 Step 6: Edit /etc/fstab Add an entry for your newly created logical volume into /etc/fstab
/dev/vg_sda/vol01 /home/logvol ext3 defaults 0 2
Before you mount do not forget to create a mount point.
# mkdir /home/logvol After creating/adding it in in fstab file, you may need to run the command 'mount -a' in shell.
There are no revisions for this post.