Warning: include(/homepages/10/d653673895/htdocs/clickandbuilds/Tutarticle/wp-includes/wp-session-manager.php): failed to open stream: Permission denied in /homepages/10/d653673895/htdocs/clickandbuilds/Tutarticle/wp-load.php on line 1

Warning: include(): Failed opening 'wp-includes/wp-session-manager.php' for inclusion (include_path='.:/usr/lib/php7.0') in /homepages/10/d653673895/htdocs/clickandbuilds/Tutarticle/wp-load.php on line 1
Creating LVM logical volumes | Tutarticle

Creating LVM logical volumes


LVM logical volumes are used from the top down, but they are created from the bottom up. First you create one or more physical volumes (pv), use the physical volumes to create volume groups (vg), and then create logical volumes from thevolume groups (lv).

Commands for working with each LVM component begin with the letters pv, vg, and lv.

For example, pvdisplay shows physical volumes, vgdisplay shows volume groups, and lvdisplay shows logical volumes. The following procedure takes you through the steps of creating LVM volumes from scratch. To do this procedure, you could use the USB flash drive and partitions. Use these steps:

  1. Obtain a disk with some spare space on it and create a disk partition on it of the LVM type (8e). Then use the pvcreate command to identify this partition as anLVM physical volume. The process of doing this is described in the section “Creating a multiple-partition disk” using the /dev/sdc6 device in that example.
  1. To add that physical volume to a new volume group, use the vgcreate command. The following command shows you how to create a volume group called myvg0 using the /dev/sdc6 device:

# vgcreate myvg0 /dev/sdc6

Volume group “myvg0” successfully created


  1. To see the new volume group, type the following:

# vgdisplay myvg0

— Volume group —

VG Name myvg0

VG Size 396.00 MiB

PE Size 4.00 MiB

Total PE 99

Alloc PE / Size 0 / 0

Free PE / Size 99 / 396.00 MiB


  1. Of the 400MiB partition, 396MiB of space can be used in blocks of 4MiB. Here’s how to create a logical volume from some of the space in that volume group and then check that the device for that logical volume exists:

# lvcreate -n music -L 100M myvg0

Logical volume “music” created

# ls /dev/mapper/myvg0*


  1. The procedure created a device named /dev/mapper/myvg0-music. That device can now be used to put a filesystem on and mount, just as you did with regular partitions in the fi rst part of this chapter. For example:

# mkfs -t ext4 /dev/mapper/myvg0-music

# mkdir /mnt/mymusic

# mount /dev/mapper/myvg0-music /mnt/mymusic

# df -h /mnt/mymusic

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/myvg0-music 97M 5.6M 87M 7% /mnt/mymusic


  1. As with regular partitions, logical volumes can be mounted permanently by adding an entry to the /etc/fstab file, such as:

/dev/mapper/myvg0-music /mnt/mymusic ext4 defaults 1 2

The next time you reboot, the logical volume is automatically mounted on /mnt/mymusic.

(Be sure to unmount the logical volume and remove this line if you want to remove the USB

flash drive from your computer.)

Leave a reply:

Your email address will not be published.

Site Footer