Escolar Documentos
Profissional Documentos
Cultura Documentos
Pagina 1 di 5
fdisk
This version of this document is no longer maintained. For the latest documentation, see
http://www.qnx.com/developers/docs.
fdisk
Create and manage partitions on a hard disk
In order to run this utility, you must be logged in as root or have read/write permissions for the blockspecial file concerned.
Syntax:
fdisk [-fpz] [-B loader] drive [cmd [args]]
Runs on:
Neutrino
Options:
-B loader
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 noninteractive use with the loader command, this forces the loader to be written in cases
where the command would otherwise be aborted. In interactive mode, you're queried about the operation if you
didn't specify -f; the operation simply proceeds without saving the old loader if you did specify -f.
-p
Pause before starting.
-z
Zero the partition table (interactive mode only).
drive
The disk drive to partition. This must name a block-special file (e.g. /dev/fd1, /dev/hd0).
[cmd [args]]
An installation 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.
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
http://www.qnx.com/developers/docs/6.4.1/neutrino/utilities/f/fdisk.html
7/17/2015
fdisk
Pagina 2 di 5
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 QNX4 partition for the first time, you must first start the hard disk driver:
devb-eide &
You should then execute the fdisk command to partition your disk:
fdisk /dev/hd0 add
The QNX4 filesystem doesn't automatically relearn any changes that you make to the partition table with fdisk.
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
DOS extended
N/A
N/A
N/A
Windows NT
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 or 147
Linux extended
N/A
N/A
N/A
165
BSD
175
177, 178, or 179
N/A
N/A
N/A
fs-mac.so
N/A
N/A
Power-Safe
fs-qnx6.so
mkqnx6fs
chkqnx6fsb
Read-only.
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.
-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
http://www.qnx.com/developers/docs/6.4.1/neutrino/utilities/f/fdisk.html
7/17/2015
fdisk
Pagina 3 di 5
The slot in the partition table to use. The default is the first open slot.
-t type
The type of partition to add (0 - 255). The default is 77.
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.
-s slot
Delete the partition in the selected slot.
-t type
Delete this type of partition.
info
Show the mount information for the raw drive.
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.
loader
Write the QNX loader to the disk.
query [args]
Print the number of cylinders to standard output. Here are the arguments for query:
-f
Print the total amount of free space.
-s slot
Query the partition in the selected slot.
-T
Print the total amount of space.
-t type
Query the partition of the selected type.
show
Display the partition table.
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):
FDISK
Ignore Next Prev 1 2 3 4 Change Delete Boot Unboot Restore Loader Save Quit
--> 1.
2.
3.
4.
_____OS_____
name
type
Start
Cylinder
End
Cylinder
______Number_____
Cylinders Blocks
Size
QNX6
QNX6
______
______
0
7649
_______
_______
7648
9963
_______
_______
7649
2315
_______
_______
60000 MB
18159 MB
_____
_____
(177)
(178)
(___)
(___)
122881122
37190475
_________
_________
Boot
http://www.qnx.com/developers/docs/6.4.1/neutrino/utilities/f/fdisk.html
7/17/2015
fdisk
Pagina 4 di 5
Drive : /dev/hd0
Size : 78159 Mbytes
Loader: Unknown
Config:
255
63
9964
512
Heads
Sectors/track
Cylinders
Block Size
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
Prev
1, 2, 3, or
4
Change
Delete
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
Restore
Loader
Save
Save all changes and quit. This writes to the device and is irrevocable.
Quit
Examples:
Create a QNX4 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 QNX4 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
Exit status:
http://www.qnx.com/developers/docs/6.4.1/neutrino/utilities/f/fdisk.html
7/17/2015
fdisk
Pagina 5 di 5
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.
See also:
chkdosfs, chkfsys, chkqnx6fs, devb-*, df, dinit, dloader, fs-dos.so, fs-ext2.so, fs-mac.so, fsnt.so, fs-qnx4.so, fs-qnx6.so, mkdosfs, mkqnx6fs, mount
Filesystems chapter of the System Architecture guide
Working with Filesystems and Backing Up and Recovering Data chapters of the QNX Neutrino User's Guide
http://www.qnx.com/developers/docs/6.4.1/neutrino/utilities/f/fdisk.html
7/17/2015