Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

ndzlogo-1-1
86%
Loading ...

INDIA – HEADQUARTERS

INDIA

UNITED STATES

CANADA

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

# 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.