Guest User

Untitled

a guest
Dec 14th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. Disk Clone With Linux dd Command
  2. --------------------------------
  3. Recently I decided to do a disk clone from one of my homelab servers that was
  4. running Ubuntu 16.04 LTS so I could install Gentoo on it.This guide shows the
  5. steps I took to get my disk cloned.
  6.  
  7. Get the disk information
  8. ------------------------
  9. Before I could start the clonning process;I had to get disk block information
  10. using `lsblk`.
  11.  
  12. ```
  13. $ lsblk
  14. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  15. sr0 11:0 1 1024M 0 rom
  16. xvda 202:0 0 30G 0 disk
  17. ├─xvda1 202:1 0 487M 0 part /boot
  18. ├─xvda2 202:2 0 1K 0 part
  19. └─xvda5 202:5 0 29.5G 0 part
  20. ├─owl--vg-root 252:0 0 27.4G 0 lvm /
  21. └─owl--vg-swap_1 252:1 0 2.1G 0 lvm [SWAP]
  22. ```
  23. My disk of interest was `xvda` that has lvm partions.
  24.  
  25. Clonning the disk
  26. -----------------
  27. The cloned disk needed to be stored to another server so I had to pipe the
  28. result of the `dd` command to `ssh`.
  29.  
  30. ```bash
  31. $ dd if=/dev/xvda | ssh xvf@storage.local "sudo dd of=~/clone.img status=progress"
  32. ```
  33.  
  34. The above command clone the disk `/dev/xvda` to `clone.img` on my other server.
  35. Once the process had finished I loaded the image with `kvm` to test if
  36. everything is ok.The process was successfully since I managed to boot the image
  37. with no error.
  38.  
  39. I prefer working with `qcow2` format instead of the `raw` so I had to do an
  40. image convertion using `qemu-img`.
  41.  
  42. ```bash
  43. $ qemu-img -f raw -O qcow2 clone.img clone.qcow2
  44. ```
  45.  
  46. And that's it.
Add Comment
Please, Sign In to add comment