By shkitch
Hello,
I have an existing (physical) linux server that I’d like to migrate (virtualize) into a droplet. Since the server contains lots of services (mail, webmail, etc) I’d like to make this migration process as easy/fast as possible. Or in other words: I don’t want to migrate service-by-service.
When moving from one physical server to another, I used to do it this way:
Can something similar be done with Droplets, too? I’m guessing that just extracting the rootfs archive on a working Droplet spells disaster, right?
Bottom line: what is the suggested/preferred way to do this?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This question was answered by @shkitch:
Ok,
I’ll just answer this for myself.
I ssh’d into the droplet and made a /rootfs directory. There be all the important filez.
I targz’d the (stock) droplet root filesystem (without the kernel mountpoints such as /dev, /proc, /sys) and stored the targz archive under /rootfs/stock-droplet.tgz
then, I extracted /rootfs/stock-droplet.tgz archive to /rootfs/stock-droplet. You’ll see why.
I made a targz archive of the source server filesystem, transferred it to the droplet (to /rootfs/source-server.tgz), and extracted it to /rootfs/source-server. You’ll see why.
then, I booted the droplet with the recovery kernel. Instructions on how to do this are here: https://www.digitalocean.com/community/tutorials/how-to-recover-from-file-system-corruption-using-fsck-and-a-recovery-iso
“mkdir /target”
I mounted the droplet’s root filesystem from the recovery kernel (initramfs) under /target. Instructions on how to do this are given in the link above, too. Note that the extracting in the previos steps is mandatory because the recovery initramfs image doesn’t have neither tar nor gzip!
then, I removed pretty much everything from the targets’s root filesystem (rm -rf /target/{usr,lib*,bin,sbin,etc} …), leaving only th stuff in /target/boot, some empty mountpoints such as /target/{tmp,run,dev,proc,sys}, and of course /target/root and /target/rootfs
I copied the important stuff from the source server’s root filesystem to the target root filesystem (e.g. “/target/rootfs/source-server/bin/cp -av /rootfs/source-server/{bin,sbin,usr,var,lib*} /target”)
I copied a few configuration files back from the stock droplet’s root filesystem to the new droplet’s root filesystem (“/target/rootfs/source-server/bin/cp -av /target/rootfs/stock-droplet/etc/networking/interfaces /target/etc/networking”, “/target/rootfs/source-server/bin/cp -av /target/rootfs/stock-droplet/etc/fstab /target/etc”, “/target/rootfs/source-server/bin/cp -av /target/rootfs/stock-droplet/etc/udev/rules.d/* /target/etc/udev/rules.d” )
umount /target, reboot
rejoice!
… hope this works for somebody else, too.
You can see the comment here.
This question was answered by @shkitch:
Ok,
I’ll just answer this for myself.
I ssh’d into the droplet and made a /rootfs directory. There be all the important filez.
I targz’d the (stock) droplet root filesystem (without the kernel mountpoints such as /dev, /proc, /sys) and stored the targz archive under /rootfs/stock-droplet.tgz
then, I extracted /rootfs/stock-droplet.tgz archive to /rootfs/stock-droplet. You’ll see why.
I made a targz archive of the source server filesystem, transferred it to the droplet (to /rootfs/source-server.tgz), and extracted it to /rootfs/source-server. You’ll see why.
then, I booted the droplet with the recovery kernel. Instructions on how to do this are here: https://www.digitalocean.com/community/tutorials/how-to-recover-from-file-system-corruption-using-fsck-and-a-recovery-iso
“mkdir /target”
I mounted the droplet’s root filesystem from the recovery kernel (initramfs) under /target. Instructions on how to do this are given in the link above, too. Note that the extracting in the previos steps is mandatory because the recovery initramfs image doesn’t have neither tar nor gzip!
then, I removed pretty much everything from the targets’s root filesystem (rm -rf /target/{usr,lib*,bin,sbin,etc} …), leaving only th stuff in /target/boot, some empty mountpoints such as /target/{tmp,run,dev,proc,sys}, and of course /target/root and /target/rootfs
I copied the important stuff from the source server’s root filesystem to the target root filesystem (e.g. “/target/rootfs/source-server/bin/cp -av /rootfs/source-server/{bin,sbin,usr,var,lib*} /target”)
I copied a few configuration files back from the stock droplet’s root filesystem to the new droplet’s root filesystem (“/target/rootfs/source-server/bin/cp -av /target/rootfs/stock-droplet/etc/networking/interfaces /target/etc/networking”, “/target/rootfs/source-server/bin/cp -av /target/rootfs/stock-droplet/etc/fstab /target/etc”, “/target/rootfs/source-server/bin/cp -av /target/rootfs/stock-droplet/etc/udev/rules.d/* /target/etc/udev/rules.d” )
umount /target, reboot
rejoice!
… hope this works for somebody else, too.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.