Bash Wiki
Posts (Latest 30 updated) :
Read all
Contents:
  1. [Linux] Bash resize2fs Usage: Resize ext2/ext3/ext4 file systems
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[Linux] Bash resize2fs Usage: Resize ext2/ext3/ext4 file systems

Overview

The resize2fs command is used to resize ext2, ext3, or ext4 file systems. It allows you to increase or decrease the size of a file system on a partition without losing data, making it a valuable tool for managing disk space.

Usage

The basic syntax of the resize2fs command is as follows:

resize2fs [options] [arguments]

Common Options

  • -f: Force the resize operation, even if the file system is mounted.
  • -p: Print progress information while resizing.
  • -s: Resize the file system to the size of the underlying block device.
  • -M: Minimize the size of the file system.
  • -d: Enable debug output.

Common Examples

Here are some practical examples of using resize2fs:

  1. Resize a file system to a specific size:
    resize2fs /dev/sda1 20G
    

    This command resizes the file system on /dev/sda1 to 20 gigabytes.

  2. Resize a file system to use all available space:
    resize2fs /dev/sda1
    

    This command will expand the file system on /dev/sda1 to fill the entire partition.

  3. Force a resize operation:
    resize2fs -f /dev/sda1 15G
    

    This command forces the resize of the file system on /dev/sda1 to 15 gigabytes, even if it is mounted.

  4. Print progress while resizing:
    resize2fs -p /dev/sda1
    

    This command will resize the file system on /dev/sda1 and display the progress of the operation.

Tips

  • Always ensure that you have a backup of your data before resizing a file system, as there is a risk of data loss.
  • It is recommended to unmount the file system before resizing it to avoid potential issues.
  • Use the -M option to minimize the file system size, which can help in reclaiming unused space effectively.