BACKUP! Most Fun&Risky Part
Usig dd which stands for copy & compile or disk destroyer lol
Clone a disk
sudo dd if=/dev/sda of=/dev/sdb
sudo dd if=/dev/sda of=/dev/sdb status=progress
Here is an example:
ubuntu@ip-172-31-35-199:~$ sudo dd if=/dev/nvme0n1p15 of=/mnt/backup_boot_disk/boot.img
217088+0 records in
217088+0 records out
111149056 bytes (111 MB, 106 MiB) copied, 1.3895 s, 80.0 MB/s
ubuntu@ip-172-31-35-199:~$ ls /mnt/backup_boot_disk
boot.img
ubuntu@ip-172-31-35-199:~$ ls -lh /mnt/backup_boot_disk
total 107M
-rw-r--r-- 1 root root 106M Aug 27 21:06 boot.img
dd Command Line Options
sudo dd if=/dev/nvme0n1p15 of=/mnt/backup_boot_disk/boot.img status=progress conv=sync,noerror
By default “dd” run with 512 bytes which very small, for new linux distro you can go more with it
sudo dd if=/dev/nvme0n1p15 of=/mnt/backup_boot_disk/boot.img status=progress conv=sync,noerror bs=1M
Now, let’s say we just want the MBR to be backed up:
sudo dd if=/dev/nvme0n1 of=/mnt/backup_boot_disk/mbr.img count=1 bs=512
and with this you can capture the first 512 bytes
What about back up with compression? well, dd dosen’t have this ability to do this, but we can work around and achieve this by piping the input to gzip
sudo dd if=/dev/nvme0n1p15 bs=1M status=progress | gzip -c > /mnt/backup_boot_disk/boot.img.gz
and guess what !!
ubuntu@ip-172-31-35-199:~$ ls -lh /mnt/backup_boot_disk
total 109M
-rw-r--r-- 1 root root 106M Aug 27 21:06 boot.img
-rw-r--r-- 1 root root 3.0M Aug 27 21:31 boot.img.gz
3.0M !! this is way smaller, i wasn’t waiting for this little tiny image
Restoring the disk: Just inverse the input with output, and make sure the disk you redirecting to is unmounted first
Last updated