e2fsprogs
repository·master·Indexed 19 days ago
https://github.com/tytso/e2fsprogsA suite of filesystem management programs for extended filesystems (ext2, ext3, ext4). Includes resize2fs for expanding or shrinking filesystems, the uuidd daemon for UUID generation, and ext2ed, a terminal-based ncurses editor used to selectively corrupt or modify filesystems for test case generation.
What's inside tytso-e2fsprogs
- e2fsprogs is a suite of filesystem management programs for the extended filesystem (ext2, ext3, ext4). It provides utilities for creating, managing, and checking filesystems to ensure they are robust and error-free.
How command dispatching and overriding works in ext2ed
masterThe
ext2ededitor uses a hierarchical command dispatch system. When you enter a command, thedispatch()function searches for a matching handler using a specific priority order. This allows the editor to provide context-sensitive commands that override general ones.Dispatch Priority (Highest to Lowest):
- Type-specific commands: Commands associated with the
current_type(the specific filesystem object currently being inspected, e.g., an inode or a block group). These always take precedence. - Ext2-specific commands: Commands available when an ext2 filesystem is actively being edited.
- General commands: Commands that are always available regardless of the current context.
If a command is found in a higher-priority tier, the lower-tier command with the same name is ignored. If no match is found in any tier, an
Error: Unknown commandmessage is displayed.- Type-specific commands: Commands associated with the
Run ext2ed with write privileges and a specific device
masterYou can launch the
ext2ededitor and immediately target a specific filesystem device. If you provide the-wflag, the editor will enable write privileges (callingenable_write) upon startup. If a device path is provided as a positional argument, the editor will automatically execute theset_devicecommand for that path.Command Syntax:
# Open a device in read-only mode ext2ed /dev/sdb1 # Open a device with write privileges enabled ext2ed -w /dev/sdb1ext2ed -w /dev/sdb1Regenerate lib/ext2fs/utf8data.h using Unicode Character Database (UCD) files
masterThe files in
util/ucd/are part of the Unicode Character Database (UCD) for Unicode version 11.0.0. These files are not distributed with the fulle2fsprogspackage because of their size. They are only required when performing a Unicode version update to regenerate thelib/ext2fs/utf8data.hheader file.To regenerate the header, you must obtain the full set of UCD files from the official Unicode website or the Linux kernel source tree and place them in the appropriate directory. The files in this repository are renamed with a suffix indicating the Unicode version (e.g.,
UnicodeData-11.0.0.txt).Configure ext2ed for ncurses
masterext2ed relies on the
ncurseslibrary for terminal output. Ensure your environment is configured correctly to avoid display issues:- Old ncurses versions: If using
ncursesaround version 1.8.5, you must enable theOLD_NCURSEScompile-time option in theMakefile. For versions 1.9.2c and newer, do not use this flag. - Terminfo Database: Ensure the
ncursesterminfo database is accessible. If you see references to/etc/termcapon startup, the terminfo database is not being found correctly. - Linux Console: If running in a Linux console, set your
TERMenvironment variable tolinux. - Custom Terminfo Path: If using the precompiled binary (linked with ncurses 1.9.4) and your terminfo database is not in
/usr/local/lib/terminfo, use theTERMINFOenvironment variable to specify the correct path.
- Old ncurses versions: If using
Install ext2ed
masterTo install
ext2ed, you must have the kernel sources,readline, andncursespackages installed on your system.- Compile the program using
make. - Install the program using
make install.
Note: If you are using an older version of
ncursesor ifgcccannot locate specific header files or libraries, you may need to manually edit theMakefilebefore compiling.make make install- Compile the program using
Run and use ext2ed
masterFollow these guidelines when using
ext2ed:- Configuration: Edit
/var/lib/ext2ed/ext2ed.confto configure the tool before running it. Options includeAllowMountedReadandForceExt2. - Opening a Filesystem: Use the
setdevicecommand to open a specific ext2 filesystem. - Write Access: Filesystems are opened in read-only mode by default. Use the
enablewritecommand to enable write access. Use caution when performing write operations. - Mounted Filesystems: Do not use
ext2edto change a mounted filesystem. While you can useAllowMountedRead onin the configuration to view a mounted filesystem in read-only mode, the displayed data may be unreliable.
Critical Limitations:
ext2edcannot handle filesystems larger than 2 GB.- It assumes an Intel (little-endian) byte order.
# Example: Opening a device within the ext2ed interface setdevice /dev/hda1- Configuration: Edit
Build and install e2fsprogs
masterTo build and install e2fsprogs from source, refer to theINSTALLfile included in the repository. The project provides specific provisions for building Red Hat RPMs and Debian dpkg packages.ext2ed configuration options
masterThe following configuration options are available in
/var/lib/ext2ed/ext2ed.conf:AllowMountedRead <on|off>: Allows the tool to open a filesystem that is currently mounted in read-only mode. Note that data displayed may be unreliable.ForceExt2 <on|off>: Forcesext2edto treat the device as an ext2 filesystem if autodetect fails.
Reference the uuidd daemon paths and files
masterWhen configuring or troubleshooting the
uuidddaemon, the following file paths are used by the init script:- Daemon Executable:
/usr/sbin/uuidd - PID File:
/var/run/uuidd/uuidd.pid
- Daemon Executable:
Reference: ext2ed Global Configuration Variables
masterThe following global variables control the behavior of the
ext2ededitor. These are typically initialized byinit.cbased on a user configuration file but have logical defaults:Variable Default Value Description Ext2Descriptors"ext2.descriptors"Location of the ext2 filesystem object definition AlternateDescriptors""Path to additional user-defined structures LogFile"ext2ed.log"Location where each write operation is logged LogChanges1Enables ( 1) or disables (0) loggingAllowChanges0If set ( 1), theenable_writecommand will failAllowMountedRead0Behavior when opening a mounted filesystem read-only ForceExt20Overrides ext2 autodetection if set DefaultBlockSize1024Default block size used if filesystem detection fails DefaultTotalBlocks2097151Default total blocks used if filesystem detection fails DefaultBlocksInGroup8192Default blocks per group used if filesystem detection fails ForceDefault0Forces use of default values if detection fails Reference: resize2fs command syntax
masterThe standard command-line syntax for
resize2fsis:resize2fs [-d debug_flags] [-f] [-F] [-M] [-P] [-p] [-s| -b] [-S RAID-stride] [-z undo_file] device [new_size]