Skip to content

danko1122q/FormatUSB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FormatUSB v1.1.0

License: GPL v3 Version Build Status

FormatUSB is a modern, powerful graphical tool for formatting USB drives and removable storage devices on Linux systems. Built with Qt5/6 and C++20, it provides an intuitive, safe, and user-friendly interface for formatting USB drives with various filesystem options.

FormatUSB

Important Note: FormatUSB is a Linux desktop application that requires an X11/Wayland display server, root privileges, and physical USB hardware access. While the code can be developed and compiled in cloud environments (like Replit), the application must be run on a local Linux system with physical USB devices.


πŸ“‹ Table of Contents


✨ Features

  • 🎨 Modern GUI: Clean, contemporary design with intuitive controls
  • πŸ’Ύ Multiple Filesystem Support:
    • FAT32 - Universal compatibility (Windows/Mac/Linux/Android)
    • NTFS - Windows native with large file support
    • ext4 - Linux native with optimal performance
    • exFAT - Cross-platform with large file support
  • πŸ” Automatic Device Detection: Intelligent USB device detection with multiple methods
  • πŸ›‘οΈ Advanced Safety Features:
    • System drive protection to prevent accidental formatting
    • Removable device filtering
    • Confirmation dialogs before destructive operations
  • βš™οΈ Partition Table Options: Support for GPT, MBR/MSDOS, and automatic selection
  • 🏷️ Custom Volume Labels: Set custom names for your drives with filesystem-specific validation
  • 🌍 Internationalization: Supports 50+ languages
  • πŸ“¦ Embedded Resources: CHANGELOG and assets bundled directly in the binary
  • ⚑ Fast & Efficient: Multi-threaded device detection and formatting

πŸ–₯️ System Requirements

Supported Operating Systems

Distribution Minimum Version Status
Ubuntu 18.04 LTS βœ… Tested
Debian 9 (Stretch) βœ… Tested
Linux Mint 19 βœ… Compatible
Elementary OS 5.0 βœ… Compatible
Pop!_OS 20.04 βœ… Compatible
Fedora 30+ βœ… Compatible
Arch Linux Latest βœ… Compatible
Other Debian-based - ⚠️ Should work

Hardware Requirements

  • RAM: Minimum 512 MB (Recommended: 1 GB+)
  • Disk Space: 10 MB for application
  • Display: X11 or Wayland display server
  • USB Port: For devices to be formatted

Software Dependencies

Required:

  • Qt5 β‰₯ 5.9 or Qt6 (Core, GUI, Widgets modules)
  • C++ Compiler with C++20 support (GCC 7+, Clang 10+)
  • X11 or Wayland display server
  • Root/sudo privileges for formatting operations

System Tools:

  • parted - Partition table manipulation
  • lsblk - Block device listing
  • udevadm - Device information (optional, fallback)

Filesystem Tools (install as needed):

  • mkfs.vfat (dosfstools) - For FAT32
  • mkfs.ntfs (ntfs-3g) - For NTFS
  • mkfs.ext4 (e2fsprogs) - For ext4
  • mkfs.exfat (exfatprogs or exfat-utils) - For exFAT

πŸ“¦ Installation

Method 1: Build from Source

Step 1: Install Build Dependencies

Ubuntu/Debian/Linux Mint:

# Update package lists
sudo apt update

# Install build tools and Qt5
sudo apt install -y \
    build-essential \
    gcc \
    g++ \
    make \
    qtbase5-dev \
    qtchooser \
    qt5-qmake \
    qtbase5-dev-tools \
    pkg-config \
    git

# Install system utilities
sudo apt install -y \
    parted \
    dosfstools \
    ntfs-3g \
    e2fsprogs

# Install exFAT support (choose one)
# For modern systems (Ubuntu 20.04+, Debian 11+):
sudo apt install -y exfatprogs

# Or for older systems (Ubuntu 18.04, Debian 9-10):
sudo apt install -y exfat-fuse exfat-utils

Fedora/RHEL/CentOS:

sudo dnf install -y \
    gcc \
    gcc-c++ \
    make \
    qt5-qtbase-devel \
    git \
    parted \
    dosfstools \
    ntfs-3g \
    e2fsprogs \
    exfatprogs

Arch Linux:

sudo pacman -S --needed \
    base-devel \
    qt5-base \
    git \
    parted \
    dosfstools \
    ntfs-3g \
    e2fsprogs \
    exfatprogs

Verify Dependencies:

# Check Qt5 installation
qmake --version
# Expected: QMake version 3.x, Using Qt version 5.x

# Check compiler
g++ --version
# Expected: g++ 7.0 or newer

# Check system tools
parted --version
lsblk --version

Step 2: Clone Repository

# Clone from GitHub
git clone https://github.com/dezuuu12/FormatUSB.git

# Enter project directory
cd FormatUSB

Step 3: Build Application

# Generate Makefile with qmake
qmake src.pro

# Compile with make (use multiple cores for speed)
make -j$(nproc)

# Result: 'formatusb' executable will be created in current directory

Expected Output:

...
g++ -Wl,-O1 -o formatusb main.o mainwindow.o about.o cmd.o ...

Step 4: Verify Build

# Check executable file
ls -lh formatusb
# Expected: -rwxr-xr-x ... 160K ... formatusb

# Check version
./formatusb --version
# Expected output: Version: 1.1.0

Automatic Installation with install.sh

If you don't want to do manual installation steps, use the provided installation script:

# Make sure FormatUSB is built first
make

# Run the installer
sudo ./install.sh

This will automatically:

  • Copy the binary to /usr/local/bin
  • Copy required libraries to /usr/lib/formatusb and /usr/local/lib/formatusb
  • Install icons and desktop entry
  • Update the desktop database

⚠️ Note: You must first compile the project (make to generate formatusb) before running install.sh.

Verify Installation:

which formatusb
# Expected: /usr/local/bin/formatusb

formatusb --version
# Expected: Version: 1.1.0

πŸš€ Usage

Running the Application

From Source Directory:

# Run directly from build folder
sudo ./formatusb

If Installed System-Wide:

# Run from terminal
sudo formatusb

# Or find in application menu: System β†’ FormatUSB

Important Notes:

  • ⚠️ Application requires root privileges for formatting operations
  • If prompted for password, enter your user password
  • Use polkit/pkexec for automatic privilege escalation

Step-by-Step Formatting Guide

1️⃣ Preparation

  1. Connect the USB drive you want to format
  2. ⚠️ BACKUP ALL IMPORTANT DATA from the USB drive
  3. Launch FormatUSB application (sudo formatusb)

2️⃣ Select Target Device

  1. In the "Select Target USB Device" dropdown, choose the correct device
  2. ⚠️ CHECK CAREFULLY - ensure you select the right USB device!
  3. Tip: Check the capacity and device name to verify it's your USB drive

Additional Options:

  • β˜‘οΈ Show all devices - Display all storage devices (⚠️ DANGER! Can show internal drives)
  • β˜‘οΈ Show partitions - Display individual partitions instead of whole devices

3️⃣ Choose Filesystem Format

Format Max File Size Max Volume Size Compatibility Best Use Case
FAT32 4 GB 2 TB Windows/Mac/Linux/Android USB for small files, maximum compatibility
NTFS 16 TB 256 TB Windows/Linux (read-only on Mac) Windows USB, large files (>4GB)
ext4 16 TB 1 EB Linux only Linux-only USB, best performance
exFAT 16 EB 128 PB Modern Windows/Mac/Linux Modern cross-platform USB, large files

Recommendations:

  • πŸ’Ύ General purpose, maximum compatibility: FAT32 (if all files < 4GB)
  • πŸŽ₯ Large videos, ISOs, archives: exFAT or NTFS
  • 🐧 Linux-only usage: ext4 (best performance)
  • πŸͺŸ Windows-only usage: NTFS

4️⃣ Set Partition Table Options

  • Defaults - Let the system choose automatically (recommended for most users)
  • MBR/msdos - Compatible with old BIOS and legacy systems
  • GPT - Modern standard, recommended for drives > 2TB

5️⃣ Customize Volume Label (Optional)

  • Enter a custom name for your USB drive
  • Allowed characters vary by filesystem:
    • FAT32: A-Z, 0-9, _, - (max 11 characters)
    • NTFS: A-Z, 0-9, _, ., -, space (max 32 characters)
    • ext4: A-Z, 0-9, _, ., - (max 16 characters)
    • exFAT: A-Z, 0-9, _, ., -, space (max 15 characters)
  • Examples: MYUSB, Backup_2025, Data Drive

6️⃣ Format the Drive

  1. Click the "Next" button
  2. ⚠️ CONFIRM the operation in the warning dialog
  3. Wait for the formatting process to complete (progress shown in output log)
  4. Check the output log for any errors
  5. βœ… SUCCESS! - Safely eject the USB drive when complete

πŸ’Ύ Supported Filesystems

FAT32 (vfat)

  • Pros: Universal compatibility, works on all operating systems
  • Cons: 4 GB file size limit, 2 TB volume limit
  • Use Case: USB drives for transferring small files between different systems

NTFS

  • Pros: Large file support, native Windows filesystem, journaling
  • Cons: Limited Mac support (read-only without additional software)
  • Use Case: Windows-centric environments, large files

ext4

  • Pros: Best performance on Linux, journaling, large file support
  • Cons: Not natively supported on Windows/Mac
  • Use Case: Linux-only USB drives, backup drives

exFAT

  • Pros: Modern cross-platform support, large file support, no 4GB limit
  • Cons: Requires modern OS versions
  • Use Case: Modern cross-platform USB drives, large media files

πŸ›‘οΈ Safety Features

Data Loss Warning

  • ❌ Formatting PERMANENTLY DESTROYS all data on the selected drive
  • ❌ Deleted data CANNOT be recovered
  • βœ… Always backup important data before formatting
  • βœ… Double-check device selection before confirming

Built-in Protection Mechanisms

  1. πŸ›‘οΈ System Drive Protection - Automatically prevents formatting of system drives (root / and boot partitions)
  2. πŸ›‘οΈ Removable Device Filtering - Only shows removable/USB devices by default
  3. πŸ›‘οΈ Multiple Confirmation Dialogs - Requires explicit confirmation before destructive operations
  4. πŸ›‘οΈ Device Verification - Uses multiple methods to verify USB devices (lsblk, udevadm, /sys/block)
  5. πŸ›‘οΈ Process Monitoring - Logs all operations for debugging and verification

Best Practices

  1. βœ… Always verify device selection before formatting
  2. βœ… Backup important data before any formatting operation
  3. βœ… Test the USB drive after formatting by copying test files
  4. βœ… Never unplug the USB drive during formatting
  5. βœ… Use "Show all devices" option only when absolutely necessary
  6. βœ… Safely eject the USB drive after formatting completes

πŸ› οΈ Building and Development

Build System

  • Build Tool: qmake (Qt Meta-Object Compiler)
  • Compiler: GCC 7+ or Clang 10+ with C++20 support
  • Qt Version: Qt5 (5.9+) or Qt6

Build Commands

# Clean previous build
make clean

# Generate Makefile
qmake src.pro

# Build (parallel)
make -j$(nproc)

# Build (single-threaded for debugging)
make

# Clean everything including generated files
make distclean

Development Dependencies

# Install development tools
sudo apt install -y \
    git \
    valgrind \
    gdb \
    qtcreator \
    clang-format

Code Style

  • Follow Qt coding conventions
  • Use modern C++20 features where appropriate
  • Add comments for complex logic
  • Keep functions focused and single-purpose

πŸ”§ Troubleshooting

Problem 1: Permission Denied

Error:

Error: Permission denied
Cannot access /dev/sdb

Solution:

# Run with sudo
sudo ./formatusb

# Or if installed system-wide
sudo formatusb

Problem 2: Qt Library Not Found

Error:

error while loading shared libraries: libQt5Core.so.5

Solution:

# Install Qt5 runtime libraries
sudo apt install -y qtbase5-dev libqt5widgets5 libqt5gui5 libqt5core5a

# Or install Qt5 full
sudo apt install -y qt5-default  # For older Ubuntu/Debian

Problem 3: Device Not Detected

Symptoms: Device dropdown is empty or USB doesn't appear

Solution:

  1. Check USB Connection:

    # List all block devices
    lsblk
    
    # Check USB devices
    lsusb
    
    # Check system log for USB events
    sudo dmesg | tail -20
  2. Try Different USB Port

  3. Enable "Show all devices" (⚠️ Be careful!)

  4. Check udev rules:

    ls -l /dev/sd*

Problem 4: Formatting Fails

Error:

Error: Failed to create filesystem

Solution:

  1. Unmount device first:

    # Check mounted partitions
    mount | grep sdb
    
    # Unmount all partitions
    sudo umount /dev/sdb*
  2. Verify filesystem tools are installed:

    # Check available mkfs tools
    ls /sbin/mkfs.*
    
    # Install missing tools
    sudo apt install dosfstools ntfs-3g e2fsprogs exfatprogs
  3. Check device for errors:

    # Check device status
    sudo parted /dev/sdb print
    
    # Check for bad blocks (warning: slow!)
    sudo badblocks -v /dev/sdb

Problem 5: Build Errors

Error during compilation:

Solution:

# Clean build artifacts
make clean
rm -f Makefile moc_* ui_* qrc_*

# Regenerate Makefile
qmake src.pro

# Rebuild
make -j$(nproc)

Missing Qt headers:

# Install all Qt5 development packages
sudo apt install -y qtbase5-dev qtbase5-dev-tools qt5-qmake

Log Files

Application logs are saved to:

/tmp/formatusb.log

For debugging, monitor the log file in real-time:

tail -f /tmp/formatusb.log

πŸ—‚οΈ Project Structure

FormatUSB/
β”œβ”€β”€ src.pro                 # Qt project configuration file
β”œβ”€β”€ Makefile               # Generated by qmake (after build)
β”œβ”€β”€ formatusb              # Compiled executable (after build)
β”‚
β”œβ”€β”€ main.cpp               # Application entry point
β”œβ”€β”€ mainwindow.cpp         # Main window logic
β”œβ”€β”€ mainwindow.h           # Main window header
β”œβ”€β”€ mainwindow.ui          # Qt Designer UI file (GUI layout)
β”œβ”€β”€ about.cpp              # About dialog implementation
β”œβ”€β”€ about.h                # About dialog header
β”œβ”€β”€ cmd.cpp                # Command execution wrapper
β”œβ”€β”€ cmd.h                  # Command execution header
β”œβ”€β”€ version.h              # Version definitions (1.1.0)
β”‚
β”œβ”€β”€ images.qrc             # Qt resource file (embedded assets)
β”œβ”€β”€ CHANGELOG.txt          # Application changelog (embedded in binary)
β”œβ”€β”€ README.md              # This file - User documentation
β”œβ”€β”€ LICENSE                # GPL v3 License
β”‚
β”œβ”€β”€ lib/
β”‚   └── formatusb_lib      # Core formatting library (Bash script)
β”‚
β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ FORMAT.png         # Screenshot
β”‚   └── logo.svg           # Application logo
β”‚
β”œβ”€β”€ translations/          # Internationalization files
β”‚   β”œβ”€β”€ formatusb_en.ts    # English
β”‚   β”œβ”€β”€ formatusb_id.ts    # Indonesian
β”‚   β”œβ”€β”€ formatusb_de.ts    # German
β”‚   β”œβ”€β”€ formatusb_fr.ts    # French
β”‚   β”œβ”€β”€ formatusb_es.ts    # Spanish
β”‚   β”œβ”€β”€ formatusb_zh_CN.ts # Chinese (Simplified)
β”‚   β”œβ”€β”€ formatusb_ja.ts    # Japanese
β”‚   └── ... (50+ languages)
β”‚
β”œβ”€β”€ debian/                # Debian packaging files
β”‚   β”œβ”€β”€ changelog          # Debian changelog
β”‚   β”œβ”€β”€ control            # Package dependencies
β”‚   β”œβ”€β”€ copyright          # Copyright information
β”‚   β”œβ”€β”€ install            # Installation rules
β”‚   β”œβ”€β”€ rules              # Build rules
β”‚   └── source/
β”‚       └── format         # Source format
β”‚
└── polkit-actions/        # PolicyKit rules
    └── org.usbformat.pkexec.formatusb.policy

πŸ“ Changelog

Version 1.1.0 (October 25, 2025)

Major Update:

  • βœ… Updated copyright to danko12
  • βœ… Updated repository URLs to https://github.com/danko1122q/FormatUSB
  • βœ… Modernized codebase with enhanced error handling
  • βœ… Improved build system compatibility with Replit environment
  • βœ… Enhanced comprehensive English documentation
  • βœ… Fixed compilation warnings
  • βœ… Enhanced USB device detection algorithm
  • βœ… Improved user interface with modern styling
  • βœ… Better safety checks for system drive protection

Technical Improvements:

  • Enhanced multi-method USB device detection (lsblk, udevadm, /sys/block)
  • Improved error handling in formatting library
  • Modern C++20 features usage
  • Better Qt5/Qt6 compatibility
  • Cleaner code structure and organization

Version 1.0.3 (October 03, 2025)

Changes:

  • βž• Added comprehensive health check script
  • πŸ“š Updated documentation with detailed installation guide
  • πŸ”§ Improved README with troubleshooting section
  • 🌐 Converted all documentation to English

Version 1.0.3 (October 03, 2025)

Changes:

  • βž– Removed license button from about dialog (cleaner UI)
  • πŸ“¦ Embedded CHANGELOG.txt into application resources
  • πŸš€ Improved resource management and portability

Version 1.0.1 (September 25, 2025)

Changes:

  • πŸŽ‰ Initial release after fork from MX Linux FormatUSB
  • πŸ” Enhanced USB detection
  • 🎨 Modern GUI with compact design
  • πŸ“ Updated copyright
  • πŸ› οΈ Improved error handling

🀝 Contributing

Contributions are welcome! Here's how you can help:

Reporting Bugs

  1. Open GitHub Issues
  2. Check if the bug is already reported
  3. Create a new issue with:
    • OS & Version: Ubuntu 22.04, Debian 12, etc.
    • Qt Version: Output from qmake --version
    • Steps to Reproduce: Clear steps to trigger the bug
    • Expected Behavior: What should happen
    • Actual Behavior: What actually happens
    • Logs: Output from /tmp/formatusb.log
    • Screenshots: If applicable

Contributing Code

  1. Fork the repository
  2. Clone your fork:
    git clone https://github.com/danko1122q/FormatUSB.git
  3. Create feature branch:
    git checkout -b feature/amazing-feature
  4. Make changes and test thoroughly
  5. Commit with descriptive messages:
    git commit -m "Add: Support for F2FS filesystem"
  6. Push to your fork:
    git push origin feature/amazing-feature
  7. Create Pull Request on GitHub

Coding Standards

  • Follow Qt coding conventions
  • Use modern C++20 features where appropriate
  • Add comments for complex logic
  • Test on multiple Linux distributions
  • Update documentation for user-facing changes
  • Ensure code compiles without errors

πŸ“„ License

This project is licensed under GNU General Public License v3.0.

FormatUSB - USB Drive Formatting Tool
Copyright (C) 2025 danko12

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

See LICENSE file for complete details.


πŸ‘₯ Credits

Current Maintainer

  • danko12 - Lead Developer & Maintainer

Original Project

  • MX Linux Team - Original FormatUSB implementation
  • James Bowlin (BitJam) - live-usb-maker utilities

Frameworks & Libraries

  • Qt Framework - Excellent GUI toolkit
  • GNU Project - Core utilities
  • Linux Kernel - USB and block device support

πŸ“ž Support & Contact


⭐ Show Your Support

If this project is useful to you, please give it a ⭐ on GitHub!

GitHub stars GitHub forks


Made with ❀️ for the Linux community by danko12

FormatUSB is an open-source tool developed to make formatting USB drives on Linux safe, easy, and intuitive.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •