Home / Alt manpages / ext2(5)

  • ext2(5)
  • File format
  • linux

Configure and Safely Mount an ext2 File System

You will inspect an ext2 file system's stored defaults, choose mount options for a real use case, and prepare a reversible /etc/fstab entry. The examples use e2fsprogs 1.47.0, installed here as package version 1.47.0-2.4~exp1ubuntu4.1. Allow about fifteen minutes, plus time to schedule a maintenance window if the file system is in service.

You need a shell, an existing ext2 file system, and its device or image path. Reading metadata is normally unprivileged only when the device permissions allow it. Inspecting a block device, changing /etc/fstab, mounting, and running a repair check generally require elevated privileges. Replace every placeholder before running a command.

1. Confirm what Linux is actually using

Start with read-only identification. An ext2 file system can be mounted by the ext4 driver on modern Linux, so do not infer the driver from the file system label alone:

$ findmnt --source /dev/EXAMPLE_DEVICE --output SOURCE,FSTYPE,OPTIONS
$ sudo blkid /dev/EXAMPLE_DEVICE
/dev/EXAMPLE_DEVICE: UUID="EXAMPLE-UUID" TYPE="ext2"

The TYPE value describes the on-disk format. The FSTYPE value from findmnt describes the current mount. If the device is already mounted, record its mount point and options before changing anything. Do not format it to make the type match: mkfs.ext2 destroys the existing contents.

Checkpoint

Continue only when the device, UUID, and intended mount directory all identify the same file system. A copied device name is an easy way to configure the wrong disk.

2. Read the superblock defaults

The ext2 manual says that, for most mount options, the default comes from the file system superblock. Use tune2fs -l to inspect those values without changing them:

$ sudo tune2fs -l /dev/EXAMPLE_DEVICE | grep -E 'Filesystem features|Default mount options|Errors behavior|Reserved block count|Filesystem UUID'
Filesystem UUID:          EXAMPLE-UUID
Filesystem features:      ext_attr resize_inode dir_index filetype sparse_super large_file
Default mount options:    user_xattr acl
Errors behavior:          Continue
Reserved block count:     409

Your UUID, feature list and reserved count will differ. On this e2fsprogs build, a newly created small ext2 image reported user_xattr acl as its defaults and Continue as its error policy. Treat that as an observation, not a universal default: the file system itself and the kernel driver decide what applies.

Features are not interchangeable with mount options. For example, has_journal is a feature used by ext3 and ext4 and is ignored by the ext2 driver. An ext2 file system does not become journaled because a journal-related option appeared in an example for another file system.

3. Choose the small set of options you need

Keep the option list explicit. The ext2-specific options most likely to matter in an ordinary mount are:

  • acl or noacl controls POSIX access control list support.
  • user_xattr or nouser_xattr controls user. extended attributes.
  • errors=continue, errors=remount-ro, or errors=panic selects the reaction to a file system error. panic can halt the machine and is not a casual troubleshooting setting.
  • grpid makes new files inherit the containing directory's group ID; without it, the process group ID normally applies, subject to the directory setgid bit.
  • bsddf is the default space-reporting behaviour; minixdf reports total blocks in the statfs result instead of subtracting ext2 overhead.

Do not add check=normal or check=strict. The installed manual identifies check=none and nocheck as the default and says the older checking modes have been removed. A mount is not a substitute for an offline e2fsck run.

4. Test the option string for one mount

Create the mount directory if it does not exist, then mount the known device for a controlled test. Both commands change system state and need root. Make sure the directory is empty and that no service depends on it:

$ sudo install -d -m 0755 /mnt/EXAMPLE_MOUNT
$ sudo mount -t ext2 -o acl,user_xattr,errors=remount-ro /dev/EXAMPLE_DEVICE /mnt/EXAMPLE_MOUNT
$ findmnt --target /mnt/EXAMPLE_MOUNT --output SOURCE,FSTYPE,OPTIONS
SOURCE              FSTYPE OPTIONS
/dev/EXAMPLE_DEVICE ext2   rw,relatime,acl,user_xattr,errors=remount-ro

Option ordering and extra generic options vary by kernel. The useful checks are the source, the reported file system type, and the options you requested. Verify access with a harmless read:

$ sudo sh -c 'test -r /mnt/EXAMPLE_MOUNT && printf "%s\n" readable'
readable

Warning

Never test an unverified device at a mount point containing valuable data. If the mount fails, read the error and inspect journalctl -k -n 50; do not immediately try random options. To undo this test, stop users and services using the mount, then run:

$ sudo umount /mnt/EXAMPLE_MOUNT

5. Add a cautious fstab entry

Use the UUID rather than a device name that can change with discovery order. Back up the file before editing it, then add one line matching your chosen mount point:

$ sudo cp --preserve=all /etc/fstab /etc/fstab.before-example-ext2
$ sudoedit /etc/fstab
UUID=EXAMPLE-UUID /mnt/EXAMPLE_MOUNT ext2 acl,user_xattr,errors=remount-ro 0 2

The final two fields disable dump-style backups and request a boot-time file system check with a non-root pass number. Confirm the exact convention used by your distribution before changing those fields. The entry does not create the file system or the mount directory.

Validate the file before rebooting. This is a read-only parse check, but it may report unrelated existing entries too:

$ findmnt --verify --verbose
Success, no errors or warnings detected

Then test the entry without repeating its device and type fields:

$ sudo mount /mnt/EXAMPLE_MOUNT
$ findmnt --target /mnt/EXAMPLE_MOUNT --output SOURCE,FSTYPE,OPTIONS

If the entry is wrong, unmount it, restore the backup, and validate again. Restoring the backup replaces your whole /etc/fstab, so compare it first if another administrator may have edited the file since you made the copy:

$ sudo diff -u /etc/fstab.before-example-ext2 /etc/fstab
$ sudo cp /etc/fstab.before-example-ext2 /etc/fstab
$ sudo findmnt --verify --verbose

6. Handle damaged-superblock advice carefully

The sb=NUMBER option selects an alternate superblock and is intended for recovery when the primary is damaged. Do not guess the number. The manual says that backup locations depend on block size, blocks per group and features such as sparse_super; it recommends using mke2fs -n with arguments consistent with the existing layout to print candidates.

Recovery is a separate, high-risk operation. Unmount the file system first, preserve an image or backup where possible, and use the installed e2fsck documentation for the repair workflow. Mounting with a guessed backup superblock can expose inconsistent metadata and can make later diagnosis harder. If the primary superblock is damaged, stop ordinary writes and involve whoever owns the backup and recovery decision.

Done means

  • The UUID and on-disk type were checked before editing configuration.
  • Superblock defaults were read with tune2fs -l rather than guessed.
  • The option list contains only settings required by the workload.
  • A controlled mount was checked with findmnt and can be undone with umount.
  • The fstab entry uses the correct UUID, passes findmnt --verify, and has a tested recovery copy.
  • No alternate superblock or repair command was used without a recovery plan.