EX200 Exam QuestionsBrowse all questions from this exam

EX200 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.

Show Answer
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

9 comments
Sign in to comment
Darion81
Oct 29, 2020

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

ntcct
Jan 29, 2021

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
Jul 25, 2022

"-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
Mar 30, 2021

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

kim_ke
May 27, 2021

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

eid
Dec 29, 2021

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
Jan 3, 2022

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
Mar 9, 2022

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

kitkat
Jun 21, 2022

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

kitkat
Jun 21, 2022

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.

hanienarimani
Nov 1, 2022

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

cloudsinair
May 17, 2023

[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 ~]#

VforVodoo
Aug 18, 2023

# 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