1

I'm figuring out how to backup the first 3 of 5 partitions, in order to be able to restore them in case of disk failure or in case I messed up my system. Partition 4 and 5 are setup in RAID 1 configuration and contain data, which is backed up on another disk.

I think I should use the procedure below. My question is whether this works and will the RAID 1 configuration still work?

  1. Get partition information:
willem@willem-desktop:~$ sudo parted -l
[sudo] password for willem:
Model: ATA WDC WD10JFCX-68N (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number Start   End    Size   File system  Name  Flags
1      1049kB  538MB  537MB  fat32              boot
2      538MB   794MB  256MB  ext2
3      794MB   170GB  170GB                     lvm
4      170GB   485GB  315GB  btrfs
5      485GB   799GB  315GB  btrfs
  1. Boot LiveUSB
  2. Reduce entropy on partition 3:
dd if=/dev/zero of=/tmp/delete.me bs=8M; rm delete.me
  1. Calculate GPT table size Formula = (128*N)+1024 = (128*5)+1024 = 1664

  2. Backup GPT table

dd if=/dev/sda of=GPT_TABLE bs=1 count=1664
  1. Backup partitions 1, 2 and 3
dd if=/dev/sda1 | bzip2 > /media/sda1_image.bz2
dd if=/dev/sda2 | bzip2 > /media/sda2_image.bz2
dd if=/dev/sda3 | bzip2 > /media/sda3_image.bz2
  1. If needed, restore GPT table
dd  if=GPT_TABLE of=/dev/sda bs=1 count=1664
  1. If needed, restore partitions 1, 2 and 3
bzcat /media/sda1_image.bz2 | dd of=/dev/sda1
bzcat /media/sda2_image.bz2 | dd of=/dev/sda1
bzcat /media/sda3_image.bz2 | dd of=/dev/sda1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.