fdisk
Create and manage partitions on a hard disk
Syntax:
fdisk [-fz] [-B loader] drive [cmd [args]]
Runs on:
QNX OS
Options:
- -B loader
- Specifies the 512-byte file that the loader command writes to the disk.
- -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).
- cmd [args]
- An fdisk command, as described below.
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.
devb-eide &
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.
Type | Filesystem | Shared object | Initialize with: | Check with: |
---|---|---|---|---|
1, 4, or 6 | DOS | fs-dos.so | mkdosfs | chkdosfs |
11, 12, or 14 | FAT32 | fs-dos.so | mkdosfs | chkdosfs |
177, 178, or 179 | Power-Safe | fs-qnx6.so | mkqnx6fs | chkqnx6fsb |
a Read-only.
b Not usually necessary.
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.
- -c start,end
- The start and end for the partition to use.
- -e extended_slot
- The index into the extended partition (1–N).
- -l
- (
el
) Use blocks instead of cylinders as the units. - -n count
- The number of cylinders to allocate (extended partitions only).
- -p percent
- 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.
- -s slot
- The slot (1-4) in the partition table to use. The default is the first free slot.
- -t type
- 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:
- -s slot
- Boot the partition in the selected slot.
- -t type
- Boot the partition of the selected type.
- delete [args]
- Delete the specified partitions. Here are the arguments for delete:
- -a
- Delete all partitions.
- -e extended_slot
- The index into the extended partition (1–N).
- -s slot
- Delete the partition in the selected slot.
- -t type
- 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_DEVINFO devctl() 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. You must specify the loader file name using -B on the command line or the operation will fail.
- query [args]
- Print the number of cylinders to standard output.
Here are the arguments for query:
- -e extended_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. - -s slot
- Query the partition in the selected slot.
- -T
- Display the total number of cylinders.
- -t type
- 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. This mode requires a properly configured /usr/share/terminfo directory structure and TERM environment variable.
FDISK
Ignore Next Prev 1 2 3 4 Change Delete Boot Unboot Restore Loader Save Quit
_____OS_____ Start End ______Number_____ Size Boot
name type Cylinder Cylinder Cylinders Blocks
--> 1. QNX6 (177) 0 7648 7649 122881122 60000 MB
2. QNX6 (178) 7649 9963 2315 37190475 18159 MB *
3. ______ (___) _______ _______ _______ _________ _____
4. ______ (___) _______ _______ _______ _________ _____
Choose a partition by typing the partition number OR moving the pointer
with the UP/DOWN arrows.
Then, choose one of the actions on the top line of the screen.
Drive : /dev/hd0 Config: 255 Heads
Size : 78159 Mbytes 63 Sectors/track
Loader: Unknown 9964 Cylinders
512 Block Size
Last cylinder is 9963
You'll see the available commands displayed at the top of the screen. To select a command, either type its first letter or move the cursor to the command (with the arrow keys) and press Enter.
Command: | Action: |
---|---|
Next | Move the pointer to the next entry. |
Prev | Move the pointer to the previous entry. |
1, 2, 3, or 4 | Move the pointer to the indicated entry. |
Change | Change the selected partition (see below). |
Delete | Delete the selected partition. |
Boot | Turn on the boot flag for the selected partition. If another partition was already flagged as the primary boot partition, the flag is turned off for it. |
Unboot | Turn off the boot flag for the selected partition. |
Restore | Restore the partition table from the disk for editing. |
Loader | Change the bootstrap loader to the QNX loader. You must specify the loader file name using -B on the command line or the operation will fail. |
Save | Save all changes and quit. This writes to the device and is irrevocable. |
Quit | Quit without saving changes. |
- Save the details about the partition (e.g., by writing them on a piece of paper), because fdisk blanks the fields as you edit them.
- You have to enter the partition's type number and the start and end cylinders; fdisk calculates the other information for you. Press Enter after typing each value.
- If the partition was bootable before you changed it, use the Boot command to make it bootable again.
Examples:
fdisk /dev/hd0 add -b -t 179 -p 50
mount -e /dev/hd0
mkqnx6fs /dev/hd0t179
mount -t qnx6 /dev/hd0t179 /mnt/psfs
Exit status:
- 0
- Success.
- >0
- An error occurred; fdisk writes error messages to standard error.
Caveats:
After changing any partition information, you must either slay and restart the filesystem/driver (devb-*) or use mount -e to make the filesystem reread the partition table.