fdisk

Note:
In order to run this utility, you must be logged in as root
or have read/write permissions for the block-special file concerned.

Syntax:

fdisk [-fz] [-B loader] drive [cmd [args]]

Runs on:

QNX Neutrino

Options:

-Bloader

Use the 512-byte file named by loader as the primary bootstrap
loader for the device when instructed to write a boot loader to the disk.
The default is to install a loader that's built into the fdisk utility.

-f

Force the boot loader to be written on command, even if it isn't
possible to save an existing old loader to a mounted filesystem.
In non-interactive mode, execute the given add command, even
if this would involve overwriting an existing partition slot.

-z

Zero the partition table (interactive mode only).

drive

The disk drive to partition. This must name a block-special file
(e.g., /dev/hd0).

Description:

The fdisk utility lets you create and manage partitions on
a hard disk (typically a rotating medium, but fdisk works on
other devices, such as compact flash and USB flash, if they support
PC-style Master Boot Records (MBRs) and partitions).
The partition information, which is kept in the disk's first physical block,
matches that used by DOS.

On some platforms, fdisk supports a full-screen interface; see
Interactive mode, below.

CAUTION:

The installer for Microsoft Windows overwrites any existing
Master Boot Record with its own.
If you want your disk to contain bootable DOS and bootable QNX
(or other non-DOS)
partitions, you should install Windows first, and then create
the other partitions.
If you create a QNX partition first and then install Windows, you
can restore the boot loader by running QNX Neutrino from the installation
disk and explicitly using
dloader.

On some x86 machines, you can boot only from OS images that are loaded from within the first
1024 cylinders of the disk. This means that while you may be able to
initially install and boot from a partition which extends past the 1024th
cylinder, it will someday fail when you go to update the boot
image because the location of some of its blocks may change. When this
happens you will have a system that's no longer bootable.

Avoid this problem by creating a separate partition to boot from
that lies entirely within the first 1024 cylinders of the hard drive,
and use a second partition to access the additional space on the drive.
(The boot partition may be quite small—just a few megabytes will suffice.)

Before creating a partition for the first time, you must start the hard disk driver:

devb-eide &

You should then execute the fdisk command to partition your disk.
For example:

fdisk /dev/hd0 add -t 179 -p 50

New or changed partitions aren't immediately recognized and/or mounted.
You must either slay and restart the filesystem/driver
(devb-*),
use
mount -e /dev/hd0
to recognize the new partitions and update the contents of
/dev, or reboot.

Partition types

The fdisk utility recognizes the following partition types.
If you add a partition, use the command shown to initialize it.

For more information, see the
Filesystems
chapter of the System Architecture guide.

Commands

The fdisk utility supports the following commands directly from the
command line:

add [args]

Add a new partition entry of the size and type specified. If
fdisk can't locate sufficient unallocated disk space
to satisfy your request, it allocates the largest available portion
of the disk (if any). Here are the arguments for add:

-b

Make the added partition bootable.
If another partition was already flagged as the primary boot
partition, the flag is turned off for it.

-cstart,end

The start and end for the partition to use.

-eextended_slot

The index into the extended partition (1–N).

-l

(el) Use blocks instead of cylinders as the units.

-ncount

The number of cylinders to allocate (extended partitions only).

-ppercent

The percentage of the largest contiguous space the added partition should use.
The default is 100%.

If you specify the -c option, the -p option is ignored.

-sslot

The slot (1-4) in the partition table to use.
The default is the last free slot.

-ttype

The type of partition to add (0–255). The default is 178 (Power-Safe filesystem).

Note that extended partition indexes may change due to additions.

boot [args]

Turn on the boot flag for the indicated partition. If another partition
was already flagged as the primary boot partition, the flag is turned
off for it. Here are the arguments for boot:

-eextended_slot

The index into the extended partition (1–N).

-sslot

Boot the partition in the selected slot.

-ttype

Boot the partition of the selected type.

delete [args]

Delete the specified partitions. Here are the arguments for delete:

-a

Delete all partitions.

-eextended_slot

The index into the extended partition (1–N).

-sslot

Delete the partition in the selected slot.

-ttype

Delete this type of partition.

Note that extended partition indexes may change due to deletions.

info

Show the mount information for the raw drive.

The fdisk utility uses a DCMD_CAM_DEVINFOdevctl()
command to obtain the cylinder, head, sectors per track, and total sectors counts.
Multiplying the first three values together is the classic method of
calculating the total number of sectors.

However, some hard drives employ zoned bit recording, so it's impossible to
precisely map the number of sectors per track and other fields.
As a result, the total number of sectors returned from devctl()
and the total number of sectors that were calculated might not match.
In this case, fdisk displays a warning.

loader

Write the QNX loader to the disk.

query [args]

Print the number of cylinders to standard output.
Here are the arguments for query:

-eextended_slot

The index into the extended partition (1–N).

-f

Display the total number of free cylinders.

-l

(el) Use blocks instead of cylinders as the units.

-sslot

Query the partition in the selected slot.

-T

Display the total number of cylinders.

-ttype

Query the partition of the selected type.

show [args]

Display the partition table.
The argument for show is:

-l

(el) Use blocks instead of cylinders as the units.

Interactive mode

On some platforms, fdisk is a fullscreen, interactive program
that's fairly self-explanatory. When you invoke fdisk,
you'll see a screen similar to this one (assuming your disk is already
partitioned):