Add New Partitions and Logical Volumes

LinuxLinuxBeginner
Practice Now

Introduction

In this challenge, you will learn how to configure local storage on a Linux system by adding new partitions and logical volumes, as well as creating a swap space, without causing any data loss. This skill is essential for system administrators to efficiently manage and expand the storage capacity of their Linux servers.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") subgraph Lab Skills linux/echo -.-> lab-389425{{"`Add New Partitions and Logical Volumes`"}} end

Add New Partitions and Logical Volumes

Tasks

  • Create a new partition on the system's storage device.
  • Create a new logical volume group using the new partition.
  • Create a new logical volume within the new volume group.
  • Format the new logical volume with an appropriate file system.
  • Mount the new logical volume to a suitable directory.

Requirements

  • The new partition should be created on the /dev/sdb device.
  • The new partition should have a size of 2 GiB.
  • The new volume group should be named vg_project.
  • The new logical volume should be named lv_project and have a size of 1 GiB.
  • The new logical volume should be formatted with the ext4 file system.
  • The new logical volume should be mounted to the /home/labex/project directory.

Example

After completing this step, the output of lsblk and df -h commands should look similar to the following:

$ lsblk
NAME                    SIZE TYPE MOUNTPOINT
sda                     40G  disk
├─sda1                   1G  part /boot
└─sda2                  39G  part /
sdb                     10G  disk
└─sdb1                   2G  part
  └─vg_project-lv_project
                         1G  lvm  /home/labex/project
$ df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/sda2                     39G  1.2G   36G   4% /
/dev/sda1                     1.0G  135M  816M  14% /boot
/dev/mapper/vg_project-lv_project
                              1.0G   33M  920M   4% /home/labex/project

Summary

In this challenge, you learned how to configure local storage on a Linux system by adding new partitions and logical volumes, as well as creating a swap space, without causing any data loss. You practiced creating a new partition, a new volume group, a new logical volume, formatting the logical volume, and mounting it to a suitable directory. This skill is essential for system administrators to efficiently manage and expand the storage capacity of their Linux servers.

Other Linux Tutorials you may like