Search This Blog

2013-07-09

Parted and Partitioning Commands

The parted command seems to me to be the replacement to fdisk, with GPT support and an extended feature set it seems to do things fdisk cannot.

Here are some command commands I use with parted

Print partition layout in sectors then in MiB
parted /dev/sda unit s print
parted /dev/sda unit MiB print

Command to tell the kernel of the changes you have done to the partition table
# notify kernel of new partitions
partprobe /dev/$part_or_disk
# notify kernel of new system partitions
partx -v -a $hddDrive
# let the kernel know about the removal of partitions
partx -d --nr $partNum /dev/sda
ls /dev/sda* to ensure that everything mounted properly.
cat /proc/partitions to ensure all your partitions you requeted for change are there.

Some cool range stuff with partx:
partx -d --nr :-1 /dev/sddRemoves the last partition on /dev/sdd.

-n, --nr M:N
Specify the range of partitions. For backward compatibility also the format M-N is supported. The range may contain negative numbers, for example --nr :-1 means the last partition, and --nr -2:-1 means the last two partitions.

Supported range specifications are:
M 
Specifies just one partition (e.g. --nr 3).
M:
Specifies lower limit only (e.g. --nr 2:).
:N
Specifies upper limit only (e.g. --nr :4).
M:N or, M-NS
pecifies lower and upper limits (e.g. --nr 2:4).

No comments:

Post a Comment