Chapter 8. Resizing Software RAID Arrays with mdadm

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.

[Warning]

Before starting any of the tasks described in this chapter, make sure that you have a valid backup of all of the data.

8.1. Understanding the Resizing Process

Resizing an existing software RAID device involves growing or shrinking the space contributed by each component partition.

8.1.1. Guidelines for Resizing a Software RAID

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 10 SP1, file system resizing utilities are available for file systems Ext2, Ext3, JFS, and ReiserFS. The utilities support growing and shrinking the size as follows:

Table 8.1. File System Support for Resizing

File System

Utility

Increase Size

Decrease Size

Ext2 or Ext3

resize2fs

Yes, offline only

Yes, offline only

JFS

mount -o remount,resize

Yes, online only

No

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.

[Warning]

To avoid data loss, make sure to back up your data before you begin any resizing task.

8.1.2. Overview of Tasks

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.

Table 8.2. Tasks Involved in Resizing a RAID

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, JFS, and ReiserFS.

3

1


8.2. Increasing the Size of a Software RAID

Before you begin, review the guidelines in Section 8.1, “Understanding the Resizing Process”.

8.2.1. Increasing the Size of Component Partitions

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.

[Warning]

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 make sure that you have a backup of your data available.

The procedure in this section uses the device names shown in the following table. Make sure to modify the names to use the names of your own devices.

Table 8.3. Scenario for Increasing the Size of Component Partitions

RAID Device

Component Partitions

/dev/md0

/dev/sda1

/dev/sdb1

/dev/sdc1


To increase the size of the component partitions for the RAID:

  1. Open a terminal console, then log in as the root user or equivalent.

  2. Make sure 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.

  3. 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.

  4. 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 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.

  5. 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.

  6. Repeat Step 2 through Step 5 for each of the remaining component devices in the array. Make sure to modify the commands for the correct component partition.

  7. 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.

  8. Continue with Section 8.2.2, “Increasing the Size of the RAID Array”.

8.2.2. Increasing the Size of the RAID Array

After you have resized each of the component partitions in the RAID (see Section 8.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. Make sure to modify the name to use the name of your own device.

  1. Open a terminal console, then log in as the root user or equivalent.

  2. 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"
    
  3. 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 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.

  4. 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"
    
  5. Do one of the following:

8.2.3. Increasing the Size of the File System

After you increase the size of the array (see Section 8.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, make sure 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.

8.2.3.1. Ext2 or Ext3

Ext2 and Ext3 file systems can be resized when mounted or unmounted with the command resize2fs.

  1. Open a terminal console, then log in as the root user or equivalent.

  2. 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 may 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.

  3. 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
    
  4. 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.

8.2.3.2. JFS

Resizing a JFS partition is done with a special option to the mount command that is specific to the JFS file system:

mount -o remount,resize /mnt

Using the resize option is valid only during a remount when the volume is already mounted read-write. The mount point is specified rather than the device name.

  1. Open a terminal console, then log in as the root user or equivalent.

  2. Increase the size of the file system on the software RAID device mounted at /mnt/point, using one of the following methods:

    • To extend the file system size to the maximum available size of the device, enter

      mount -o remount,resize /mnt/point
      

      The resize option with no value specified grows the volume to the full size of the partition.

    • To extend the file system to a specific size, enter

      mount -o remount,resize=size /mnt/point
      

      Replace size with the desired size in blocks based on the block size used for the file system.

      For example, if you have a 4 GB device with a block size of 4KB, enter

      mount -o remount,resize=1048576 /mnt/point
      

    Wait until the resizing is completed before continuing.

  3. 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.

8.2.3.3. ReiserFS

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.

  1. Open a terminal console, then log in as the root user or equivalent.

  2. 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 grows 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.

  3. 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
    
  4. 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.

8.3. Decreasing the Size of a Software RAID

Before you begin, review the guidelines in Section 8.1, “Understanding the Resizing Process”.

8.3.1. Decreasing the Size of the File System

When decreasing the size of the file system on a RAID device, make sure 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 SP1, only Ext2, Ext3, and ReiserFS provide utilities for shrinking 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. Make sure to modify commands to use the name of your own device.

8.3.1.1. Ext2 or Ext3

The Ext2 and Ext3 file systems can be resized when mounted or unmounted.

  1. Open a terminal console, then log in as the root user or equivalent.

  2. 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.

  3. 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
    
  4. 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.

8.3.1.2. JFS

JFS does not support shrinking a volume.

8.3.1.3. ReiserFS

ReiserFS file systems can be shrunk only if the volume is unmounted.

  1. Open a terminal console, then log in as the root user or equivalent.

  2. Unmount the device by entering

    umount /mnt/point
    

    If the partition you are attempting to shrink contains system files (such as the root (/) volume), unmounting is possible only when booting from a bootable CD or floppy.

  3. 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.

  4. Mount the file system by entering

    mount -t reiserfs /dev/md0 /mnt/point
    
  5. 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.

8.3.2. Decreasing the Size of Component Partitions

Resize the RAID’s component partitions one at a time. For each component partition, you remove it from the RAID, modify its partition size, return the partition to the RAID, then wait until the RAID stabilizes. 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.

[Warning]

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 make sure that you have a backup of your data available.

The procedure in this section uses the device names shown in the following table. Make sure to modify the commands to use the names of your own devices.

Table 8.4. Scenario for Increasing the Size of Component Partitions

RAID Device

Component Partitions

/dev/md0

/dev/sda1

/dev/sdb1

/dev/sdc1


To resize the component partitions for the RAID:

  1. Open a terminal console, then log in as the root user or equivalent.

  2. Make sure 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.

  3. 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.

  4. Increase the size of the partition that you removed in Step 3 by doing one of the following:

    • Use a disk partitioner such as fdisk, cfdisk, or parted to increase the size of the partition.

    • Replace the disk on which the partition resides with a different 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.

  5. 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.

  6. Repeat Step 2 through Step 5 for each of the remaining component devices in the array. Make sure to modify the commands for the correct component partition.

  7. 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.

  8. Continue with Section 8.3.3, “Decreasing the Size of the RAID Array”.

8.3.3. Decreasing the Size of the RAID Array

After you have resized each of the component partitions in the RAID, 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. Make sure to modify commands to use the name of your own device.

  1. Open a terminal console, then log in as the root user or equivalent.

  2. 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"
    
  3. 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 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.)

  4. 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"
    
  5. Do one of the following:

    • If your array was successfully resized, you are done.

    • If your array was not resized as you expected, you must reboot, then try this procedure again.


SUSE® Linux Enterprise Server Storage Administration Guide 10 SP3/SP4