3

Linux newbie here. I am connecting to the machine from a Mac via SSH. Would someone be able to tell me the best process for converting the already running Linux machine to a Virtual machine to be used in ESXI? Running Ubuntu Server 16.04.2 LTS with a RAID connected as shown below:

 Filesystem      Size  Used Avail Use% Mounted on
 udev            1.9G     0  1.9G   0% /dev
 tmpfs           393M   23M  371M   6% /run
 /dev/sdg2       1.8T   12G  1.7T   1% /
 tmpfs           2.0G     0  2.0G   0% /dev/shm
 tmpfs           5.0M     0  5.0M   0% /run/lock
 tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
 /dev/loop0      161M  161M     0 100% /snap/nextcloud/1337
 /dev/loop1       80M   80M     0 100% /snap/core/1689
 /dev/md0        8.2T  6.5T  1.3T  84% /mnt/raid/samba
 /dev/sdg1       512M  3.4M  509M   1% /boot/efi
 /dev/loop2      179M  179M     0 100% /snap/nextcloud/1474
 tmpfs           393M     0  393M   0% /run/user/1000
 tmpfs           393M     0  393M   0% /run/user/1001

Do I need to convert each of these disks individually? Or is there a way easier process I'm not seeing?

Thank you!

Aaron Kane
  • 31
  • 1
  • 3

1 Answers1

2

Yes, it is possible and not really difficult. You can take the advantage of the UNIX filesystem having a single root, so you don’t need to replicate the structure of mounts, RAID etc. in your copy – the system will behave the same way having all files in a single mount.

I have successfully done the procedure before, my method is based on a guide from https://wiki.archlinux.org/index.php/full_system_backup_with_rsync.

Preconditions

  • enough free space in your home directory on the server to store the whole server contents (compressed)
  • enough free space for both uncompressed + compressed server contents on your local hard drive
  • root access on the server
  • both machines must use a compatible architecture (otherwise you could not run the transferred binaries)

Instructions

  1. Backup the complete server contents. You can use rsync from the linked guide and then compress or do it in a single step. You need sudo to access all the files.

     sudo tar --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","~/server-backup.tar.xz"} -cJvf ~/server-backup.tar.xz /
    
  2. Download the created file using SCP or another suitable method.

  3. Create a VM with a new virtual hard drive with a sufficient capacity. Boot a live distro.

  4. Format and mount the blank hard drive.

  5. Decompress the contents of the compressed backup file to the mounted drive. (You need to make the file available to the VM, e.g. using shared folder or another drive attached to the VM.)

  6. Restore GRUB using the chroot method.

  7. Edit configuration files if necessary (especially /etc/fstab, /etc/network/interfaces).

  8. Shut down the VM, dettach the live distro media and boot your server clone.

Melebius
  • 11,431
  • 9
  • 52
  • 78