Exam EX200 All QuestionsBrowse all questions from this exam
Question 50

SIMULATION -

One Logical Volume is created named as myvol under vo volume group and is mounted. The Initial Size of that Logical Volume is 400MB. Make successfully that the size of Logical Volume 200MB without losing any data. The size of logical volume 200MB to 210MB will be acceptable.

    Correct Answer:

    To reduce the size of a logical volume without losing data, follow these steps. First, ensure the filesystem is consistent with `fsck -f /dev/vo/myvol`. Next, resize the filesystem to 200MB with `resize2fs /dev/vo/myvol 200M`. Then, reduce the logical volume size with `lvreduce -L 200M /dev/vo/myvol`. Confirm the operation by checking the logical volume size using `lvdisplay /dev/vo/myvol` and ensure the filesystem size is correctly displayed with `df -h`.

Discussion
Darion81

Why not just lvreduce /dev/vo/myvol -r -L 200M? -r - resize filesystem

ntcct

Resizing the LV is just step1. It resize the "holder". To make it be regconized at the "upper" ilesystem lelvel, we need to resize2fs. Im short, there are 5 key components related to LVM disk/volume mgmt: physical storage -> physical partition --> vol group -> logical vol --> file system.

Hmenu0s

"-r / --resizefs" option of lvreduce is the recommended approach. Excerpt from RHEL 8 docs - If the logical volume you are reducing contains a file system, to prevent data loss you must ensure that the file system is not using the space in the logical volume that is being reduced. For this reason, it is recommended that you use the --resizefs option of the lvreduce command when the logical volume contains a file system. When you use this option, the lvreduce command attempts to reduce the file system before shrinking the logical volume. If shrinking the file system fails, as can occur if the file system is full or the file system does not support shrinking, then the lvreduce command will fail and not attempt to shrink the logical volume.

ms200

lvresize -r -L 200M /dev/vo/myvol

kim_ke

This works as well lvreduce --resizefs -L 200M /dev/vo/myvol

eid

in RH8 #df -Th #xfsdump -l 0 -f /myvol.image /dev/vo/myvol #umount /dev/vo/myvol #lvremove /dev/vo/myvol #lvcreate -L 200M -n myvol vo #blkid /dev/vo/myvol #vim /etc/fstab #edit UUID for /dev/vo/myvol #mount -a #xfsrestore -f /myvol.image /myvol #df -Th

cloudyhr

To srink the XFS, never use lvreduce command. the above steps by @eid are the correct process. https://logic.edchen.org/how-to-shrink-xfs-file-system-on-enterprise-linux-7-2/

kenkct

umount /dev/vo/myvol e2fsck -f /dev/vo/myvol resize2fs /dev/vo/myvol 200M mount -a df -hT

kitkat

This should work in case of ext2,3,4 file system.

VforVodoo

# umount /mnt/myvol #e2fsck -f /dev/mapper/vo-myvol #resize2fs /dev/mapper/vo-myvol 200M #lvreduce -l -50 vo/myvol (if PE size was 4.00 MiB) #lvdisplay vo/myvol --LV Path /dev/vo/myvol --LV Size 200.00 MiB --Current LE 50 ---- #mount -a

cloudsinair

[root@dtop5 ~]# lvreduce -r -L 100M /dev/datastore1/fs1 fsadm: Xfs filesystem shrinking is unsupported. /usr/sbin/fsadm failed: 1 Filesystem resize failed. [root@dtop5 ~]# [root@dtop5 ~]# lvremove /dev/datastore1/fs1 [root@dtop5 ~]# [root@dtop5 ~]# lvcreate -L 150M -n fs1 datastore1 Rounding up size to full physical extent 152.00 MiB WARNING: xfs signature detected on /dev/datastore1/fs1 at offset 0. Wipe it? [y/n]: y Wiping xfs signature on /dev/datastore1/fs1. Logical volume "fs1" created. [root@dtop5 ~]# [root@dtop5 ~]# [root@dtop5 ~]# [root@dtop5 ~]# mkfs.xfs /dev/datastore1/fs1 [root@dtop5 ~]# xfsrestore -f newdump.img /mnt/ [root@dtop5 ~]#

hanienarimani

-r option is important when using lvreduce , it will resize firesystem too lvresize -r /dev/vgdata/lvbetoche -L 200M

kitkat

Anywhere in the question somehow it is not mentioned if file system is ext based or xfs. In both cases steps will be different. I think it would be important to check first that what type of file system is in use before we write answer.