partx

notify kernel about the presence and numbering of on-disk partitions

partx [-a|-d|-P|-r|-s|-u] [-t type] [-n M:N] [-] disk
partx [-a|-d|-P|-r|-s|-u] [-t type] partition [disk]

Parse the partition table and list its contents. notifies the kernel to add or remove partitions

disk argument is optional when a partition argument is provided.
To force scanning a partition as if it were a whole disk

To list nested subpartitions use the argument "-" (hyphen). For example:
partx --show - /dev/sda3

Not an fdisk program - adding and removing partitions does not change the disk.

-s
--show
List the partitions. The output columns can be selected and rearranged with --output option. .
sudo partx -s /dev/mmcblk0
NR    START      END  SECTORS  SIZE NAME UUID
 1     8192    93236    85045 41.5M      c5b4c492-01
 2    94208 31116287 31022080 14.8G      c5b4c492-02
 3 31117312 62333951 31216640 14.9G      c5b4c492-03
-v
--verbose
 sudo partx --show --verbose /dev/mmcblk0
partition: none, disk: /dev/mmcblk0, lower: 0, upper: 0
/dev/mmcblk0: partition table type 'dos' detected
range recount: max partno=3, lower=0, upper=0
NR    START      END  SECTORS  SIZE NAME UUID
 1     8192    93236    85045 41.5M      c5b4c492-01
 2    94208 31116287 31022080 14.8G      c5b4c492-02
 3 31117312 62333951 31216640 14.9G      c5b4c492-03
-P
--pairs
KEY="value" format.
 sudo partx --pairs /dev/mmcblk0
NR="1" START="8192" END="93236" SECTORS="85045" SIZE="41.5M" NAME="" UUID="c5b4c492-01"
NR="2" START="94208" END="31116287" SECTORS="31022080" SIZE="14.8G" NAME="" UUID="c5b4c492-02"
NR="3" START="31117312" END="62333951" SECTORS="31216640" SIZE="14.9G" NAME="" UUID="c5b4c492-03"
-r
--raw
 sudo partx -r /dev/mmcblk0
NR START END SECTORS SIZE NAME UUID
1 8192 93236 85045 41.5M  c5b4c492-01
2 94208 31116287 31022080 14.8G  c5b4c492-02
3 31117312 62333951 31216640 14.9G  c5b4c492-03
-l
--list
List the partitions. in 512-byte sectors. Deprecated in favour of --show
 sudo partx --list /dev/mmcblk0
# 1:      8192-    93236 (    85045 sectors,     43 MB)
# 2:     94208- 31116287 ( 31022080 sectors,  15883 MB)
# 3:  31117312- 62333951 ( 31216640 sectors,  15982 MB)
-o
--output [list]
Define the output columns to use for --show, --pairs and --raw .
Use SCHEME for partition table type (dos, gpt, ...) in addition column headings.
 sudo partx --show --output nr,sectors /dev/mmcblk0 
NR  SECTORS
 1    85045
 2 31022080
 3 31216640

Cannot be combined with the --add, --delete, --update or --list .

-b
--bytes
SIZE column in bytes
-g
--noheadings
Do not output header line with --show or --raw.
 
-a
--add
Add the specified partitions, or read the disk and add all partitions.
-d
--delete
Delete one or all partitions.
-n
--nr i:j
Specify the range of partitions. -1:-1 last partition, and -2:-1 last two partitions.
i one partition. example: --nr 3.
i: lower limit example: --nr 2:.
:j upper limit example: --nr :4
i:j lower and upper limits example: --nr 2:4.
-t
--type type
aix, bsd, dos, gpt, mac, minix, sgi, solaris_x86, sun, ultrix, or unixware.
-u
--update
Update the specified partitions.
-V
--version
Display version information and exit.
 sudo partx --version                               
partx from util-linux 2.29.2
-h
--help
Display help text and exit.
partx [-a|-d|-s|-u] [--nr n:m> | partition>] disk>

Tell the kernel about the presence and numbering of partitions.

Options:
 -a, --add            add specified partitions or all of them
 -d, --delete         delete specified partitions or all of them
 -u, --update         update specified partitions or all of them
 -s, --show           list partitions

 -b, --bytes          print SIZE in bytes rather than in human readable format
 -g, --noheadings     don't print headings for --show
 -n, --nr        specify the range of partitions (example: --nr 2:4)
 -o, --output   define which output columns to use
 -P, --pairs          use key="value" output format
 -r, --raw            use raw output format
 -t, --type     specify the partition type (dos, bsd, solaris, etc.)
 -v, --verbose        verbose mode

 -h, --help     display this help and exit
 -V, --version  output version information and exit

Available columns (for --show, --raw or --pairs):
         NR  partition number
      START  start of the partition in sectors
        END  end of the partition in sectors
    SECTORS  number of sectors
       SIZE  human readable size
       NAME  partition name
       UUID  partition UUID
       TYPE  partition type (a string, a UUID, or hex)
      FLAGS  partition flags
     SCHEME  partition table type (dos, gpt, ...)

EXAMPLES

list partition 3 of /dev/sdb.:

partx --show /dev/sdb3
partx --show --nr 3 /dev/sdb
partx --show /dev/sdb3 /dev/sdb

List all subpartitions on /dev/sdb3 (the device is used as whole-disk).
partx --show - /dev/sdb3

Print the start sector of partition 5 on /dev/sdb without header.
partx -o START -g --nr 5 /dev/sdb

List the in sectors and human-readable size of partition 5 on /dev/sda.
partx -o SECTORS,SIZE /dev/sda5 /dev/sda Ads all available partitions from 3 to 5 (inclusive) on /dev/sdd.
partx --add --nr 3:5 /dev/sdd Remove the last partition on /dev/sdd.
partx -d --nr :-1 /dev/sdd

See

addpart, delpart, fdisk, parted, partprobe

ENVIRONMENT

LIBBLKID_DEBUG=all enables libblkid debug output.