### Install .NET Runtime on Fedora Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Installs the .NET 8.0 runtime for framework-dependent UFS2Tool builds on Fedora. ```bash sudo dnf install dotnet-runtime-8.0 ``` -------------------------------- ### Install Required Packages on openSUSE Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Installs the native libraries necessary for the UFS2Tool GUI on openSUSE. ```bash sudo zypper install libX11-6 libICE6 libSM6 fontconfig ``` -------------------------------- ### Install .NET Runtime on Arch Linux Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Installs the .NET 8.0 runtime for framework-dependent UFS2Tool builds on Arch Linux. ```bash sudo pacman -Syu dotnet-runtime-8.0 ``` -------------------------------- ### Install .NET Runtime (Framework-Dependent) Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Installs the .NET 8.0 runtime for framework-dependent UFS2Tool builds on Ubuntu/Debian using Microsoft's script or package manager. ```bash # Ubuntu/Debian (using Microsoft packages) wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh chmod +x dotnet-install.sh ./dotnet-install.sh --channel 8.0 --runtime dotnet # Or install via your package manager (Ubuntu 22.04+) sudo apt install dotnet-runtime-8.0 ``` -------------------------------- ### Run UFS2Tool CLI Commands Source: https://github.com/svengdk/ufs2tool/blob/main/macOS.md Examples of common UFS2Tool command-line interface commands for creating filesystems, inspecting images, and listing directory contents. ```bash # Show help or create a filesystem ./UFS2Tool newfs myimage.img 256 # Inspect an existing image ./UFS2Tool info myimage.img # List directory contents ./UFS2Tool ls myimage.img ``` -------------------------------- ### PS5 Quick Create - UFS2 Image Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Creates a UFS2 image compatible for mounting on PS5 with ShadowMount. This command is designed for quick setup. ```powershell UFS2Tool.exe newfs -D ``` -------------------------------- ### Install Required Packages on Fedora/RHEL Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Installs the native libraries necessary for the UFS2Tool GUI on Fedora and RHEL-based systems. ```bash sudo dnf install libX11 libICE libSM fontconfig ``` -------------------------------- ### Install .NET 8.0 Runtime on macOS Source: https://github.com/svengdk/ufs2tool/blob/main/macOS.md Install the .NET 8.0 runtime using Homebrew or a provided script if you are using a framework-dependent build of UFS2Tool. This step is not needed for self-contained builds. ```bash brew install dotnet@8 ``` ```bash curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 8.0 --runtime dotnet ``` -------------------------------- ### Install Required Packages on Arch Linux Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Installs the native libraries necessary for the UFS2Tool GUI on Arch Linux. ```bash sudo pacman -Syu libx11 libice libsm fontconfig ``` -------------------------------- ### Install Required Packages on Ubuntu/Debian Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Installs the native libraries necessary for the UFS2Tool GUI on Ubuntu and Debian-based systems. ```bash sudo apt update sudo apt install libx11-6 libice6 libsm6 libfontconfig1 ``` -------------------------------- ### Run UFS2Tool Tests Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Executes the comprehensive xUnit test suite for UFS2Tool. Ensure you have the .NET 8.0 SDK or later installed. ```bash dotnet test ``` -------------------------------- ### Install Font Packages on Fedora Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Installs font configuration and a default font package to resolve font-related errors in the GUI. ```bash sudo dnf install fontconfig dejavu-sans-fonts ``` -------------------------------- ### Install Font Packages on Arch Linux Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Installs font configuration and a default font package to resolve font-related errors in the GUI. ```bash sudo pacman -Syu fontconfig ttf-dejavu ``` -------------------------------- ### Install Font Packages on Ubuntu/Debian Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Installs missing font libraries and a default font package to resolve font-related errors in the GUI. ```bash sudo apt install libfontconfig1 fonts-dejavu-core ``` -------------------------------- ### Find Files by Prefix Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Searches a UFS filesystem image for regular files whose names start with 'game'. ```bash ufs2tool find myimage.img "game*" -type f ``` -------------------------------- ### Set DOTNET_ROOT and PATH Environment Variables Source: https://github.com/svengdk/ufs2tool/blob/main/macOS.md Configure the DOTNET_ROOT and PATH environment variables if the .NET runtime is installed in a non-standard location. This ensures that the system can locate the .NET executables. ```bash export DOTNET_ROOT=$HOME/.dotnet export PATH=$PATH:$DOTNET_ROOT ``` -------------------------------- ### Force X11 for GUI on Wayland Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md If the Avalonia GUI application fails to start on Wayland, try forcing it to use X11 by setting the AVALONIA_SCREEN_SCALE_FACTORS environment variable to an empty string before launching. ```bash AVALONIA_SCREEN_SCALE_FACTORS="" ./UFS2Tool.GUI ``` -------------------------------- ### Build UFS2Tool CLI and GUI Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Use this command to build the entire solution, including the CLI, GUI, and tests. Requires .NET 8.0 SDK or later. ```bash dotnet build UFS2-Tool.sln ``` -------------------------------- ### Run UFS2Tool GUI Application Source: https://github.com/svengdk/ufs2tool/blob/main/macOS.md Launch the UFS2Tool graphical user interface by executing the UFS2Tool.GUI binary. ```bash ./UFS2Tool.GUI ``` -------------------------------- ### Create UFS2 Filesystem Image with Default Settings Source: https://context7.com/svengdk/ufs2tool/llms.txt Use this command to create a UFS2 filesystem image with default block and fragment sizes. Specify the image file name and desired size in MB. ```bash ufs2tool newfs myimage.img 256 ``` -------------------------------- ### Show Filesystem Information with info Source: https://github.com/svengdk/ufs2tool/blob/main/README.md The `info` command displays detailed information about a given UFS filesystem image. Provide the path to the image file as an argument. ```bash ufs2tool info ``` -------------------------------- ### makefs Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Creates a filesystem image from a directory tree, compatible with FreeBSD's makefs. ```APIDOC ## makefs — Create filesystem image from directory tree ### Usage ``` ufs2tool makefs [-DxZ] [-B endian] [-b free-blocks] [-f free-files] [-M minimum-size] [-m maximum-size] [-o fs-options] [-S sector-size] [-s image-size] [-T timestamp] [-t fs-type] image-file directory ``` ### Description This command creates a filesystem image from a directory tree. It is compatible with FreeBSD's `makefs(8)` and does not require special devices or privileges. It supports various options for customizing the filesystem, including FFS-specific options. ### Options - `-D`: Enable debugging output. - `-x`: Enable extended attributes. - `-Z`: Zero out the image before creating the filesystem. - `-B endian`: Specify the endianness of the filesystem (`big` or `little`). - `-b free-blocks`: Number of free blocks to reserve. - `-f free-files`: Number of free files to reserve. - `-M minimum-size`: Minimum size of the filesystem image. - `-m maximum-size`: Maximum size of the filesystem image. - `-o fs-options`: FFS-specific options in the format `key=value,...`. - `-S sector-size`: Sector size in bytes. - `-s image-size`: Size of the filesystem image. - `-T timestamp`: Set the filesystem timestamp. - `-t fs-type`: Type of filesystem to create (e.g., `ufs`). ### FFS-specific Options (used with `-o`) - `version`: UFS version: `1` for FFS, `2` for UFS2. Default: `1`. - `bsize`: Block size. Default: `32768`. - `fsize`: Fragment size. Default: `4096`. - `label`: Volume label (max 32 chars). - `softupdates`: `0` for disable, `1` for enable. Default: `0`. - `density`: Bytes per inode. Default: `auto`. - `minfree`: Minimum % free. Default: `8`. - `optimization`: `time` or `space`. Default: `time`. - `avgfilesize`: Expected average file size. Default: `16384`. - `avgfpdir`: Expected files per directory. Default: `64`. - `maxbpg`: Maximum blocks per file in CG. Default: `auto`. - `extent`: Maximum extent size. Default: `auto`. - `maxbpcg`: Maximum total blocks in CG. Default: `auto`. ### Size Suffixes `b` (×512), `k` (×1024), `m` (×1M), `g` (×1G), `t` (×1T), `w` (×4). Products with `x`: e.g., `512x1024` = 524288. ### Arguments - `image-file`: The name of the output filesystem image file. - `directory`: The source directory tree to create the filesystem from. ``` -------------------------------- ### Run UFS2Tool CLI Command Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Executes the UFS2Tool CLI, demonstrated here with the 'newfs' command to create a filesystem image. Requires .NET 8.0 SDK or later. ```bash dotnet run -- newfs myimage.img 256 ``` -------------------------------- ### PS5 Quick Create - FreeBSD-compatible FFS Image Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Creates a UFS2 image with FreeBSD-compatible FFS options for PS5 mounting with ShadowMount. This command uses specific FFS options for compatibility. ```powershell UFS2Tool.exe makefs -S 4096 -t ffs -o version=2,minfree=0,softupdates=0,optimization=space ``` -------------------------------- ### Show Device Information Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Displays information about a specified device path. ```bash ufs2tool devinfo ``` -------------------------------- ### Create New UFS1/UFS2 Filesystem with newfs Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Use the `newfs` command to create a new UFS1 or UFS2 filesystem. It supports numerous options for configuring block size, fragment size, volume label, optimization, and more. The `-E` flag erases the device before creation, and `-N` performs a dry run. ```bash ufs2tool newfs [-EJNUjlnt] [-D input-directory] [-L volname] [-O format] [-S sector-size] [-a maxcontig] [-b block-size] [-c blocks-per-cg] [-d max-extent-size] [-e maxbpg] [-f frag-size] [-g avgfilesize] [-h avgfpdir] [-i bytes-per-inode] [-m free-space%] [-o optimization] [-p partition] [-s size] [size-MB] [volume-name] ``` -------------------------------- ### Search for files by name pattern in a filesystem image Source: https://github.com/svengdk/ufs2tool/blob/main/IMPLEMENTATIONS.md Recursively searches for files and directories matching a glob-style name pattern in a UFS1/UFS2 filesystem image. Supports type filtering and starting path. ```bash ufs2tool find myimage.img "*.txt" ``` ```bash ufs2tool find myimage.img "game*" -type f ``` ```bash ufs2tool find myimage.img "*" -type d ``` ```bash ufs2tool find myimage.img "*.cfg" -path /etc ``` -------------------------------- ### Create UFS2 Filesystem Images Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Creates UFS2 filesystem images with various configurations. Supports default settings, custom block/fragment sizes, soft updates, journaling, TRIM, auto-sizing from directories, and dry runs. ```bash # Create a 256 MB UFS2 image with default settings ufs2tool newfs myimage.img 256 ``` ```bash # Create a UFS1 image with custom block/fragment sizes ufs2tool newfs -O 1 -b 16384 -f 2048 myimage.img 128 ``` ```bash # Create with soft updates, journaling, and TRIM enabled ufs2tool newfs -Ujt -L MYVOLUME myimage.img 512 ``` ```bash # Auto-sized image from directory contents ufs2tool newfs -D /path/to/my/files output.img ``` ```bash # With explicit options and directory population ufs2tool newfs -O 1 -D /path/to/my/files output.img MyVolume ``` ```bash # Dry run — show what would be created without writing ufs2tool newfs -N myimage.img 256 ``` -------------------------------- ### Create Basic UFS1 Image from Directory Source: https://context7.com/svengdk/ufs2tool/llms.txt Create a UFS1 filesystem image from a directory tree using FreeBSD's default makefs settings. This command is compatible with FreeBSD's makefs(8) interface. ```bash ufs2tool makefs output.img /path/to/my/files ``` -------------------------------- ### Get file information using stat Source: https://context7.com/svengdk/ufs2tool/llms.txt The 'stat' command displays detailed metadata for files, directories, or symlinks, similar to Unix stat(1). It shows inode details, permissions, timestamps, and block usage. ```bash ufs2tool stat myimage.img /path/to/file.txt ``` -------------------------------- ### Create UFS1 Image with Custom Settings and Volume Label Source: https://context7.com/svengdk/ufs2tool/llms.txt Create a UFS1 filesystem image with specific block and fragment sizes, and assign a custom volume label. Use the -O flag for UFS1, -b for block size, -f for fragment size, and -L for the label. ```bash ufs2tool newfs -O 1 -b 16384 -f 2048 -L MYVOLUME myimage.img 128 ``` -------------------------------- ### Build UFS2Tool CLI Only Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Builds only the command-line interface project. Use this if you only need the CLI functionality. ```bash dotnet build UFS2Tool.csproj ``` -------------------------------- ### Create macOS .app Bundle Structure Source: https://github.com/svengdk/ufs2tool/blob/main/macOS.md Commands to create the necessary directory structure for a macOS .app bundle and copy the UFS2Tool files into it for a more native application experience. ```bash # Create the .app bundle structure mkdir -p ~/Applications/UFS2Tool.app/Contents/MacOS mkdir -p ~/Applications/UFS2Tool.app/Contents/Resources # Copy the published files into the bundle cp -R ~/UFS2Tool/* ~/Applications/UFS2Tool.app/Contents/MacOS/ ``` -------------------------------- ### Create UFS2 Image with Soft Updates, Journaling, and TRIM Source: https://context7.com/svengdk/ufs2tool/llms.txt Enable advanced features like soft updates, journaling, and TRIM support for enhanced data integrity and performance. Use -Ujt for soft updates, journaling, and TRIM, -m for minimum free space, and -o for optimization. ```bash ufs2tool newfs -Ujt -m 5 -o space myimage.img 512 ``` -------------------------------- ### Set DISPLAY for XWayland Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Alternatively, if you are using XWayland, you can try setting the DISPLAY environment variable to ':0' before launching the GUI application. ```bash export DISPLAY=:0 ./UFS2Tool.GUI ``` -------------------------------- ### Create Filesystem Image from Directory with makefs Source: https://github.com/svengdk/ufs2tool/blob/main/README.md The `makefs` command creates a filesystem image from a directory tree, compatible with FreeBSD's `makefs(8)`. It offers options for specifying filesystem type, size, and various FFS-specific parameters like block size, fragment size, and optimization. ```bash ufs2tool makefs [-DxZ] [-B endian] [-b free-blocks] [-f free-files] [-M minimum-size] [-m maximum-size] [-o fs-options] [-S sector-size] [-s image-size] [-T timestamp] [-t fs-type] image-file directory ``` -------------------------------- ### Write to a Windows Physical Device Source: https://context7.com/svengdk/ufs2tool/llms.txt Create a UFS filesystem directly on a Windows physical drive or partition. This requires Administrator privileges. Use the device path (e.g., \\.\PhysicalDrive2 or \\.\E:). ```bash # ufs2tool newfs \\.\PhysicalDrive2 # ufs2tool newfs -O 1 -b 16384 -f 2048 \\.\E: ``` -------------------------------- ### Create PS5-compatible Image (ShadowMount Format) Source: https://context7.com/svengdk/ufs2tool/llms.txt Generate a PS5-compatible image in ShadowMount format. Specify the sector size with -S, use FFS type with -t ffs, and set FFS options like minfree, softupdates, and optimization via -o. ```bash ufs2tool makefs -S 4096 -t ffs -o version=2,minfree=0,softupdates=0,optimization=space PPSAxxxx.ffpkg /folder ``` -------------------------------- ### Create FreeBSD-compatible Images with makefs Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Creates UFS filesystem images using FreeBSD-compatible makefs syntax. Supports various options including filesystem type, version, block size, label, size constraints, and soft updates. ```bash # Create distribution image (soft updates disabled by default) ufs2tool makefs output.img /path/to/my/files ``` ```bash # Create UFS2 image with makefs (FreeBSD-compatible syntax) ufs2tool makefs -t ffs -o version=2 output.img /path/to/my/files ``` ```bash # makefs with label and custom block size ufs2tool makefs -o version=2,bsize=32768,label=MYVOLUME output.img /path/to/my/files ``` ```bash # makefs with size constraints ufs2tool makefs -s 256m output.img /path/to/my/files ufs2tool makefs -b 10% -f 10% output.img /path/to/my/files ``` ```bash # makefs with soft updates explicitly enabled ufs2tool makefs -o softupdates=1,version=2 output.img /path/to/my/files ``` -------------------------------- ### Create Fixed Size Image with Slack Space Source: https://context7.com/svengdk/ufs2tool/llms.txt Create a filesystem image with a fixed size and specify the percentage of free blocks and file slack. Use the -s flag for fixed size and -b/-f for block/file slack percentages. ```bash ufs2tool makefs -s 256m output.img /path/to/my/files ufs2tool makefs -b 10% -f 10% output.img /path/to/my/files ``` -------------------------------- ### Create UFS2 Image with Custom Options and Soft Updates Source: https://context7.com/svengdk/ufs2tool/llms.txt Create a UFS2 image with a custom volume label, block/fragment sizes, and soft updates enabled. Use the -o flag to specify multiple FFS options like version, bsize, fsize, label, and softupdates. ```bash ufs2tool makefs -o version=2,bsize=32768,fsize=4096,label=MYVOLUME,softupdates=1 output.img /path/to/files ``` -------------------------------- ### Build UFS2Tool GUI Application Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Builds the UFS2Tool GUI application using the .NET build command. This command compiles the GUI project located in the UFS2Tool.GUI directory. ```bash dotnet build UFS2Tool.GUI/UFS2Tool.GUI.csproj ``` -------------------------------- ### Mount UFS Image Read-Write Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Mounts a UFS filesystem image as a Windows drive in read-write mode using the Dokan driver, allowing modifications. ```bash ufs2tool mount_udf -o rw myimage.img X: ``` -------------------------------- ### Enable TRIM Support on Filesystem Source: https://context7.com/svengdk/ufs2tool/llms.txt Enable TRIM support for the filesystem image, which can improve performance on SSDs. Use the -t enable flag. ```bash ufs2tool tunefs -t enable myimage.img ``` -------------------------------- ### Populate UFS1 Image from Directory with Volume Name Source: https://context7.com/svengdk/ufs2tool/llms.txt Create a UFS1 image populated from a directory and assign a specific volume name. Combine the -O 1 flag for UFS1, -D for directory population, and -L for the volume label. ```bash ufs2tool newfs -O 1 -D /path/to/my/files output.img MyVolume ``` -------------------------------- ### Create UFS2 Image with FreeBSD-compatible FFS Options Source: https://context7.com/svengdk/ufs2tool/llms.txt Generate a UFS2 filesystem image using FFS-specific options compatible with FreeBSD. Use the -t ffs flag and specify options like 'version=2' via the -o flag. ```bash ufs2tool makefs -t ffs -o version=2 output.img /path/to/my/files ``` -------------------------------- ### Show Info for Subdirectory Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Displays detailed inode information for a specific subdirectory within a UFS filesystem image. ```bash ufs2tool stat myimage.img /path/to/dir ``` -------------------------------- ### Run UFS2Tool GUI Application Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Runs the UFS2Tool GUI application using the .NET run command. This command executes the GUI project. ```bash dotnet run --project UFS2Tool.GUI/UFS2Tool.GUI.csproj ``` -------------------------------- ### Create Info.plist for UFS2Tool Application Source: https://github.com/svengdk/ufs2tool/blob/main/macOS.md This XML configuration file is essential for macOS applications, defining metadata like bundle name, identifier, version, and system requirements. Ensure NSHighResolutionCapable is true for proper Retina display support. ```xml CFBundleName UFS2Tool CFBundleDisplayName UFS2Tool GUI CFBundleIdentifier com.svengdk.ufs2tool CFBundleVersion 2.5.0 CFBundleShortVersionString 2.5.0 CFBundleExecutable UFS2Tool.GUI CFBundleIconFile AppIcon CFBundlePackageType APPL NSHighResolutionCapable LSMinimumSystemVersion 10.14 ``` -------------------------------- ### Ufs2ImageCreator — Library API: filesystem creation Source: https://context7.com/svengdk/ufs2tool/llms.txt The `Ufs2ImageCreator` class is the programmatic entry point for creating UFS images. Configure properties to match desired `newfs` flags, then call `CreateImage`, `CreateOnDevice`, `CreateImageFromDirectory`, or `MakeFsImage`. The `Output` and `ErrorOutput` properties redirect log messages for GUI embedding. ```APIDOC ## `Ufs2ImageCreator` — Library API: filesystem creation The `Ufs2ImageCreator` class is the programmatic entry point for creating UFS images. Configure properties to match desired `newfs` flags, then call `CreateImage`, `CreateOnDevice`, `CreateImageFromDirectory`, or `MakeFsImage`. The `Output` and `ErrorOutput` properties redirect log messages for GUI embedding. ```csharp using UFS2Tool; // Create a 256 MB UFS2 image with soft updates and TRIM var creator = new Ufs2ImageCreator { FilesystemFormat = 2, // UFS2 (default) BlockSize = 32768, // -b 32768 FragmentSize = 4096, // -f 4096 VolumeName = "MYVOLUME", // -L MYVOLUME SoftUpdates = true, // -U TrimEnabled = true, // -t MinFreePercent = 8, // -m 8 OptimizationPreference = "time"// -o time }; creator.CreateImage("myimage.img", 256L * 1024 * 1024); // Auto-sized image populated from a directory (-D equivalent) var creator2 = new Ufs2ImageCreator { VolumeName = "DATA" }; long finalSize = creator2.CreateImageFromDirectory("data.img", "/path/to/dir"); Console.WriteLine($"Created {finalSize / (1024 * 1024)} MB image"); // makefs-compatible creation with custom density and size constraints var creator3 = new Ufs2ImageCreator { FilesystemFormat = 1, // version=1 (UFS1, makefs default) BytesPerInode = 8192, // -o density=8192 MinFreePercent = 0, // -o minfree=0 }; creator3.MakeFsImage("output.img", "/source/dir", minimumSize: 64 * 1024 * 1024, maximumSize: 512 * 1024 * 1024, freeblockpc: 10, // -b 10% freefilepc: 10); // -f 10% ``` ``` -------------------------------- ### add Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Add a file or directory to a UFS1/UFS2 filesystem image. If source-path is a file, it is added at fs-path. If source-path is a directory, it is created at fs-path and its contents are added recursively. ```APIDOC ## add ### Description Add a file or directory to a UFS1/UFS2 filesystem image. If `source-path` is a file, it is added at `fs-path`. If `source-path` is a directory, it is created at `fs-path` and its contents are added recursively. ### Method `ufs2tool add ` ### Parameters #### Path Parameters - **image-path** (string) - Required - Path to the UFS image file. - **fs-path** (string) - Required - The destination path within the filesystem image. - **source-path** (string) - Required - The path to the local file or directory to add. ### Request Example ```bash # Add a single file ufs2tool add myimage.img /newfile.txt ./local/file.txt # Add a file into a subdirectory ufs2tool add myimage.img /subdir/newfile.txt ./local/file.txt # Add a directory recursively ufs2tool add myimage.img /newdir ./local/dir ``` ``` -------------------------------- ### Show Summary Disk Usage Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Displays only the total disk usage for the specified path in a UFS filesystem image. ```bash ufs2tool du -s myimage.img ``` -------------------------------- ### Create UFS2 Image with Custom Settings Source: https://context7.com/svengdk/ufs2tool/llms.txt Programmatically creates a UFS2 filesystem image with configurable parameters such as block size, fragment size, volume name, soft updates, and TRIM support. The `CreateImage` method generates a file-based image. ```csharp using UFS2Tool; // Create a 256 MB UFS2 image with soft updates and TRIM var creator = new Ufs2ImageCreator { FilesystemFormat = 2, // UFS2 (default) BlockSize = 32768, // -b 32768 FragmentSize = 4096, // -f 4096 VolumeName = "MYVOLUME", // -L MYVOLUME SoftUpdates = true, // -U TrimEnabled = true, // -t MinFreePercent = 8, // -m 8 OptimizationPreference = "time"// -o time }; creator.CreateImage("myimage.img", 256L * 1024 * 1024); ``` -------------------------------- ### Add Files with add Source: https://context7.com/svengdk/ufs2tool/llms.txt Adds a file or directory from the local filesystem into a UFS1/UFS2 image. This involves allocating inodes and data blocks, writing directory entries with boundary handling, and updating filesystem metadata. ```bash ``` -------------------------------- ### Show Disk Usage for Entire Filesystem Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Displays disk usage for all files and directories in a UFS filesystem image. ```bash ufs2tool du myimage.img ``` -------------------------------- ### Show Info for Root Directory Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Displays detailed inode information for the root directory of a UFS filesystem image. ```bash ufs2tool stat myimage.img / ``` -------------------------------- ### Show Disk Usage with Human-Readable Sizes Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Displays disk usage for a UFS filesystem image with sizes formatted in a human-readable way (e.g., KB, MB, GB). ```bash ufs2tool du -h myimage.img ``` -------------------------------- ### Create UFS Image from Directory Source: https://context7.com/svengdk/ufs2tool/llms.txt Creates a UFS image file populated with the contents of a specified directory. The image size is automatically determined based on the directory content. This is equivalent to the `-D` flag in `newfs`. ```csharp // Auto-sized image populated from a directory (-D equivalent) var creator2 = new Ufs2ImageCreator { VolumeName = "DATA" }; long finalSize = creator2.CreateImageFromDirectory("data.img", "/path/to/dir"); Console.WriteLine($"Created {finalSize / (1024 * 1024)} MB image"); ``` -------------------------------- ### Tune UFS Filesystem Parameters Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Modify layout parameters on an existing UFS1/UFS2 filesystem image. Use -p to print current values without modification. ```bash ufs2tool tunefs [-Ap] [-a enable|disable] [-e maxbpg] [-f avgfilesize] [-J enable|disable] [-j enable|disable] [-k metaspace] [-L volname] [-l enable|disable] [-m minfree] [-N enable|disable] [-n enable|disable] [-o space|time] [-s avgfpdir] [-t enable|disable] ``` ```bash # Print current tuneable values ufs2tool tunefs -p myimage.img ``` ```bash # Enable soft updates journaling ufs2tool tunefs -j enable myimage.img ``` ```bash # Set volume label and minfree ufs2tool tunefs -L MYVOLUME -m 5 myimage.img ``` ```bash # Write updated superblock to all backup locations ufs2tool tunefs -A -n enable myimage.img ``` -------------------------------- ### newfs Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Creates a new UFS1 or UFS2 filesystem on a target device or image. ```APIDOC ## newfs — Create a new UFS1/UFS2 filesystem ### Usage ``` ufs2tool newfs [-EJNUjlnt] [-D input-directory] [-L volname] [-O format] [-S sector-size] [-a maxcontig] [-b block-size] [-c blocks-per-cg] [-d max-extent-size] [-e maxbpg] [-f frag-size] [-g avgfilesize] [-h avgfpdir] [-i bytes-per-inode] [-m free-space%] [-o optimization] [-p partition] [-s size] [size-MB] [volume-name] ``` ### Description This command creates a new UFS1 or UFS2 filesystem. It supports various options to customize the filesystem parameters, including size, block size, and optimization strategy. It can also populate the filesystem with contents from an input directory. ### Options #### Boolean Flags - `-E`: Erase (zero) device before creating filesystem. - `-J`: Enable gjournal provider. - `-N`: Dry run — display parameters without creating filesystem. - `-U`: Enable soft updates. - `-j`: Enable soft updates journaling (implies `-U`). - `-l`: Enable multilabel MAC support. - `-n`: Do not create `.snap` directory. - `-t`: Enable TRIM/DISCARD flag in superblock. #### Options with Values - `-D directory`: Input directory — populate image with directory contents. Size auto-calculated as `dir_size × 1.2 + 10 MB`. All files including hidden files are copied. - `-L volname`: Volume label (max 32 chars). - `-O format`: Filesystem format: `1` (UFS1) or `2` (UFS2). Default: `2`. - `-S sector-size`: Sector size in bytes. Default: `512`. - `-a maxcontig`: Max contiguous blocks. Default: `auto`. - `-b block-size`: Block size (4096–65536, power of 2). Default: `32768`. - `-c blocks-per-cg`: Blocks per cylinder group. Default: `auto`. - `-d max-extent`: Maximum extent size. Default: `auto`. - `-e maxbpg`: Max blocks per file in a cylinder group. Default: `auto`. - `-f frag-size`: Fragment size (≥512, power of 2). Default: `4096`. - `-g avgfilesize`: Expected average file size. Default: `16384`. - `-h avgfpdir`: Expected average files per directory. Default: `64`. - `-i bytes/inode`: Inode density (bytes per inode). Default: `auto`. - `-m free-space`: Minimum free space percentage. Default: `8`. - `-o optimization`: `time` or `space`. Default: `time`. - `-p partition`: Partition label (informational). - `-s size`: Filesystem size in 512-byte sectors. Default: `auto`. ### Arguments - ``: The device or image file to create the filesystem on. - `[size-MB]`: Optional size in megabytes. - `[volume-name]`: Optional volume name. ``` -------------------------------- ### Create UFS Image with makefs Compatibility Source: https://context7.com/svengdk/ufs2tool/llms.txt Generates a UFS image compatible with `makefs` by specifying parameters like bytes per inode and minimum free space. This method allows for fine-grained control over filesystem density and size constraints. ```csharp // makefs-compatible creation with custom density and size constraints var creator3 = new Ufs2ImageCreator { FilesystemFormat = 1, // version=1 (UFS1, makefs default) BytesPerInode = 8192, // -o density=8192 MinFreePercent = 0, // -o minfree=0 }; creator3.MakeFsImage("output.img", "/source/dir", minimumSize: 64 * 1024 * 1024, maximumSize: 512 * 1024 * 1024, freeblockpc: 10, // -b 10% freefilepc: 10); # -f 10% ``` -------------------------------- ### List UFS Filesystem Contents Source: https://github.com/svengdk/ufs2tool/blob/main/README.md List directory contents of a UFS1/UFS2 filesystem image. ```bash ufs2tool ls [path] ``` -------------------------------- ### growfs — Expand an existing filesystem Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Expand an existing UFS1/UFS2 filesystem image. Equivalent to FreeBSD's `growfs(8)`. ```APIDOC ## growfs ### Description Expand an existing UFS1/UFS2 filesystem image. ### Method `ufs2tool growfs` ### Parameters #### Path Parameters - **image-path** (string) - Required - Path to the filesystem image. #### Options - `-N` - Test mode — print parameters without modifying the filesystem. - `-y` - Assume yes to all prompts. - `-s size` - New filesystem size (default: image file size). Suffixes: `b` (bytes), `k` (KB), `m` (MB), `g` (GB), `t` (TB). Without suffix: 512-byte sectors. ### Request Example ```bash # Grow filesystem to fill expanded image truncate -s 512M myimage.img ufs2tool growfs -y myimage.img # Grow to specific size ufs2tool growfs -y -s 256m myimage.img # Dry-run: see what would happen ufs2tool growfs -N -s 1g myimage.img ``` ``` -------------------------------- ### Mount UFS Image as Windows Drive Source: https://github.com/svengdk/ufs2tool/blob/main/IMPLEMENTATIONS.md Mounts a UFS1/UFS2 filesystem image as a Windows drive letter using the Dokan driver. Supports read-only or read-write mounting and verbose logging. ```bash ufs2tool mount_udf -o ro myimage.img X: ``` ```bash ufs2tool mount_udf -o rw myimage.img Y: ``` ```bash ufs2tool mount_udf -v myimage.img Z: ``` -------------------------------- ### info Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Displays information about a given filesystem image. ```APIDOC ## info — Show filesystem information ### Usage ``` ufs2tool info ``` ### Description This command retrieves and displays detailed information about a UFS filesystem image specified by its path. ``` -------------------------------- ### Constrain Image Size Between Minimum and Maximum Source: https://context7.com/svengdk/ufs2tool/llms.txt Create a filesystem image with size constraints, specifying both a minimum and maximum allowable size. Use the -M flag for maximum size and -m for minimum size. ```bash ufs2tool makefs -M 128m -m 512m output.img /path/to/my/files ``` -------------------------------- ### Extract UFS2Tool Archive Source: https://github.com/svengdk/ufs2tool/blob/main/LINUX.md Creates a directory and extracts the UFS2Tool release archive. Supports both .zip and .tar.gz formats. ```bash # Create a directory for UFS2Tool mkdir -p ~/UFS2Tool # Extract the archive unzip UFS2Tool-linux-x64.zip -d ~/UFS2Tool # or for .tar.gz archives: tar -xzf UFS2Tool-linux-x64.tar.gz -C ~/UFS2Tool ``` -------------------------------- ### Set Execute Permissions for UFS2Tool Executables Source: https://github.com/svengdk/ufs2tool/blob/main/macOS.md Ensure that the UFS2Tool and UFS2Tool.GUI executables have the necessary execute permissions. This command grants execute permissions to the specified files. ```bash chmod +x UFS2Tool UFS2Tool.GUI ``` -------------------------------- ### Print Current Tuneable Values of Filesystem Image Source: https://context7.com/svengdk/ufs2tool/llms.txt Read and display the current tuneable parameters from an existing filesystem image's superblock. This operation is read-only and does not modify the image. ```bash ufs2tool tunefs -p myimage.img ``` -------------------------------- ### Recursively Set File and Directory Permissions Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Applies specified file and directory permissions recursively to the entire UFS filesystem image. ```bash ufs2tool chmod -R myimage.img 644 755 ``` -------------------------------- ### Add and Delete Files from Filesystem Images Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Manages files within UFS filesystem images. Supports adding single files or directories recursively, and deleting single files or directories recursively. ```bash # Add a single file to the filesystem ufs2tool add myimage.img /newfile.txt ./local/file.txt ``` ```bash # Add a directory recursively ufs2tool add myimage.img /newdir ./local/dir ``` ```bash # Delete a single file ufs2tool delete myimage.img /path/to/file.txt ``` ```bash # Delete a directory recursively ufs2tool delete myimage.img /path/to/dir ``` -------------------------------- ### Show detailed file information from a filesystem image Source: https://github.com/svengdk/ufs2tool/blob/main/IMPLEMENTATIONS.md Displays detailed inode information for files, directories, or symlinks in a UFS1/UFS2 filesystem image, similar to Unix stat. ```bash ufs2tool stat myimage.img / ``` ```bash ufs2tool stat myimage.img /path/to/file.txt ``` ```bash ufs2tool stat myimage.img /path/to/dir ``` -------------------------------- ### Find All Directories Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Searches a UFS filesystem image for all entries that are directories. ```bash ufs2tool find myimage.img "*" -type d ``` -------------------------------- ### Mount UFS Image Read-Only Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Mounts a UFS filesystem image as a Windows drive in read-only mode using the Dokan driver. ```bash ufs2tool mount_udf myimage.img X: ``` -------------------------------- ### tunefs — Tune existing filesystem parameters Source: https://github.com/svengdk/ufs2tool/blob/main/README.md Modify layout parameters on an existing UFS1/UFS2 filesystem image. Equivalent to FreeBSD's `tunefs(8)`. ```APIDOC ## tunefs ### Description Modify layout parameters on an existing UFS1/UFS2 filesystem image. ### Method `ufs2tool tunefs` ### Parameters #### Path Parameters - **image-path** (string) - Required - Path to the filesystem image. #### Options - `-A` - Write the updated superblock to all backup superblock locations. - `-a enable|disable` - Enable or disable POSIX.1e ACL support. - `-e maxbpg` - Set maximum blocks per file in a cylinder group. - `-f avgfilesize` - Set expected average file size. - `-J enable|disable` - Enable or disable gjournal. - `-j enable|disable` - Enable or disable soft updates journaling (enabling also enables soft updates). - `-k metaspace` - Set space (in frags) to hold for metadata blocks. - `-L volname` - Set volume label (alphanumerics, dashes, underscores; max 31 chars). - `-l enable|disable` - Enable or disable multilabel MAC support. - `-m minfree` - Set minimum percentage of free space (0–99). - `-N enable|disable` - Enable or disable NFSv4 ACL support. - `-n enable|disable` - Enable or disable soft updates. - `-o space|time` - Set optimization preference. - `-p` - Print current tuneable values and exit (read-only). - `-s avgfpdir` - Set expected number of files per directory. - `-t enable|disable` - Enable or disable TRIM/DISCARD support. ### Request Example ```bash # Print current tuneable values ufs2tool tunefs -p myimage.img # Enable soft updates journaling ufs2tool tunefs -j enable myimage.img # Set volume label and minfree ufs2tool tunefs -L MYVOLUME -m 5 myimage.img # Write updated superblock to all backup locations ufs2tool tunefs -A -n enable myimage.img ``` ``` -------------------------------- ### Extract UFS2Tool Archive on macOS Source: https://github.com/svengdk/ufs2tool/blob/main/macOS.md Use these commands to create a directory and extract the UFS2Tool archive. Choose the appropriate command based on whether you have a .zip or .tar.gz archive. ```bash mkdir -p ~/UFS2Tool unzip UFS2Tool-osx-arm64.zip -d ~/UFS2Tool # or for .tar.gz archives: tar -xzf UFS2Tool-osx-arm64.tar.gz -C ~/UFS2Tool ``` -------------------------------- ### Display Disk Usage for UFS Image Source: https://github.com/svengdk/ufs2tool/blob/main/IMPLEMENTATIONS.md Shows disk usage for files and directories within a UFS1/UFS2 filesystem image. Supports human-readable sizes, summary-only output, and depth limiting. ```bash ufs2tool du myimage.img ``` ```bash ufs2tool du -h myimage.img ``` ```bash ufs2tool du -s myimage.img ``` ```bash ufs2tool du myimage.img /subdir ``` ```bash ufs2tool du -d 1 myimage.img ``` -------------------------------- ### Add files and directories to UFS image Source: https://context7.com/svengdk/ufs2tool/llms.txt Use the 'add' command to insert files or directories into a UFS image. Specify the image file, the destination path within the image, and the local source path. ```bash ufs2tool add myimage.img /newfile.txt ./local/file.txt ``` ```bash ufs2tool add myimage.img /subdir/newfile.txt ./local/file.txt ``` ```bash ufs2tool add myimage.img /newdir ./local/dir ``` -------------------------------- ### Filesystem Consistency Check with `fsck_ufs` Source: https://github.com/svengdk/ufs2tool/blob/main/IMPLEMENTATIONS.md Performs a filesystem consistency check on UFS1/UFS2 images, similar to FreeBSD's `fsck_ffs(8)`. Supports various options for controlling the check and repair process. ```bash fsck_ufs [-b block] [-d] [-f] [-n] [-p] [-y] ``` -------------------------------- ### List Directory Contents with `ls` Source: https://github.com/svengdk/ufs2tool/blob/main/IMPLEMENTATIONS.md Lists directory entries from a UFS1/UFS2 filesystem image. Supports an optional path argument to list subdirectories and traversal through direct and indirect block pointers. ```bash ls [path] ``` -------------------------------- ### Check Filesystem Consistency with fsck_ufs Source: https://context7.com/svengdk/ufs2tool/llms.txt Performs a filesystem consistency check on UFS1/UFS2 images. Exit code 0 indicates a clean filesystem, while 8 indicates errors. Use -f to force a check, -p for preen mode (auto-fix safe issues), -n for read-only, and -b to specify an alternate superblock. ```bash # Standard check ufs2tool fsck_ufs myimage.img # Output: # ** Checking UFS2 filesystem image: myimage.img # ** Phase 1 - Check Blocks and Sizes # ** Phase 2 - Check Pathnames # ** Phase 3 - Check Connectivity # ** Phase 4 - Check Reference Counts # ** Phase 5 - Check Cylinder Groups # ** myimage.img is clean # 5 files, 1024 used, 8192 free (0.0% fragmentation) ``` ```bash # Force check even if marked clean ufs2tool fsck_ufs -f myimage.img ``` ```bash # Preen mode: auto-fix safe issues, report orphaned inodes for lost+found ufs2tool fsck_ufs -p myimage.img ``` ```bash # Read-only check (assume no to all questions) ufs2tool fsck_ufs -n myimage.img ``` ```bash # Use alternate superblock (for corrupted primary) ufs2tool fsck_ufs -b 192 myimage.img ``` ```bash # Debug output with combined flags ufs2tool fsck_ufs -df myimage.img ``` -------------------------------- ### Display Filesystem Information with info Source: https://context7.com/svengdk/ufs2tool/llms.txt Reads and displays detailed superblock metadata for UFS1/UFS2 filesystem images, including magic number, block/fragment sizes, cylinder group layout, resource counts, volume name, flags, optimization settings, and last modification time. ```bash ufs2tool info myimage.img # Output: # UFS2 Filesystem Image: myimage.img # Magic: 0x19540119 (Valid UFS2) # Block Size: 32768 bytes # Fragment Size: 4096 bytes # Cylinder Groups: 4 # Inodes Per Group: 16384 # Total Fragments: 131072 # Total Size: 512 MB # Free Blocks: 15234 # Free Inodes: 65533 # Directories: 1 # Volume Name: MYVOLUME # Min Free: 8% # Optimization: time # Flags: SOFTUPDATES # Last Modified: 2025-01-15 10:30:00Z ```