RHCSA LVM Storage Management Questions and Answers — Questions and Answers
Question 1: A logical volume named `lv_data` in the volume group `vg_apps` is almost full. A new physical disk, `/dev/sdd`, has been added to the system to provide more space. Which of the following sequences of commands correctly extends the logical volume to use the new disk?
- 1. `pvcreate /dev/sdd` 2. `vgextend vg_apps /dev/sdd` 3. `lvextend -l +100%FREE /dev/vg_apps/lv_data` 4. `xfs_growfs /mount/point` or `resize2fs /dev/vg_apps/lv_data` (Correct answer)
- 1. `vgextend vg_apps /dev/sdd` 2. `pvcreate /dev/sdd` 3. `lvextend -l +100%FREE /dev/vg_apps/lv_data` 4. `xfs_growfs /mount/point`
- 1. `pvcreate /dev/sdd` 2. `lvextend -l +100%FREE /dev/vg_apps/lv_data /dev/sdd` 3. `vgextend vg_apps /dev/sdd` 4. `resize2fs /dev/vg_apps/lv_data`
- 1. `lvcreate -l +100%FREE /dev/vg_apps/lv_data` 2. `vgextend vg_apps /dev/sdd` 3. `pvcreate /dev/sdd` 4. `xfs_growfs /mount/point`
Correct answer: 1. `pvcreate /dev/sdd` 2. `vgextend vg_apps /dev/sdd` 3. `lvextend -l +100%FREE /dev/vg_apps/lv_data` 4. `xfs_growfs /mount/point` or `resize2fs /dev/vg_apps/lv_data`
The correct procedure is to first initialize the new disk as a physical volume using `pvcreate`. Then, the volume group must be extended to include this new physical volume with `vgextend`. After the volume group has more space, the logical volume can be extended to use the available free space using `lvextend`. Finally, the filesystem on the logical volume must be resized to recognize and use the additional space; this is done with `xfs_growfs` for XFS filesystems or `resize2fs` for ext2/3/4 filesystems.
Question 2: Which command is used to create a new logical volume named `lv_web` of size 10 Gigabytes from a volume group named `vg_data`?
- A. `vgcreate -n lv_web -L 10G vg_data`
- B. `lvnew -s 10G -n lv_web vg_data`
- C. `lvcreate -L 10G -n lv_web vg_data` (Correct answer)
- D. `pvcreate -L 10G -n lv_web vg_data`
Correct answer: C. `lvcreate -L 10G -n lv_web vg_data`
The `lvcreate` command is used to create a new logical volume. The `-L` option specifies the size of the logical volume (10G), and the `-n` option specifies its name (lv_web). The final argument is the name of the volume group from which to allocate the space (vg_data).
Question 3: A system administrator needs to remove a logical volume `/dev/vg01/lv01` which is currently mounted on `/data`. What is the correct procedure to safely remove the logical volume?
- A. `lvremove /dev/vg01/lv01` followed by `umount /data`
- B. `vgremove vg01`
- C. `umount /data` followed by `lvremove /dev/vg01/lv01` (Correct answer)
- D. `lvreduce -L 0 /dev/vg01/lv01` followed by `umount /data`
Correct answer: C. `umount /data` followed by `lvremove /dev/vg01/lv01`
Before a logical volume can be removed, it must be unmounted. The `umount` command is used to unmount the filesystem. After it's unmounted and no longer in use, the `lvremove` command can be used to safely delete the logical volume.
Question 4: Which of the following describes the fundamental relationship between Physical Volumes (PVs), Volume Groups (VGs), and Logical Volumes (LVs) in LVM?
- A. Logical Volumes are grouped together to form a Volume Group, which is then stored on a single Physical Volume.
- B. Physical Volumes are combined into a Logical Volume, which is then partitioned into multiple Volume Groups.
- C. Physical Volumes are abstract layers on top of Volume Groups, which contain the actual Logical Volumes.
- D. Physical Volumes are pooled together to create a Volume Group, from which Logical Volumes can be created. (Correct answer)
Correct answer: D. Physical Volumes are pooled together to create a Volume Group, from which Logical Volumes can be created.
LVM works by creating a pool of storage space called a Volume Group (VG) from one or more Physical Volumes (PVs), which can be whole disks or partitions. From this VG, you can create Logical Volumes (LVs), which function as virtual partitions that can be easily managed and resized.
Question 5: A sysadmin has created a logical volume and now needs to make it usable by the operating system. What are the next two essential steps after using `lvcreate`?
- A. Create a filesystem on the LV, then mount it. (Correct answer)
- B. Mount the LV, then create a filesystem on it.
- C. Add the LV to `/etc/fstab`, then run `pvcreate` on it.
- D. Run `vgextend` on the LV, then mount it.
Correct answer: A. Create a filesystem on the LV, then mount it.
After a logical volume is created with `lvcreate`, it is just a raw block device. The next step is to create a filesystem on it using a command like `mkfs.xfs` or `mkfs.ext4`. Once the filesystem exists, the logical volume can be mounted to a directory to make it accessible for storing files.
Question 6: You need to reduce the size of a logical volume named `data_lv` in the `corp_vg` volume group. The volume is formatted with an ext4 filesystem. What is a critical prerequisite before running the `lvreduce` command?
- A. The Volume Group must be deactivated.
- B. The filesystem must be resized to be smaller than or equal to the new LV size. (Correct answer)
- C. The logical volume must be snapshotted.
- D. The physical volumes in the group must be defragmented.
Correct answer: B. The filesystem must be resized to be smaller than or equal to the new LV size.
Reducing the size of a logical volume will destroy any data in the removed space. Therefore, it is critical to first shrink the filesystem on the volume to ensure no data is lost. Commands like `resize2fs` (for ext4) must be used before `lvreduce` to safely reduce the overall size.
A logical volume named `lv_data` in the volume group `vg_apps` is almost full.
A new physical disk, `/dev/sdd`, has been added to the system to provide more space.
Which of the following sequences of commands correctly extends the logical volume to use the new disk?