Create and manage partitions on a hard disk
fdisk [-fz] [-B loader] drive [cmd [args]]
Neutrino
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.
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.
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 |
5 | DOS extended | N/A | N/A | N/A |
7 | Windows NTa | fs-nt.so | N/A | N/A |
8 or 9 | QNX 2 | N/A | N/A | N/A |
11, 12, or 14 | FAT32 | fs-dos.so | mkdosfs | chkdosfs |
15 | Windows 95 extended | N/A | N/A | N/A |
77, 78, or 79 | QNX 4 | fs-qnx4.so | dinit | chkfsys |
99 | UNIX | N/A | N/A | N/A |
130 | Linux swap | N/A | N/A | N/A |
131 | Linux (Ext2) | fs-ext2.so | N/A | N/A |
133 | Linux extended | N/A | N/A | N/A |
165 | BSD | N/A | N/A | N/A |
175 | Apple Macintosh HFS or HFS Plusa | fs-mac.so | N/A | N/A |
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.
The fdisk utility supports the following commands directly from the command line:
If you specify the -c option, the -p option is ignored.
Note that extended partition indexes may change due to additions.
Note that extended partition indexes may change due to deletions.
The fdisk utility makes a devctl(DCMD_CAM_DEVINFO) call 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.
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):
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 </comment> 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.
The commands are:
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 previous non-QNX bootstrap loader. |
Loader | Change the bootstrap loader to the QNX loader. |
Save | Save all changes and quit. This writes to the device and is irrevocable. |
Quit | Quit without saving changes. |
Create a QNX 4 partition that occupies half the disk, or the largest available space if there isn't a space big enough for a new partition that occupies half the disk:
fdisk /dev/hd0 add -t 77 -p 50
Do the same, but make the partition bootable:
fdisk /dev/hd0 add -b -t 77 -p 50
Continuing from either of the above examples, reread the partition table, set up a QNX 4 filesystem on the new partition, and then mount it:
mount -e /dev/hd0 dinit -h /dev/hd0t77 mount -t qnx4 /dev/hd0t77 /mnt/q4fs
Create a bootable partition for a Power-Safe filesystem, reread the partition table, format the new partition, and then mount it:
fdisk /dev/hd0 add -b -t 179 -p 50 mount -e /dev/hd0 mkqnx6fs /dev/hd0t179 mount -t qnx6 /dev/hd0t179 /mnt/psfs