unit (Parted User’s Manual)
- Command: unit unit
Selects the current default unit that Parted will use to display locations and capacities on the disk and to interpret those given by the user if they are not suffixed by an
unitmay be one of:
sector (n bytes depending on the sector size, often 512)
kibibyte (1024 bytes)
mebibyte (1048576 bytes)
gibibyte (1073741824 bytes)
tebibyte (1099511627776 bytes)
kilobyte (1000 bytes)
megabyte (1000000 bytes)
gigabyte (1000000000 bytes)
terabyte (1000000000000 bytes)
percentage of the device (between 0 and 100)
cylinders (related to the BIOS CHS geometry)
cylinders, heads, sectors addressing (related to the BIOS CHS geometry)
This is a special unit that defaults to megabytes for input, and picks a unit that gives a compact human readable representation for output.
The default unit apply only for the output and when no unit is specified after an input number. Input numbers can be followed by an unit (without any space or other character between them), in which case this unit apply instead of the default unit for this particular number, but CHS and cylinder units are not supported as a suffix. If no suffix is given, then the default unit is assumed. Parted will compute sensible ranges for the locations you specify (e.g., a range of +/- 500 MB when you specify the location in “G”, and a range of +/- 500 KB when you specify the location in “M”) and will select the nearest location in this range from the one you wrote that satisfies constraints from both the operation, the filesystem being worked on, the disk label, other partitions and so on. Use the sector unit “s” to specify exact locations (if they do not satisfy all constraints, Parted will ask you for the nearest solution). Note that negative numbers count back from the end of the disk, with “-1s” pointing to the last sector of the disk.
Note that as of parted-2.4, when you specify start and/or end values using IEC binary units like “MiB”, “GiB”, “TiB”, etc., parted treats those values as exact, and equivalent to the same number specified in bytes (i.e., with the “B” suffix), in that it provides no “helpful” range of sloppiness. Contrast that with a partition start request of “4GB”, which may actually resolve to some sector up to 500MB before or after that point. Thus, when creating a partition, you should prefer to specify units of bytes (“B”), sectors (“s”), or IEC binary units like “MiB”, but not “MB”, “GB”, etc.
(parted) unit compact (parted) print Disk geometry for /dev/hda: 0kB - 123GB Disk label type: msdos Number Start End Size Type File system Flags 1 32kB 1078MB 1077MB primary reiserfs boot 2 1078MB 2155MB 1078MB primary linux-swap 3 2155MB 123GB 121GB extended 5 2155MB 7452MB 5297MB logical reiserfs
(parted) unit chs print Disk geometry for /dev/hda: 0,0,0 - 14946,225,62 BIOS cylinder,head,sector geometry: 14946,255,63. Each cylinder is 8225kB. Disk label type: msdos Number Start End Type File system Flags 1 0,1,0 130,254,62 primary reiserfs boot 2 131,0,0 261,254,62 primary linux-swap 3 262,0,0 14945,254,62 extended 5 262,2,0 905,254,62 logical reiserfs
(parted) unit mb print Disk geometry for /dev/hda: 0MB - 122942MB Disk label type: msdos Number Start End Size Type File system Flags 1 0MB 1078MB 1077MB primary reiserfs boot 2 1078MB 2155MB 1078MB primary linux-swap 3 2155MB 122935MB 120780MB extended 5 2155MB 7452MB 5297MB logical reiserfs