Jump to contentJump to page navigation: previous page [access key p]/next page [access key n]
Applies to SUSE Linux Enterprise Server 12 SP4

2 Resizing File Systems Edit source

Resizing file systems—not to be confused with resizing partitions or volumes—can be used to make space available on physical volumes or to use additional space available on a physical volume.

2.1 Use Cases Edit source

It is strongly recommended to use the YaST Partitioner to resize partitions or logical volumes. When doing so, the file system will automatically be adjusted to the new size of the partition or volume. However, there are some cases where you need to resize the file system manually, because they are not supported by YaST:

  • After having resized a virtual disk of a VM Guest.

  • After having resized a volume from a network-attached storage.

  • After having manually resized partitions (for example by using fdisk or parted) or logical volumes (for example by using lvresize).

  • When wanting to shrink Btrfs file systems (as of SUSE Linux Enterprise Server 12, YaST only supports growing Btrfs file systems).

2.2 Guidelines for Resizing Edit source

Resizing any file system involves some risks that can potentially result in losing data.

Warning
Warning: Back Up your 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.

2.2.1 File Systems that Support Resizing Edit source

The file system must support resizing 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:

Table 2.1: File System Support for Resizing

File System

Utility

Increase Size (Grow)

Decrease Size (Shrink)

Btrfs

btrfs filesystem resize

Online

Online

XFS

xfs_growfs

Online

Not supported

Ext2

resize2fs

Online or offline

Offline only

Ext3

resize2fs

Online or offline

Offline only

Ext4

resize2fs

Online or offline

Offline only

ReiserFS

resize_reiserfs

Online or offline

Offline only

2.2.2 Increasing the Size of a File System Edit source

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.

2.2.3 Decreasing the Size of a File System Edit source

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.

Important
Important: XFS

Decreasing the size of a file system formatted with XFS is not possible, since such a feature is not supported by XFS.

2.3 Changing the Size of a Btrfs File System Edit source

The size of a Btrfs file system can be changed by using the btrfs filesystem resize command when the file system is mounted. Increasing and decreasing the size are both supported while the file system is mounted.

  1. Open a terminal console.

  2. Make sure the file system you want to change is mounted.

  3. Change the size of the file system using the btrfs filesystem resize command with one of the following methods:

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

      sudo btrfs filesystem resize max /mnt
    • To extend the file system to a specific size, enter

      sudo btrfs filesystem resize SIZE /mnt

      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 or decrease to the current size by prefixing the value with a plus (+) or a minus (-) sign, respectively:

      sudo btrfs filesystem resize +SIZE /mnt
      sudo btrfs filesystem resize -SIZE /mnt
  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 prints sizes in human-readable format, such as 1K, 234M, or 2G.

2.4 Changing the Size of an XFS File System Edit source

The size of an XFS file system can be increased by using the xfs_growfs command when the file system is mounted. Reducing the size of an XFS file system is not possible.

  1. Open a terminal console.

  2. Make sure the file system you want to change is mounted.

  3. Increase the size of the file system using the xfs_growfs command. The following example expands the size of the file system to the maximum value available. See man 8 xfs_growfs for more options.

    sudo xfs_growfs -d /mnt
  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 prints sizes in human-readable format, such as 1K, 234M, or 2G.

2.5 Changing the Size of an Ext2, Ext3, or Ext4 File System Edit source

The size of Ext2, Ext3, and Ext4 file systems can be increased by using the resize2fs command, regardless of whether the respective partition is mounted or not. To decrease the size of an Ext file system it needs to be unmounted.

  1. Open a terminal console.

  2. If the file system size should be decreased, unmount it.

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

      sudo resize2fs /dev/sda1

      If a size parameter is not specified, the size defaults to the size of the partition.

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

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

  4. If the file system is not mounted, mount it now.

  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 prints sizes in human-readable format, such as 1K, 234M, or 2G.

2.6 Changing the Size of a Reiser File System Edit source

A ReiserFS file system can be increased in size while mounted or unmounted. To decrease its size it needs to be unmounted.

  1. Open a terminal console.

  2. If you want to decrease the size of the file system, unmount it in case it is mounted.

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

      sudo 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

      sudo 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 or decrease to the current size by prefixing the value with a plus (+) or minus (-) sign, respectively:

      sudo resize_reiserfs -s +SIZE /dev/sda2
      sudo resize_reiserfs -s -SIZE /dev/sda2

    Wait until the resizing is completed before continuing.

  4. If the file system is not mounted, mount it now.

  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 prints sizes in human-readable format, such as 1K, 234M, or 2G.

Print this page