You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

(Server A) /dev/sda → (Server B) disk.qcow2


A # lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                         8:0    0 446.6G  0 disk
├─sda1                      8:1    0     1M  0 part
├─sda2                      8:2    0     1G  0 part /boot
└─sda3                      8:3    0 445.6G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0   200G  0 lvm  /

A # df -h
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv  196G   26G  161G  14% /
/dev/sda2                          976M  150M  760M  17% /boot


B # dnf install -y pv libnbd

B # qemu-img create -f qcow2 disk.qcow2 500G
Formatting 'disk.qcow2', fmt=qcow2 size=536870912000 cluster_size=65536 lazy_refcounts=off refcount_bits=16

B # ls -alh disk.qcow2
200K    disk.qcow2

B # ssh root@remote "dd if=/dev/sda bs=256M | gzip -1 -" | gzip -d | pv | nbdcopy -- - [ qemu-nbd -f qcow2 --detect-zeroes=on --discard=on disk.qcow2 ]
 21GiB 0:04:33 [36.9MiB/s]
446GiB 0:45:30 [ 167MiB/s]

B # virt-filesystems -l -h -a disk.qcow2
Name                      Type        VFS   Label  Size  Parent
/dev/sda2                 filesystem  ext4  -      1.0G  -
/dev/ubuntu-vg/ubuntu-lv  filesystem  ext4  -      200G  -


참고

How to dd a remote disk using SSH on local machine and save to a local disk - https://unix.stackexchange.com/questions/132797

Download / Upload a Disk over SSH - https://www.linode.com/docs/guides/copying-a-disk-image-over-ssh/

Did qemu-img support stdin/stdout? - https://www.mail-archive.com/qemu-discuss@nongnu.org/msg05177.html

Manuals

https://linux.die.net/man/1/pv

https://www.mankier.com/8/qemu-nbd

https://libguestfs.org/nbdcopy.1.html

  • No labels