Logical Volume Creation

In one of my current projects I have to attach a (virtual) disk to a (cloud) server.

Gather information

To get an overview of the system I used this commands:




fdisk -c -l /dev/sdb

Interpretation of information

Physical VolumePartitionVolume GroupLogical VolumesSize
/dev/sda107 GB
/dev/sda/dev/sda10,5 GB
/dev/sda/dev/sda2106,5 GB
/dev/sda/dev/sda2vg00lv_home2 GB
/dev/sda/dev/sda2vg00lv_usr2 GB
/dev/sdb107 GB

Technically it is possible to create a new logical volume inside volume group vg00, because there are > 76,5 GB unassigned and free storage.

But the vg00 is reserved for the Operating System and should not used for data from application.

Therefore the additional disk is needed for applicatin data.

Volume creation

Physical Volume with ~ 100 GB is attached to the server and added as /dev/sdb.

A volume group "vg_app" will be created with two logical volumes. One logical volume for logfiles, named "lv_logs" with 20 GB and the other with remaining free space, named "lv_app", for application data.

# create volume group
vgcreate -s 32M vg_app /dev/sdb

# create logical volume for logfiles
lvcreate -L 20G -n lv_log vg_app

# create logical volume for application data
lvcreate -l 100%%VG -n lv_app vg_app

# show information
vgdisplay -v /dev/vg_app

mount -a
Physical VolumeVolume GroupLogical VolumeSize
/dev/sdb107 GB
/dev/sdbvg_app107 GB
/dev/sdbvg_applv_log20 GB
/dev/sdbvg_applv_app> 79 GB

Create File system

mkfs -t ext4 /dev/vg_app/lv_app
mkfs -t ext4 /dev/vg_app/lv_log

Mount logical volumes

mkdir /app
mkdir /app/log
mount /dev/mapper/vg_app-lv_log /app/log
mount /dev/mapper/vg_app-lv_app /app
mount -a
vi /etc/fstab
mount -a
# /etc/fstab
# [...] existing files code [...]
/dev/mapper/vg_app-lv_app /app     ext4 defaults 0 0
/dev/mapper/vg_app-lv_log /app/log ext4 defaults 0 0


Reboot and doublecheck that mounted volumes are still there.

reboot now
df -h
Filesystem                 Size  Used Avail Use%% Mounted on
/dev/mapper/vg_app-lv_app   79G   57M   75G   1%% /app
/dev/mapper/vg_app-lv_log   20G   45M   19G   1%% /app/log

-> Both logical volumes are mounted --> Success!

Leave a Reply

Your email address will not be published. Required fields are marked *