This section describes how to increase or reduce the size of a software
RAID 1, 4, 5, or 6 device with the Multiple Device Administration
(mdadm(8)) tool.
Before starting any of the tasks described in this section, ensure that you have a valid backup of all of the data.
Resizing an existing software RAID device involves increasing or decreasing the space contributed by each component partition.
The mdadm(8) tool supports resizing only for
software RAID levels 1, 4, 5, and 6. These RAID levels provide disk
fault tolerance so that one component partition can be removed at a
time for resizing. In principle, it is possible to perform a hot resize
for RAID partitions, but you must take extra care for your data when
doing so.
The file system that resides on the RAID must also be able to be resized in order to take advantage of the changes in available space on the device. In SUSE Linux Enterprise Server, file system resizing utilities are available for file systems Ext2, Ext3, and ReiserFS. The utilities support increasing and decreasing the size as follows:
|
File System |
Utility |
Increase Size |
Decrease Size |
|---|---|---|---|
|
Ext2 or Ext3 |
resize2fs |
Yes, offline only |
Yes, offline only |
|
ReiserFS |
resize_reiserfs |
Yes, online or offline |
Yes, offline only |
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.
Resizing the RAID involves the following tasks. The order in which these tasks is performed depends on whether you are increasing or decreasing its size.
|
Tasks |
Description |
Order If Increasing Size |
Order If Decreasing Size |
|---|---|---|---|
|
Resize each of the component partitions. |
Increase or decrease the active size of each component partition. You remove only one component partition at a time, modify its size, then return it to the RAID. |
1 |
2 |
|
Resize the software RAID itself. |
The RAID does not automatically know about the increases or decreases you make to the underlying component partitions. You must inform it about the new size. |
2 |
3 |
|
Resize the file system. |
You must resize the file system that resides on the RAID. This is possible only for file systems that provide tools for resizing, such as Ext2, Ext3, and ReiserFS. |
3 |
1 |
Before you begin, review the guidelines in Section 11.1, “Understanding the Resizing Process”.
Apply the procedure in this section to increase the size of a RAID 1, 4, 5, or 6. For each component partition in the RAID, remove the partition from the RAID, modify its size, return it to the RAID, then wait until the RAID stabilizes to continue. While a partition is removed, the RAID operates in degraded mode and has no or reduced disk fault tolerance. Even for RAIDs that can tolerate multiple concurrent disk failures, do not remove more than one component partition at a time.
If a RAID does not have disk fault tolerance, or it is simply not consistent, data loss results if you remove any of its partitions. Be very careful when removing partitions, and ensure that you have a backup of your data available.
The procedure in this section uses the device names shown in the following table. Ensure that you modify the names to use the names of your own devices.
|
RAID Device |
Component Partitions |
|---|---|
|
|
|
To increase the size of the component partitions for the RAID:
Open a terminal console, then log in as the
root user or equivalent.
Ensure that the RAID array is consistent and synchronized by entering
cat /proc/mdstat
If your RAID array is still synchronizing according to the output of this command, you must wait until synchronization is complete before continuing.
Remove one of the component partitions from the RAID array. For
example, to remove /dev/sda1, enter
mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1
In order to succeed, both the fail and remove actions must be done.
Increase the size of the partition that you removed in Step 3 by doing one of the following:
Increase the size of the partition, using a disk partitioner such
as fdisk(8), cfdisk(8), or
parted(8). This option is the usual choice.
Replace the disk on which the partition resides with a higher-capacity device.
This option is possible only if no other file systems on the original disk are accessed by the system. When the replacement device is added back into the RAID, it takes much longer to synchronize the data because all of the data that was on the original device must be rebuilt.
Re-add the partition to the RAID array. For example, to add
/dev/sda1, enter
mdadm -a /dev/md0 /dev/sda1
Wait until the RAID is synchronized and consistent before continuing with the next partition.
Repeat Step 2 through Step 5 for each of the remaining component devices in the array. Ensure that you modify the commands for the correct component partition.
If you get a message that tells you that the kernel could not re-read the partition table for the RAID, you must reboot the computer after all partitions have been resized to force an update of the partition table.
Continue with Section 11.2.2, “Increasing the Size of the RAID Array”.
After you have resized each of the component partitions in the RAID (see Section 11.2.1, “Increasing the Size of Component Partitions”), the RAID array configuration continues to use the original array size until you force it to be aware of the newly available space. You can specify a size for the RAID or use the maximum available space.
The procedure in this section uses the device name
/dev/md0 for the RAID device. Ensure that you
modify the name to use the name of your own device.
Open a terminal console, then log in as the
root user or equivalent.
Check the size of the array and the device size known to the array by entering
mdadm -D /dev/md0 | grep -e "Array Size" -e "Device Size"
Do one of the following:
Increase the size of the array to the maximum available size by entering
mdadm --grow /dev/md0 -z max
Increase the size of the array to the maximum available size by entering
mdadm --grow /dev/md0 -z max --assume-clean
The array makes use of any space that has been added to the devices, but this space will not be synchronized. This is recommended for RAID1 because the sync is not needed. It can be useful for other RAID levels if the space that was added to the member devices was pre-zeroed.
Increase the size of the array to a specified value by entering
mdadm --grow /dev/md0 -z size
Replace size with an integer value in kilobytes (a kilobyte is 1024 bytes) for the desired size.
Recheck the size of your array and the device size known to the array by entering
mdadm -D /dev/md0 | grep -e "Array Size" -e "Device Size"
Do one of the following:
If your array was successfully resized, continue with Section 11.2.3, “Increasing the Size of the File System”.
If your array was not resized as you expected, you must reboot, then try this procedure again.
After you increase the size of the array (see Section 11.2.2, “Increasing the Size of the RAID Array”), you are ready to resize the file system.
You can increase the size of the file system to the maximum space available or specify an exact size. 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 RAID size because the file system size cannot extend beyond the space available.
Ext2 and Ext3 file systems can be resized when mounted or unmounted
with the resize2fs command.
Open a terminal console, then log in as the
root user or equivalent.
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 software RAID device called /dev/md0,
enter
resize2fs /dev/md0
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/md0 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 RAID named
/dev/md0 at mount point
/raid, enter
mount -t ext2 /dev/md0 /raid
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.
As with Ext2 and Ext3, a ReiserFS file system can be increased in size while mounted or unmounted. The resize is done on the block device of your RAID array.
Open a terminal console, then log in as the
root user or equivalent.
Increase the size of the file system on the software RAID device
called /dev/md0, using one of the following
methods:
To extend the file system size to the maximum available size of the device, enter
resize_reiserfs /dev/md0
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/md0
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/md0 by 500 MB:
resize_reiserfs -s +500M /dev/md0
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 a RAID named
/dev/md0 at mount point
/raid, enter
mount -t reiserfs /dev/md0 /raid
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.
Before you begin, review the guidelines in Section 11.1, “Understanding the Resizing Process”.
When decreasing the size of the file system on a RAID 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 RAID size because the file system size cannot extend beyond the space available.
In SUSE Linux Enterprise Server, Ext2, Ext3, and ReiserFS provide utilities for decreasing the size of the file system. Use the appropriate procedure below for decreasing the size of your file system.
The procedures in this section use the device name
/dev/md0 for the RAID device. Ensure that you
modify commands to use the name of your own device.
The Ext2 and Ext3 file systems can be resized when mounted or unmounted.
Open a terminal console, then log in as the
root user or equivalent.
Decrease the size of the file system on the RAID by entering
resize2fs /dev/md0 <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.
If the file system is not mounted, mount it now. For example, to
mount an Ext2 file system for a RAID named
/dev/md0 at mount point
/raid, enter
mount -t ext2 /dev/md0 /raid
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.
Continue with Section 11.3.2, “Decreasing the Size of the RAID Array”.
ReiserFS file systems can be decreased 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 the software RAID device
called /dev/md0 by entering
resize_reiserfs -s size /dev/md0
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/md0
Wait until the resizing is completed before continuing.
Mount the file system by entering
mount -t reiserfs /dev/md0 /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.
Continue with Section 11.3.2, “Decreasing the Size of the RAID Array”.
After you have resized the file system, the RAID array configuration
continues to use the original array size until you force it to reduce
the available space. Use the mdadm --grow mode to
force the RAID to use a smaller segment size. To do this, you must use
the -z option to specify the amount of space in kilobytes to use from
each device in the RAID. This size must be a multiple of the chunk
size, and it must leave about 128KB of space for the RAID superblock to
be written to the device.
The procedure in this section uses the device name
/dev/md0 for the RAID device. Ensure that you
modify commands to use the name of your own device.
Open a terminal console, then log in as the
root user or equivalent.
Check the size of the array and the device size known to the array by entering
mdadm -D /dev/md0 | grep -e "Array Size" -e "Device Size"
Decrease the size of the array’s device size to a specified value by entering
mdadm --grow /dev/md0 -z <size>
Replace size with an integer value in kilobytes for the desired size. (A kilobyte is 1024 bytes.)
For example, the following command sets the segment size for each RAID device to about 40 GB where the chunk size is 64 KB. It includes 128 KB for the RAID superblock.
mdadm --grow /dev/md2 -z 41943168
Recheck the size of your array and the device size known to the array by entering
mdadm -D /dev/md0 | grep -e "Array Size" -e "Device Size"
Do one of the following:
If your array was successfully resized, continue with Section 11.3.3, “Decreasing the Size of Component Partitions”.
If your array was not resized as you expected, you must reboot, then try this procedure again.
After you decrease the segment size that is used on each device in the RAID, the remaining space in each component partition is not used by the RAID. You can leave partitions at their current size to allow for the RAID to grow at a future time, or you can reclaim this now unused space.
To reclaim the space, you decrease the component partitions one at a time. For each component partition, you remove it from the RAID, reduce its partition size, return the partition to the RAID, then wait until the RAID stabilizes. To allow for metadata, you should specify a slightly larger size than the size you specified for the RAID in Section 11.3.2, “Decreasing the Size of the RAID Array”.
While a partition is removed, the RAID operates in degraded mode and has no or reduced disk fault tolerance. Even for RAIDs that can tolerate multiple concurrent disk failures, you should never remove more than one component partition at a time.
If a RAID does not have disk fault tolerance, or it is simply not consistent, data loss results if you remove any of its partitions. Be very careful when removing partitions, and ensure that you have a backup of your data available.
The procedure in this section uses the device names shown in the following table. Ensure that you modify the commands to use the names of your own devices.
|
RAID Device |
Component Partitions |
|---|---|
|
|
|
To decrease the size of the component partitions for the RAID:
Open a terminal console, then log in as the
root user or equivalent.
Ensure that the RAID array is consistent and synchronized by entering
cat /proc/mdstat
If your RAID array is still synchronizing according to the output of this command, you must wait until synchronization is complete before continuing.
Remove one of the component partitions from the RAID array. For
example, to remove /dev/sda1, enter
mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1
In order to succeed, both the fail and remove actions must be done.
Decrease the size of the partition that you removed in
Step 3 to a size that is
slightly larger than the size you set for the segment size. The size
should be a multiple of the chunk size and allow 128 KB for the RAID
superblock. Use a disk partitioner such as fdisk,
cfdisk, or parted to decrease
the size of the partition.
Re-add the partition to the RAID array. For example, to add
/dev/sda1, enter
mdadm -a /dev/md0 /dev/sda1
Wait until the RAID is synchronized and consistent before continuing with the next partition.
Repeat Step 2 through Step 5 for each of the remaining component devices in the array. Ensure that you modify the commands for the correct component partition.
If you get a message that tells you that the kernel could not re-read the partition table for the RAID, you must reboot the computer after resizing all of its component partitions.
(Optional) Expand the size of the RAID and file system to use the maximum amount of space in the now smaller component partitions:
Expand the size of the RAID to use the maximum amount of space that is now available in the reduced-size component partitions:
mdadm --grow /dev/md0 -z max
Expand the size of the file system to use all of the available space in the newly resized RAID. For information, see Section 11.2.3, “Increasing the Size of the File System”.