Configuring a New Disk with Second LVM on Linux

This guide will help you configure a new disk using LVM (Logical Volume Manager) on a Linux system.

1. Create a Partition Table on the Disk

First, identify the new disk. Use the pvs command to list all partitions. The new disk, which is not listed, will be the one you need to partition.

For example, if the new disk is /dev/sdb, follow these steps:

# fdisk /dev/sdb

You will see a command prompt. Enter the following commands:

Command (m for help): n

Partition type: p

Partition number (1-4): 1

First sector (default 1): [press Enter]

Last sector, +sectors or +size{K,M,G} (default): [press Enter]

Command (m for help): w

This will create a primary partition on the new disk.

2. List Available Disks

Verify the disk partitions with:

# ls /dev/sd*

You should see something like:

/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb  /dev/sdb1

Here, /dev/sda are your existing disks, and /dev/sdb is your new disk.

3. Create a Physical Volume

Create a physical volume on the new disk:

# pvcreate /dev/sdb1

You should see:

Physical volume "/dev/sdb1" successfully created

4. Create a Volume Group

Create a volume group named "hitit":

# vgcreate hitit /dev/sdb1

You should see:

Volume group "hitit" successfully created

5. Create a Logical Volume

Create a logical volume named "data" with a size of 1GB in the "hitit" volume group:

# lvcreate -n data -L 1G hitit

You should see:

Logical volume "data" created

6. List Volume Groups

To list volume groups, use:

# vgdisplay

7. Scan for Physical Volumes

To view the physical volumes, use:

# pvscan

8. List Logical Volumes

To list the logical volumes, use:

# lvscan

You should see something like:

ACTIVE '/dev/hitit/data' [1.00 GiB] inherit

9. Extend a Logical Volume (If Needed)

If you need to extend the logical volume, use:

# lvextend -L +SizeG /dev/mapper/hitit-data

10. Format the Logical Volume

Format the logical volume with ext4 filesystem:

# mkfs.ext4 /dev/mapper/hitit-data

11. Create a Mount Point

Create a directory to mount the logical volume:

# mkdir /data1

12. Mount the Logical Volume

Mount the logical volume to the newly created directory:

# mount /dev/mapper/hitit-data /data1

13. Configure Automatic Mount at Boot

Edit the fstab file to ensure the disk mounts automatically at boot:

# mcedit /etc/fstab

Add the following line to the end of the file:

/dev/mapper/hitit-data /data1 ext4 defaults 0 0


Was this article helpful?
0 out of 0 found this helpful

Articles in this section

See more
Become a Certified Logsign User/Administrator
Sign-up for Logsign Academy and take the courses to learn about Logsign USO Platform in detail. Enjoy the courses, and get your badges and certificates. In these courses, you'll learn how to use Logsign in your work and add value to your career.
Visit Our Blog
Our Logsign USO Platform illustrate our expertise. So do the blog. Through our blog posts, deepen your knowledge on various SecOps topics or get updated about important news & modern approaches for cybersecurity. Get into the habit of reading valuable information provided by Logsign. Be a step ahead.