How to list start and end sectors of a partition by parted in Linux?
Posted on In QAHow to list start and end of a partition by the sectors in parted
on Linux? The default behavior seems be listing the start and end by bytes in parted
.
# parted /dev/sdc print
Model: Innostor IS888 ext. HDD (scsi)
Disk /dev/sdc: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 2097kB 2000GB 2000GB ext4 home
parted
has a unit
command to specify the unit to use.
unit unit
Set unit as the unit to use when displaying locations and sizes, and for interpreting those given by the user when not suffixed with an explicit unit. unit can be one of “s” (sectors), “B” (bytes), “kB”, “MB”, “MiB”, “GB”, “GiB”, “TB”, “TiB”, “%” (percentage of device size), “cyl” (cylinders), “chs” (cylinders, heads, sectors), or “compact” (megabytes for input, and a human-friendly form for output).
For sectors, the unit is “s”.
To print the stand and end sections of a disk such as sda
, the command will be
parted /dev/sda 'unit s print'
Example:
# parted /dev/sda 'unit s print'
Model: ATA ST2000DM001-1CH1 (scsi)
Disk /dev/sda: 3907029168s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 4096s 1229064191s 1229060096s data
3 1229064192s 3907029134s 2677964943s