General Information
Two tools are needed to resize a reiserfs partition. The first,
fdisk, should come as part of the debian base set of packages. The second,
resize_reiserfs, is part of the
reiserfsprogs package in the debian repositories and can be obtained via:
apt-get install reiserfsprogs
Shrinking
The first step in shrinking a
reiserfs partition is to umount it. Note that in some cases unmounting will only be possible when booting from a live-cd or live-floppy since the partition may contain neccessary system files:
umount /dev/hda1
Next the
reiserfs filesystem must be shrunk such that it will still fit once the partition is resized. For example, if it is neccessary to reduce the partition size by 2GB, the filesystem mush first be shrunk by at
least as much (in this example we'll shrink the filesystem by 3GB):
resize_reiserfs -s-3G /dev/hda1
Now it is possible to run fdisk on the target drive:
fdisk /dev/hda
It will now be neccessary to figure out how many cylinders are equivalent to 2GB (fdisk will provide the number of bytes per cylinder if the 'p' command is issued):
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 8005 64300130+ 83 Linux
/dev/hda2 8006 8068 506047+ 82 Linux swap / Solaris
/dev/hda3 8069 9729 13341982+ 83 Linux
Command (m for help):
In this case 2GB = 2147483648 bytes = about 261 cylinders which need to be removed from
/dev/hda1. To do this using fdisk, the target partition must be deleted and then recreated with the new desired size but with
the same starting cylinder (otherwise the filesystem will be corrupted). Once this is done the partition table in the example should look something like this:
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
<b>Units = cylinders of 16065 * 512 = 8225280 bytes</b>
Device Boot Start End Blocks Id System
/dev/hda1 * 1 7744 62203648+ 83 Linux
/dev/hda2 8006 8068 506047+ 82 Linux swap / Solaris
/dev/hda3 8069 9729 13341982+ 83 Linux
Command (m for help):
Now the write command should be issued to write the changes to disk. All that remains is to expand the filesystem to fully fill the new size of the partition, this is done using
resize_reiserfs without the
-s argument:
resize_reiserfs /dev/hda1
Growing
Growing a reiserfs partition is somewhat easier than shrinking one. As above, fdisk must be used to delete the target partition and then recreate it with the new desired size but with
the same starting cylinder. Running
resize_reiserfs will then expand the filesystem to the new size of the partition:
resize_reiserfs /dev/hda1
--
AlexBencz - 16 May 2006