Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Disk Clone With Linux dd Command
- --------------------------------
- Recently I decided to do a disk clone from one of my homelab servers that was
- running Ubuntu 16.04 LTS so I could install Gentoo on it.This guide shows the
- steps I took to get my disk cloned.
- Get the disk information
- ------------------------
- Before I could start the clonning process;I had to get disk block information
- using `lsblk`.
- ```
- $ lsblk
- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
- sr0 11:0 1 1024M 0 rom
- xvda 202:0 0 30G 0 disk
- ├─xvda1 202:1 0 487M 0 part /boot
- ├─xvda2 202:2 0 1K 0 part
- └─xvda5 202:5 0 29.5G 0 part
- ├─owl--vg-root 252:0 0 27.4G 0 lvm /
- └─owl--vg-swap_1 252:1 0 2.1G 0 lvm [SWAP]
- ```
- My disk of interest was `xvda` that has lvm partions.
- Clonning the disk
- -----------------
- The cloned disk needed to be stored to another server so I had to pipe the
- result of the `dd` command to `ssh`.
- ```bash
- $ dd if=/dev/xvda | ssh xvf@storage.local "sudo dd of=~/clone.img status=progress"
- ```
- The above command clone the disk `/dev/xvda` to `clone.img` on my other server.
- Once the process had finished I loaded the image with `kvm` to test if
- everything is ok.The process was successfully since I managed to boot the image
- with no error.
- I prefer working with `qcow2` format instead of the `raw` so I had to do an
- image convertion using `qemu-img`.
- ```bash
- $ qemu-img -f raw -O qcow2 clone.img clone.qcow2
- ```
- And that's it.
Add Comment
Please, Sign In to add comment