If you have network access from your live CD boot, you should be able to do something like this:
get a root shell in the Live CD running on the VirtualBox VM
partition and format the virtual disks however you want. If LVM tools are on the Live CD you can even use LVM.
run mkdir -p /target
mount your intended rootfs on /target, make directories for any mount-points (e.g. /target/home, /target/var, etc) and mount the appropriate partitions.
cd /target
rsync -a --exclude proc/** --exclude sys/** --exclude dev/** root@remoteVM:/ ./
(that rsync command might need to be fine-tuned. run with --dry-run
option until it's just right)
for i in dev dev/pts proc sys ; do mount -o bind /$i /target/$i ; done
chroot /target
.
edit /etc/fstab
and /etc/default/grub
as needed to suit the new system.
update-grub
exit
unmount /target and everything under it (including the bind mounts above)
reboot.
Alternatively, instead of rsync
, you can use tar
to backup the remote VM's filesystems and put the tar.gz files somewhere you can get at from the Live CD. exclude /proc, /dev, and /sys directories from the backup.
Note: if you're running mysql or postgres or anything that writes to db files or other non- plain-text files, you'll want to shut down those services before the rsync
. running a database backup to dump all dbs to text is also a good idea.
writes to plain text files (e.g. log files) during the rsync aren't so risky, if you don't mind losing any log entries that occurred after you ran the rsync....at least there won't be any file corruption possible.
systemd's journal is binary. so if you're running systemd you'll need to shutdown journald to avoid corruption. I have no idea if that's even possible without shutting down the system.