LinuxCommandLibrary

mpartition

Partition media for Minix filesystem

SYNOPSIS

mpartition [options] device type [size]
mpartition device -D partition
mpartition device -P
mpartition device -a partition
mpartition device -i partition

PARAMETERS

device
    The device file (e.g., /dev/sdb) or disk image file to operate on.

type
    The partition type (e.g., primary, extended), often used in conjunction with type-specific flags.

size
    The size of the partition, specified either in sectors with -s or megabytes with -m.

-I
    Initializes the disk, destroying any existing MBR and creating an empty partition table. Use with extreme caution.

-0
    Instructs mpartition not to create a primary partition, useful when only creating extended partitions.

-p
    Creates a primary partition. This is the default if no -e or -E is specified.

-e
    Creates an extended partition.

-E
    Creates an extended partition that is not marked as Win95 LBA (type 0Fh), suitable for older DOS systems.

-s sectors
    Specifies the size of the partition in disk sectors.

-m MB
    Specifies the size of the partition in megabytes.

-D partition_number
    Deletes the specified partition number.

-P
    Prints the current partition table of the specified device.

-a partition_number
    Marks the specified partition as active (bootable).

-i partition_number
    Marks the specified partition as inactive.

-t type_code
    Specifies the partition type code (e.g., 0b for FAT32, 0c for FAT32 LBA) in hexadecimal.

-f
    Forces the creation even if the disk appears too small for the requested partition.

-v
    Enables verbose output, showing more details about the operation.

DESCRIPTION

mpartition is a utility from the mtools suite designed to create, delete, and modify partition table entries specifically for MS-DOS filesystems. Unlike general-purpose disk partitioning tools like fdisk or parted, mpartition focuses on the MBR (Master Boot Record) and is primarily intended for managing partitions on devices or disk images that will host MS-DOS or FAT-based filesystems. It allows users to set a partition as active, specify its size in sectors or MB, and define its partition type.

Its usage is quite specialized, typically employed when preparing floppy disks, USB drives, or disk image files for use with legacy DOS systems or emulators, rather than for modern hard disk partitioning on Linux. It operates directly on the raw device or file.

CAVEATS

mpartition is part of the mtools suite, designed primarily for MS-DOS compatible filesystems. It is generally not suitable for managing partitions for modern Linux, Windows, or other non-DOS operating systems on primary hard drives.

It operates directly on the Master Boot Record (MBR) and should be used with extreme caution, as incorrect usage can lead to data loss or an unbootable system.

It does not create filesystems; it only modifies the partition table. You will need to use a tool like mkfs.fat (or mkdosfs) after creating the partition.

It is not designed for GPT (GUID Partition Table) disks, only MBR.

DIRECT MBR MODIFICATION

mpartition directly modifies the Master Boot Record (MBR) on the specified device or file. This means it bypasses any operating system level partitioning abstractions and operates at a very low level. This direct interaction grants power but also carries significant risk of data corruption if misused.

PURPOSE AND WORKFLOW

Its primary purpose is to set up a partition table entry on a raw disk or image before a filesystem is created on that partition, specifically for FAT-based systems. It does not handle filesystem creation itself; after using mpartition, a separate tool like mkfs.fat is needed to format the newly created partition.

HISTORY

mpartition is a component of the mtools software package, which originated in the early days of Linux (and Unix-like systems) to provide utilities for interacting with MS-DOS filesystems. As DOS compatibility was crucial for many users, mtools filled a significant gap by allowing seamless access and manipulation of FAT-formatted floppies and hard drive partitions without requiring a DOS installation. mpartition specifically addressed the need to prepare partitions for these DOS environments, particularly for floppy disks and early hard drives. Its usage has become more niche over time, now primarily serving legacy system support, virtualization, and embedded systems that still rely on FAT partitions.

SEE ALSO

fdisk(8), parted(8), mkfs.fat(8), mtools(1), mlabel(1), mmd(1)

Copied to clipboard