Skip to content

Instantly share code, notes, and snippets.

@maykbrito
Last active July 8, 2024 08:31
Show Gist options
  • Save maykbrito/e53bfb4c2e7d0c1704167947e10e362e to your computer and use it in GitHub Desktop.
Save maykbrito/e53bfb4c2e7d0c1704167947e10e362e to your computer and use it in GitHub Desktop.
Using dd Command: Clone file, folder, disk / mount it / restore it

Clone

To create a backup

dd if=file1 of=backup.dd

Everything is file. IF = Input File, OF = Output File. So, you can clone an entire disk

  • Use bs=4096 argument if you are cloning into a HD and need more speed on process
  • Use status=progress to monitoring data written
  • Use conv=sparse to sparse file
  • For integrity: sha1sum backup.dd & sha1sum file1

Mount

To browser and see files

mkdir /media/file
mount backup.dd /media/file

Restore

If you had clone a disk with dd, you can restore it to a physical drive.

dd if=disk.dd of=/dev/sdb

Rescue bad disk

Try to recovery bad disk

dd_rescue -a -b 8M /dev/sda /mount/external/backup/sda.dd

References

@changchichung
Copy link

how to clone a "folder" ??

@maykbrito
Copy link
Author

Hi!
In this method, you can see "folder" as "file".
folder == file

Hope it still working!

@jmfergeau
Copy link

Hi! In this method, you can see "folder" as "file". folder == file

Hope it still working!

Nope it doesn't. It reports an error saying it's "a folder".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment