Skip to main content

Importing server using initramfs shell

On donor:

open port on firewall, ideally only to acceptor’s IP.

freeze all filesystems mounted on local disk:

mount / -o remount,ro or echo u > /proc/sysrq-trigger

start fake HTTP server:

(printf ‘HTTP/1.0 200 OK’; cat /dev/sda) | pv | nc -l -p 1234

On acceptor:

/etc/default/grub change GRUB_TIMEOUT to 10

update-grub

note ip address, netmask, gateway

reboot

open KVM console

enter bootloader, edit options, add break=premount to command line

manually add ip address, netmask, gateway

but initramfs in Ubuntu doesn’t have netcat, so…

wget -O /dev/sda http://DONOR:1234

reboot

should work

Security considerations:

if doing it between VPSes in the same server room and everything is in well-protected network, then nothing to worry about, as VPS provider has access to all the content of the disk anyway.

Otherwise: verify sha512sum before reboot, revoke & regenerate keypairs