parted

partition manipulation program

sudo parted [options] [device [command [options]]]

Manipulate disk partitions. supports multiple partition table formats, including MS-DOS and GPT.
For creating space for new operating systems, reorganising disk usage, and copying data to new hard disks.

see partprobe

If no command is given, parted will present a command prompt.
Default device:first block device found.

-l
--list
partition layout on all block devices
Model: SD SL32G (sd/mmc)
Disk /dev/mmcblk0: 31.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      4194kB  47.7MB  43.5MB  primary  fat32        lba
 2      48.2MB  15.9GB  15.9GB  primary  ext4
 3      15.9GB  22.4GB  6442MB  primary
-m
--machine
displays machine parseable output
BYT;
/dev/mmcblk0:31.9GB:sd/mmc:512:512:msdos:SD SL32G:;
1:4194kB:47.7MB:43.5MB:fat32::lba;
2:48.2MB:15.9GB:15.9GB:ext4::;
3:15.9GB:22.4GB:6442MB:::;
-s
--script
no prompts
-a atype
--align atype
Set alignment for new partitions
none Use the minimum alignment allowed by the disk type.
cylinder Align partitions to cylinders.
minimal Use minimum alignment as given by the disk topology information. This and the opt value will use layout information provided by the disk to align the logical partition table addresses to actual physical blocks on the disks. The min value is the minimum alignment needed to align the partition properly to physical blocks, which avoids performance degradation.
optimal as given by the disk topology information. to a multiple of the physical block size for optimal performance.
-v
--version
-h
--help

COMMANDS

print Display the partition table.
 sudo parted /dev/mmcblk0
GNU Parted 3.2
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Model: SD SA04G (sd/mmc)
Disk /dev/mmcblk0: 3905MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      4194kB  50.2MB  46.0MB  primary  fat32        lba
 2      50.3MB  1866MB  1816MB  primary  ext4

(parted) q                                                              
              
unit unit 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).
resizepart partition end Change the end position of partition.

(parted) p
Model: SD SS08G (sd/mmc)
Disk /dev/mmcblk0: 7948MB
…
Number  Start   End     Size    Type     File system  Flags
 2      273MB   2248MB  1976MB  primary  ext4

(parted) resizepart                                                       
Partition number? 2                                                       
End?  [2248MB]? 7400MB                                                    
(parted) p                                                                
Model: SD SS08G (sd/mmc)
Disk /dev/mmcblk0: 7948MB
…
Number  Start   End     Size    Type     File system  Flags
 2      273MB   7400MB  7127MB  primary  ext4

sudo fdisk /dev/mmcblk0 Command (m for help): p Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 sectors Disk identifier: 0x6c586e13 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p2 532480 14453125 13920646 6.7G 83 Linux Command (m for help): F Unpartitioned space /dev/mmcblk0: 525 MiB, 550502400 bytes, 1075200 sectors Start End Sectors Size 2048 8191 6144 3M 14454784 15523839 1069056 522M
    Warning
  1. Does not modify filesystem in the partition. See resize2fs

  2. Changes Disk identifier.
    Necessitates changing /etc/fstab and /boot/cmdline.txt
mklabel label-type Create a new disklabel (partition table) of aix amiga bsd dvh gpt loop mac msdos pc98 or sun.
mkpart part-type [fs-type] start end Make a partition for filesystem (by default in megabytes). part-type should be one of primary logical or extended.
name partition name Only on Mac, PC98, and GPT disklabels. name can be placed in quotes, if necessary.
rescue start end Rescue a lost partition located between start and end.
rm partition Remove partition.
select device
set partition flag on|off boot root swap hidden raid lvm lba legacy_boot irst esp palo.
toggle partition flag
align-check type partition type : minimal or optimal.
version
help [command] Print general help, or help on command
quit

Starting without command runs inactively:

sudo parted
GNU Parted 3.2
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) h                                                                
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a particular
        partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted 

SEE ALSO fdisk, mkfs(8),

True parted documentation.


partprobe

inform the OS of partition table changes

sudo partprobe [-d] [-s] [devices]

Informs the operating system kernel of partition table changes.

-d
--dry-run
Don't update the kernel.
-s
--summary
Show a summary of devices and their partitions.
/dev/mmcblk0: msdos partitions 1 2
-h
--help
Show summary of options.
-v
--version
Show version of program.
partprobe (GNU parted) 3.2
Copyright (C) 2014 Free Software Foundation, Inc.…