Fdisk / gdisk / sfdisk / sgdisk / parted
Jump to navigation
Jump to search
The familie of fdisk programs are used to handle partition tables.
- fdisk original DOS partition table program, linux version is called the same
- cfdisk has a nice interface, but does not align partitions to 1MB
- sfdisk works well for MBR formatted hard disks
- sgdisk does the same as sfdisk but is for GPT formatted hard disks
- parted is a very powerful tool to work and fix partition tables
- gparted is the graphical version of parted and exists also as bootable CD, http://gparted.org/livecd.php
- diskpart is the successor of fdisk on Windows 2000 onward
Backup a partition table
sfdisk -d /dev/sda > backup.sfdisk # for MBR sgdisk --backup=backup.sgdisk /dev/sda # for GPT
Copy a partition table
sfdisk -d /dev/sda | sfdisk /dev/sdb # for MBR sgdisk --backup=tmp.sgdisk /dev/sda # for GPT sgdisk --load-backup=tmp.sgdisk /dev/sdb sgdisk -G /dev/sdb # note GPT uuid must be unique
Restore a partition table
sfdisk -f /dev/sdb < backup.sfdisk # for MBR # -f force sgdisk --load-backup=backup.sgdisk /dev/sdb # for GPT