When your data needs grow for a volume, you might need to increase the amount of space allocated to its file system.
Resizing any partition or file system involves some risks that can potentially result in losing data.
To avoid data loss, ensure that you back up your data before you begin any resizing task.
Consider the following guidelines when planning to resize a file system.
The file system must support resizing in order to take advantage of increases in available space for the volume. In SUSE Linux Enterprise Server, file system resizing utilities are available for file systems Ext2, Ext3, Ext4, and ReiserFS. The utilities support increasing and decreasing the size as follows:
|
File System |
Utility |
Increase Size (Grow) |
Decrease Size (Shrink) |
|---|---|---|---|
|
Ext2 |
resize2fs |
Offline only |
Offline only |
|
Ext3 |
resize2fs |
Online or offline |
Offline only |
|
Ext4 |
resize2fs |
Offline only |
Offline only |
|
ReiserFS |
resize_reiserfs |
Online or offline |
Offline only |
You can grow a file system to the maximum space available on the device, or specify an exact size. Ensure that you grow the size of the device or logical volume before you attempt to increase the size of the file system.
When specifying an exact size for the file system, ensure that the new size satisfies the following conditions:
The new size must be greater than the size of the existing data; otherwise, data loss occurs.
The new size must be equal to or less than the current device size because the file system size cannot extend beyond the space available.
When decreasing the size of the file system on a device, ensure that the new size satisfies the following conditions:
The new size must be greater than the size of the existing data; otherwise, data loss occurs.
The new size must be equal to or less than the current device size because the file system size cannot extend beyond the space available.
If you plan to also decrease the size of the logical volume that holds the file system, ensure that you decrease the size of the file system before you attempt to decrease the size of the device or logical volume.
The size of Ext2, Ext3, and Ext4 file systems can be increased by using
the resize2fs command when the file system is
mounted. The size of an Ext3 file system can also be increased by using
the resize2fs command when the file system is
unmounted.
Open a terminal console, then log in as the
root user or equivalent.
If the file system is Ext2 or Ext4, you must unmount the file system. The Ext3 file system can be mounted or unmounted.
Increase the size of the file system using one of the following methods:
To extend the file system size to the maximum available size of the
device called /dev/sda1, enter
resize2fs /dev/sda1
If a size parameter is not specified, the size defaults to the size of the partition.
To extend the file system to a specific size, enter
resize2fs /dev/sda1 size
The size parameter specifies the requested new size of the file system. If no units are specified, the unit of the size parameter is the block size of the file system. Optionally, the size parameter can be suffixed by one of the following the unit designators: s for 512 byte sectors; K for kilobytes (1 kilobyte is 1024 bytes); M for megabytes; or G for gigabytes.
Wait until the resizing is completed before continuing.
If the file system is not mounted, mount it now.
For example, to mount an Ext2 file system for a device named
/dev/sda1 at mount point
/home, enter
mount -t ext2 /dev/sda1 /home
Check the effect of the resize on the mounted file system by entering
df -h
The Disk Free (df) command shows the total size of
the disk, the number of blocks used, and the number of blocks
available on the file system. The -h option print sizes in
human-readable format, such as 1K, 234M, or 2G.
A ReiserFS file system can be increased in size while mounted or unmounted.
Open a terminal console, then log in as the
root user or equivalent.
Increase the size of the file system on the device called
/dev/sda2, using one of the following methods:
To extend the file system size to the maximum available size of the device, enter
resize_reiserfs /dev/sda2
When no size is specified, this increases the volume to the full size of the partition.
To extend the file system to a specific size, enter
resize_reiserfs -s size /dev/sda2
Replace size with the desired size in
bytes. You can also specify units on the value, such as 50000K
(kilobytes), 250M (megabytes), or 2G (gigabytes). Alternatively, you
can specify an increase to the current size by prefixing the value
with a plus (+) sign. For example, the following command increases
the size of the file system on /dev/sda2 by 500
MB:
resize_reiserfs -s +500M /dev/sda2
Wait until the resizing is completed before continuing.
If the file system is not mounted, mount it now.
For example, to mount an ReiserFS file system for device
/dev/sda2 at mount point
/home, enter
mount -t reiserfs /dev/sda2 /home
Check the effect of the resize on the mounted file system by entering
df -h
The Disk Free (df) command shows the total size of
the disk, the number of blocks used, and the number of blocks
available on the file system. The -h option print sizes in
human-readable format, such as 1K, 234M, or 2G.
You can shrink the size of the Ext2, Ext3, or Ext4 file systems when the volume is unmounted.
Open a terminal console, then log in as the
root user or equivalent.
Unmount the file system.
Decrease the size of the file system on the device such as
/dev/sda1 by entering
resize2fs /dev/sda1 <size>
Replace size with an integer value in kilobytes for the desired size. (A kilobyte is 1024 bytes.)
Wait until the resizing is completed before continuing.
Mount the file system. For example, to mount an Ext2 file system for a
device named /dev/sda1 at mount point
/home, enter
mount -t ext2 /dev/md0 /home
Check the effect of the resize on the mounted file system by entering
df -h
The Disk Free (df) command shows the total size of
the disk, the number of blocks used, and the number of blocks
available on the file system. The -h option print sizes in
human-readable format, such as 1K, 234M, or 2G.
Reiser file systems can be reduced in size only if the volume is unmounted.
Open a terminal console, then log in as the
root user or equivalent.
Unmount the device by entering
umount /mnt/point
If the partition you are attempting to decrease in size contains
system files (such as the root (/) volume),
unmounting is possible only when booting from a removable device.
Decrease the size of the file system on a device called
/dev/sda1 by entering
resize_reiserfs -s size /dev/sda2
Replace size with the desired size in
bytes. You can also specify units on the value, such as 50000K
(kilobytes), 250M (megabytes), or 2G (gigabytes). Alternatively, you
can specify a decrease to the current size by prefixing the value with
a minus (-) sign. For example, the following command reduces the size
of the file system on /dev/md0 by 500 MB:
resize_reiserfs -s -500M /dev/sda2
Wait until the resizing is completed before continuing.
Mount the file system by entering
mount -t reiserfs /dev/sda2 /mnt/point
Check the effect of the resize on the mounted file system by entering
df -h
The Disk Free (df) command shows the total size of
the disk, the number of blocks used, and the number of blocks
available on the file system. The -h option print sizes in
human-readable format, such as 1K, 234M, or 2G.