File system resizing
Process for resizing a file system on a dedicated server.
Ext2/Ext3 & LVM
Use the tool resize2fs that is part of the e2fsprogs package on a modern distribution.
Shrinking a file system is the more dangerous operation. Tips and tricks for shrinking:
- Take a backup before you start!
You will need to unmount the file system and perform a forced fsck (e2fsck -f)
The utility will handily print out the new size of of the file system afterwards.
[root@BLAH ~]# resize2fs /dev/BLAH/data 45G resize2fs 1.39 (29-May-2006) Resizing the filesystem on /dev/BLAH/data to 11796480 (4k) blocks. The filesystem on /dev/BLAH/data is now 11796480 blocks long.
Calculate the new size in kilobytes by multiplying the block count (11796480 in the above example) by the number of kilobytes (4 in the above example output). This filesystem has a size of 47185920 KiB now.
Resizing a logical volume is then easy:
lvreduce -L 47185920k /dev/BLAH/data
Check the file system (in read only mode) again before proceeding:
e2fsck -fn /dev/BLAH/data