Red Hat Enterprise Linux v7, RHCSA EX200 exam task: reduce the size of a file system.
Reducing or increasing the size of a file system is one of the RHCSA exam tasks so you have 50% chance that you will get file system shrinking task on your EX200 exam.
If you will be shrinking file system in your production Environment in work there are two things which you have to consider:
1) File system type musts support shrinking – XFS which is the default file system in Red Hat 7 does not support shrinking at all.
2) ext2, ext3 and ext4 file systems must be unmounted during shrinking. ext2, ext3 and ext4 file systems don’t support on-line shrinking.
Also best practise is to have up to date backup before you perform file system shrinking. On your RHCSA exam you will have to shrink file system which will be very small in size so copy data to some other file system on your exam will be very quick and command like “cp -av” will do the job. And even in unlikely case if you loose the file system you can easily recreate it with smaller requested size – restore files from backup and you will get full points for this task on your RHCSA exam.
Our given task is to shrink file system /u03 to 1GB.
1) Verify the file system size and file system utilization:
df -h /u03
So we are going to reduce the size of a file system /u03 from 4GB to 1GB.
2) Verify what is the file system type.
mount | grep u03
file system type is ext4 which supports shrinking.
3) Command to reduce the size of a logical volume together with a size of file system.
lvresize -L 1G -r /dev/mapper/datavg-lv_u03
-L (upper case L) 1G : will set the size of logical volume to 1GB
you can use M for Megabytes or K for Kilobytes and so on …
-r option will resize the file system together with the logical volume.
command “lvresize -L 1G -r /dev/mapper/datavg-lv_u03” performed following steps:
– unmounted our file system
– performed file system check
– shrank file system to 1GB
– and also reduced size of logical volume to 1GB as well.
4) Confirm the new size of a file system with command:
df -h /u03
Note: Some room is taken for a file system meta-data which is not any problem at all on your RHCSA exam.
Related Video Tutorials: