Some backup schemes use disk partitions as the basic unit of system backup. In such a scenario, each of the filesystems listed in /etc/fstab is backed up separately, and they are arranged so that each filesystem fits within the size of the backup media. For this reason, the available backup device capabilities can play a role in determining the ultimate size of partitions.

Using the dd command as discussed earlier, you can back up each of the individual partitions. The command may also be used to back up the entire hard drive. To back up a hard drive to another hard drive, you would issue the following command, where if=/dev/hdx represents the hard drive you want to back up and of=/dev/hyd represents the target or destination drive of the backup:

dd if=/dev/hdx of=/dev/hdy

If you are just interested in making a backup of the partition layout, you can also use the sfdisk command to create a copy of the partition table:

sfdisk -d /dev/hda > partition_backup.txt

Then, if you need to restore the partition table, you can use the sfdisk command again:

sfdisk /dev/hda < partition_backup.txt

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.