Home / Alt manpages / fsadm(8)

  • fsadm(8)
  • Admin command
  • linux

Resize or Check a Linux Filesystem Safely with fsadm

Get the device wrong and fsadm will happily resize the wrong volume, so the tool forces you to check first, preview second, and apply last. The examples match lvm2 2.03.16-3ubuntu3.2, installed here on Ubuntu. Allow 15 minutes for a read-only check or dry run, and longer for a real resize because you need a maintenance window and a verified recovery plan.

Warning

Resizing storage changes data layout and can make a filesystem or its contents unavailable if the device, size or filesystem type is wrong. Do not substitute a guessed device. Confirm the block device, mount point, filesystem type, free space and backup before you run a command that changes state.

1. Check the installed command

Confirm the binary and package version first. These are ordinary read-only commands and do not need sudo:

$ command -v fsadm
/usr/sbin/fsadm
$ dpkg-query -W -f='${Package} ${Version}\n' lvm2
lvm2 2.03.16-3ubuntu3.2
$ fsadm --help
fsadm: Utility to resize or check the filesystem on a device

  fsadm [options] check <device>
    - Check the filesystem on device using fsck

  fsadm [options] resize <device> [<new_size>[BKMGTPE]]
    - Change the size of the filesystem on device to new_size
  • Two subcommands. check runs fsck on the device, resize changes its size.
  • Wide filesystem support. ext2, ext3, ext4, ReiserFS and XFS, plus dm-crypt encrypted devices.
  • The man page rules. It is the authority for this machine, so check it again after an lvm2 upgrade.
$ man 8 fsadm

2. Identify the exact device

Do not infer a logical volume's name from a ticket or hostname. Replace /dev/vgname/lvname below only after checking your own inventory and mount inspection, and stop if the results do not agree:

$ lsblk -f
$ findmnt --source /dev/vgname/lvname
$ stat --printf='%n\n' /dev/vgname/lvname
  • lsblk -f shows filesystem and mount information.
  • findmnt confirms whether the selected device is mounted.
  • stat confirms that the path exists.

None of these three alter storage. This checkpoint is where you catch the common error of selecting the whole disk, a partition, a snapshot, or the wrong logical volume.

3. Check the filesystem

Run a check against the confirmed device. fsadm invokes the filesystem-specific checker, so expect it to need elevated privileges when it must read the block device or operate around a mount:

$ sudo fsadm check /dev/vgname/lvname
$ printf 'exit status: %s\n' "$?"
exit status: 0
  • Status 0. The operation completed successfully.
  • Status 1. Another failure occurred.
  • Status 2. The operation was interrupted by the user.
  • Status 3. The check could not be performed because the filesystem is mounted and does not support an online fsck.

Read the diagnostic text as well as the numeric status. If status 3 comes back, do not add --force as a reflex: arrange an outage or maintenance boot, unmount the filesystem where appropriate, and rerun the check according to the filesystem's own recovery procedure. The check itself is not a repair guarantee, and a mounted filesystem may limit what can safely be inspected.

4. Preview a resize without running it

Before changing anything, use --dry-run. It prints the commands fsadm would use without running them: a review checkpoint, not a substitute for a backup.

$ sudo fsadm --dry-run --verbose resize /dev/vgname/lvname 1000M

The exact preview depends on the device and filesystem, so do not copy an output transcript from another host as proof. Check that the device path, detected filesystem and requested size are all the ones you intended.

  • The size is absolute, not an increment. 1000M means an absolute size in mebibyte-style units, not "add 1000 MB". Suffixes use powers of 1024.
  • No size means the whole device. If you omit new_size, fsadm uses the whole device.

Keep the filesystem's current size and the containing device's size in your change record. A filesystem cannot safely be made larger than the available block device, and shrinking requires enough free space and a filesystem that supports the requested operation. fsadm does not turn an unsafe size into a safe one.

5. Apply the resize only after the checkpoint

Resizing is the state-changing step. Take or verify a restorable backup, confirm the service using the filesystem is stopped or tolerant of the maintenance window, and make sure you can identify the device from a rescue environment if recovery is needed. There is no generic undo command for a completed resize: restoring data from backup or restoring the storage layout is the recovery path.

For an ext2, ext3 or ext4 filesystem, --ext-offline tells fsadm to unmount it before resizing. That can disrupt services and may fail if another process still has the mount open:

$ sudo fsadm --ext-offline --verbose resize /dev/vgname/lvname 1000M
  • Answer prompts interactively unless your reviewed automation requires otherwise.
  • --yes answers yes to prompts, which removes a useful safety pause.
  • --force bypasses some sanity checks and should be reserved for a documented, understood case. Neither option repairs a wrong device selection.

If the device is an LVM logical volume, --lvresize asks fsadm to resize the logical volume as well as the filesystem:

$ sudo fsadm --lvresize resize /dev/vgname/lvname 1000M

Use that only when the logical-volume change is part of the approved plan. The manual points to lvresize and its --resizefs option for broader LVM workflows. Do not combine storage-layer changes casually: confirm the resulting LV and filesystem sizes after the command.

6. Handle encrypted devices deliberately

For a recognisable dm-crypt device, --cryptresize asks fsadm to resize the dm-crypt mapping together with the detected filesystem:

$ sudo fsadm --cryptresize resize /dev/mapper/cryptname 1000M

The mapping must be recognisable by cryptsetup. Confirm the mapping and its backing layers before using this option. An encrypted device adds another boundary to the recovery plan, so keep the required key material and unlocking procedure available before the maintenance window. If the mapping is not the device you inspected, stop rather than trying --force.

7. Verify the result

After a successful resize, inspect the layers again. These are ordinary read-only checks:

$ lsblk -f
$ findmnt --source /dev/vgname/lvname
$ sudo fsadm check /dev/vgname/lvname
$ printf 'check status: %s\n' "$?"
check status: 0

Compare the reported filesystem size with the approved target, confirm the expected mount is present, and check that the service can read and write its normal data. If the command was interrupted, preserve the diagnostic output and do not immediately repeat a resize until the device state is understood.

Done means

  • Device confirmed. The exact device, filesystem, mount point and containing storage layer were confirmed.
  • Recovery ready. A backup or other recovery path was verified before the state-changing command.
  • Size reviewed. The requested absolute size was reviewed with --dry-run.
  • Impact planned. Any unmount, LVM or dm-crypt impact was included in the maintenance plan.
  • Result checked. lsblk, findmnt and a final fsadm check agree with the intended result.