2.4.17 unit

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 unit.

unit may be one of:

s

sector (n bytes depending on the sector size, often 512)

B

byte

KiB

kibibyte (1024 bytes)

MiB

mebibyte (1048576 bytes)

GiB

gibibyte (1073741824 bytes)

TiB

tebibyte (1099511627776 bytes)

kB

kilobyte (1000 bytes)

MB

megabyte (1000000 bytes)

GB

gigabyte (1000000000 bytes)

TB

terabyte (1000000000000 bytes)

%

percentage of the device (between 0 and 100)

cyl

cylinders (related to the BIOS CHS geometry)

chs

cylinders, heads, sectors addressing (related to the BIOS CHS geometry)

compact

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.

Example:

(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