Dump/Restore partition table
sfdisk -d /dev/sdX > ptable # Dump to file ptable cat ptable | sfdisk /dev/sdX # Restore from file ptable sfdisk -d /dev/sdX | sfdisk /dev/sdY # Copy to another disk
Create a disk image
dd if=/dev/sdX of=disk_image.img
where sdX is the disk name (sda, sdb etc)
Create a partition image
dd if=/dev/sdXn of=partition_image.img
where sdXn is the partition name (sda1, sdc4 etc)
Mount a partition from a disk image
get partition table fro mdisk image
fdisk -l disk_image.img Disk disk_image.img: 500.1 GB, 500104826880 bytes 255 heads, 63 sectors/track, 60800 cylinders, total 976767240 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x4e19293b Device Boot Start End Blocks Id System disk_image.img1 * 2048 206847 102400 7 HPFS/NTFS/exFAT disk_image.img2 206848 102399999 51096576 7 HPFS/NTFS/exFAT disk_image.img3 102400000 961781109 429690555 83 Linux disk_image.img4 961781110 976751999 7485445 82 Linux swap / Solaris
determine partition offset as follows: sector_size * start_sector
For 3rd partition (disk_image.img3) this would be 512 * 102400000
mount -o loop,offset=$((512*102400000)) disk_image.img /mnt
Copy a partition from a disk image
Determine partition size and offset as above
dd if=disk_image.img of=/dev/sdXn bs=512 skip=$((102400000)) count=$((961781109-102400000+1))