WalzoneInterview Prep
πŸ“ž Interviewing soon? Practice with a realistic AI mock phone interview β€” it calls you, then scores you. First 15 min FREE β†’

Linux Β· Advanced Β· question 48 of 100

How do you set up and manage LVM (Logical Volume Management) in Linux, and what are its benefits?

πŸ“• Buy this interview preparation book: 100 Linux questions & answers β€” PDF + EPUB for $5

LVM (Logical Volume Management) is a technology in Linux that allows for the management of hard drive storage devices on a higher level of abstraction than the traditional partition scheme. With LVM, multiple physical hard drives can be combined into logical volumes that can be dynamically resized, migrated, or backed up.

To set up LVM, there are a few steps involved:

Partitioning the hard drive: The hard drive needs to be partitioned into physical volumes (PVs) using the pvcreate command. For example, to create a physical volume on /dev/sdb1, you can run the following command:

    sudo pvcreate /dev/sdb1

Creating a volume group: After creating the physical volumes, they can be grouped together into a volume group (VG) using the vgcreate command. For example, to create a volume group named "vg1" using the physical volume /dev/sdb1, you can run the following command:

    sudo vgcreate vg1 /dev/sdb1

Creating logical volumes: Once the volume group is created, logical volumes (LVs) can be created using the lvcreate command. For example, to create a logical volume named "lv1" with a size of 10GB in the volume group "vg1", you can run the following command:

    sudo lvcreate -n lv1 -L 10G vg1

Formatting and mounting the logical volumes: After creating the logical volumes, they need to be formatted with a file system (e.g., ext4, xfs) and mounted on the file system. This can be done using the mkfs and mount commands, respectively. For example, to format the logical volume "lv1" with ext4 and mount it on the /mnt directory, you can run the following commands:

    sudo mkfs.ext4 /dev/vg1/lv1
    sudo mount /dev/vg1/lv1 /mnt

Once the logical volumes are set up, they can be managed using various commands such as lvextend to increase the size of a logical volume, pvmove to move data between physical volumes, and lvremove to remove a logical volume.

The benefits of using LVM include:

Dynamic resizing: Logical volumes can be resized without the need to repartition the hard drive. Flexibility: Logical volumes can span multiple hard drives and can be easily moved or backed up. Data redundancy: LVM supports various RAID configurations for data redundancy.

However, there are also some potential downsides to using LVM, such as decreased performance due to additional overhead and increased complexity in managing the storage.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Linux interview β€” then scores it.
πŸ“ž Practice Linux β€” free 15 min
πŸ“• Buy this interview preparation book: 100 Linux questions & answers β€” PDF + EPUB for $5

All 100 Linux questions Β· All topics