Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 4978  / 1 Year ago, thu, april 27, 2023, 7:44:06

I have a server running Ubuntu 10.04. As I want to test some maintenance work, such as upgrading to 12.04, I thought I should create a VM copy of the server using Virtual Box. I don't have a physical access to the server, so I considered the following options: I do




  • dd'ing the entire hard disk to a raw image on my pc and then creating a VDI out of the raw dd image.

  • Installing the same ubuntu version, install update and mount the VDI locally and rsync the filesystem from the server to the mounted VDI creating a logical copy of the server.



The rsync solution is a bit more complicated, but seems to save bandwidth, and allows me to create a "copy" of the server with slightly different configuration (e.g. smaller disk).



What do you think is the best way to do so? One of the above methods? A different one?


More From » server

 Answers
3

Using rsync directly turned out to be more problematic than I first thought:




  1. The command needs to be run as root on the remote machine.

  2. I didn't won't to enable remote root login.

  3. The filesystem in based on LVM and it was a hassle to mount the actual root partition of the VM from inside the LVM in the VDI file.



For these reasons I ended up with a 2 step process:




  1. Copy all the files from the remote machine to the local host machine.

  2. Copy the files to the guest.



I finally went with basic tar, although I could have used rdiffdir provided by duplicity to save some bandwidth.



I started out by setting up an SSH tunnel which I could use to tunnel the tar files so I wouldn't have to write the archive to the filesystem I was copying.



local$ ssh user@remote -R 3000:localhost:3000
loacl$ nc -l 3000 > filesystem.tar.gz
remote$ sudo tar -vcz / --exclude={/dev,/proc,/sys,/tmp} | nc localhost 3000


This created a tar archive of the entire filesystem in my local host machine. The next step was to untar it on the guest:



guest$ cd /
guest$ nc -l 3000 | sudo tar -xvz
local$ nc guest_ip 3000 < filesystem.tar.gz


In my case /etc/fstab referenced filesystems by their UUIDs, so I had to update it with the output of guest$ sudo blkid. I also had to update the networking settings in /etc/udev/rules.d/70-persistent-net.rules (interface names) and /etc/network/interfaces (ip addresses).


[#33480] Friday, April 28, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sator

Total Points: 258
Total Questions: 119
Total Answers: 101

Location: Sweden
Member since Fri, Apr 16, 2021
3 Years ago
;