System ProgrammingLearn how to Use Logical Volume Manager in Red Hat Linux -...

Learn how to Use Logical Volume Manager in Red Hat Linux – Part 2

Red-Hat-Linux-Administration-(20)-LVM-(2)-740X296

In the previous article, we had an introduction to LVM. We have gone through the procedure to create a large file system from two smaller disks using LVM. We have stopped after creating and verifying a volume group that contains two disks of sizes 4 GB and 6 GB. So, let’s complete what we have started.

Creating Logical Volume
5. Create an 8 GB logical volume using the lvcreate command.
Syntax
lvcreate –n LVNAME –l NUMBER_of_LOGICAL_EXTENTS VGNAME
lvcreate –n LVNAME –L LVSIZE [bBsSkKmMgGtTpPeE] VGNAME

The following command will create a logical volume with 8 GB size in the vgdata volume group.
lvcreate -n lv_sales_data -L 8G vgdata
Img1
To review and verify the result of the previous command, we can use either lvs or lvdisplay.
Img2

6. On top of the lv_sales_data logical volume, the required file system is built. The same commands we used with basic partitions also apply here: the mkfs command, and its derivatives.
Img3

7. Create the directory that will be used as mount point.
mkdir /sales_data

8. Edit the /etc/fstab file, and add a line for /sales_data. This is to ensure that the file system will be mounted automatically after reboots.
/dev/vgdata/lv_sales_data   /sales_data  ext4  defaults   0 0
Or using the UUID:
UUID=66902b61-d4c1-4b85-b626-49eeac4a15d3 /sales_data ext4 defaults 0 0
Where the UUID is the universally unique identifier. To obtain the UUID for a block device (like a hard disk, or logical volume), use the blkid command:
Img4
Copy the UUID part of the output into your /etc/fstab file as above.
In either cases, save and exit the file.

9. To mount /sales_data, use one of the following commands:
mount /sales_data/
or:
mount –a

10. Now, check the mounted file systems using either the mount command or df command:
Img5
That was the full procedure, starting from physical disks, until building and mounting the file system using the LVM, using the CLI commands. Now, we are going to investigate the other method: the GUI tool.

Implementing LVM using GUI Method
If the GUI tool wasn’t installed on your Linux box, you can easily install it using the command:

yum install -y system-config-lvm

Img6
Now, start the GUI tool using the command system-config-lvm from your terminal:
Img7
The application window is divided into three panes:
The left pane: displays the existing volume groups, and any disk devices not yet initialized as physical volume.
The middle pane: displays graphical views for the physical and logical structures of volume groups.
The right pane: displays detailed info on the object/part selected on the left or middle panes.

You can easily notice the existence of three un-initialized disks:

    • /dev/sda:       this is the first SCSI, SATA disk in the system. In our case, it contains two partitions: /dev/sda1 that is used for /boot, and /dev/sda2 that is used as physical volume for the volume group vg_rhel67srv created by the Red Hat installation wizard.
    • /dev/sdb

If you select this disk from the left pane, you will get its graphical view on the middle, and some info including the size on the right.
IMg8

  • /dev/sdc

Select it to see it is the 6 GB size disk we used in our previous procedure.

<strong>Note</strong>
/boot is always mounted on /dev/sda1 which is created as a basic partition.

As we did with CLI commands, we are going to implement the same previous requirements using the GUI tool this time. Here is the procedure:

    1. Select /dev/sdb from the left pane, and click Initialize Entity button in the bottom of the middle pane.

Img9

    1. You get a confirmation message box that tells you that everything on this disk will be lost, and whether you are sure you want to continue. Click Yes.

Img10

    1. Now, the view looks like the following:

Img11
We have the option to create a new volume group using this new physical volume, add it to an existing volume group, or un-initialize it.

    1. Click Create new Volume Group.

Img12

    1. Type the volume group name, and click OK.

Img13
The new volume group appears on the left pane, and its physical and logical views appear on the middle pane.

    1. repeat the procedure for /dev/sdc

Img14

    1. Click Add to existing Volume Group.

Img15

    1. Select the vgdata volume group and click Add.

Img16
Now, vgdata contains two physical volumes /dev/sdb and /dev/sdc with total space of ten gigabytes.

    1. Click Logical View

Img17

    1. From the middle pane, click Create New Logical Volume.
    2. Fill in the “Create New Logical Volume” dialog.

Img18

        • In the LV name, type: lv_sales_data.
        • In the LV size, type: 8 Gigabytes
        • Under the Filesystem section, select Ext4 from the dropdown list.
        • Select the Mount checkbox.
        • Select the Mount when rebooted checkbox.
        • In the Mount point textbox, type /sales_data.

Img19
When finished, click OK.
Img20

    1. The tool creates the file system, creates /sales_data directory, mounts the file system, and creates the /etc/fstab entry for you.

That was the procedure, simply.

Summary

      • The lvcreate command creates a logical volume in a volume group.
      • The commands lvs and lvdisplay display information about existing logical volumes.
      • The system-config-lvm command starts the GUI tool that manages LVM tasks.

 

In the next article, we are going to continue our journey with LVM. See you there.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Exclusive content

- Advertisement -

Latest article

21,501FansLike
4,106FollowersFollow
106,000SubscribersSubscribe

More article

- Advertisement -