Decreasing the Size of a Software RAID

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

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.

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.

JFS

JFS does not support shrinking a volume.

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.

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

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