Shrink ext2 ext3 and ext4 file system and reduce the size of a logical volume with only one command.



2
2007

Shrink ext2 ext3 and ext4 file system and reduce the size of a logical volume with only one command in Linux. 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 where: -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: RHCSA Fast Track course: Reset forgotten root password in Redhat 7: https://youtu.be/cUG16kdYCxE Network Interface naming convention in Red Hat 7: https://youtu.be/oPLEYK-we1A Setting up network without NetworkManager in Redhat 7: https://youtu.be/WwzO2rzaXtI Setting up network using NetworkManager and network scripts in Redhat 7: https://youtu.be/7PwA__i9Bi0 Setting up network using a NetworkManager text user interface (nmtui) in Red Hat 7 - EASY!!! https://youtu.be/IKH1sCEjG2A Setting up network in Red Hat 7 in less than a minute - QUICK & EASY!!! https://youtu.be/TqMdzTPsjJY Setting up network using a NetworkManager command line interface (nmcli) in Red Hat 7 https://youtu.be/v-soSvSsw18 nmcli cheat! Setting up network using nmcli in Red Hat 7 in less than a 30 seconds - QUICK & EASY!!! https://youtu.be/NqEuucdSS60 Setting up network using a NetworkManager connection editor GUI tool in Red Hat 7 - EASY!!! https://youtu.be/sa-lB7SpPdg The Complete Beginners Guide to Linux Network Configuration - GUI & Easy! https://youtu.be/1LcAdQWF6KQ Shrink ext2 ext3 and ext4 file system and reduce the size of a logical volume with only one command. https://youtu.be/tTpStv6cfeQ Complete guide to file system shrinking and reducing the size of the underlying logical volume. https://youtu.be/8AD8ZiYDavY Other related video tutorials: Calculate netmask, network and broadcast address - EASY!: https://youtu.be/Y24XcB5NMvs NetworkManager connection priority - manage network profile priority in Linux: https://youtu.be/21SIHo_Rc_M RHCE EX300 exam: RHCE EX300 exam: Configure an iSCSI target on Red Hat Enterprise Linux https://youtu.be/vF3YFVqwLT0 === I am currently working on: Shrink ext2 ext3 and ext4 file system and recreate underlying disk partition with smaller size.

Published by: Business Server Solutions Published at: 7 years ago Category: علمی و تکنولوژی