Gentoo Archives: gentoo-user

From: "Mickaël Bucas" <mbucas@×××××.com>
To: Gentoo <gentoo-user@l.g.o>
Subject: Re: [gentoo-user] Migrating chroot to VM
Date: Thu, 05 Mar 2020 15:29:54
Message-Id: CAG1=SYRH7bYp=nFb+LCjrpKzgQUqDPdmShxJprP57NWbH21P6A@mail.gmail.com
In Reply to: Re: [gentoo-user] Migrating chroot to VM by Michael
1 Le jeu. 5 mars 2020 à 13:07, Michael <confabulate@××××××××.com> a écrit :
2 >
3 > On Thursday, 5 March 2020 09:54:01 GMT Alessandro Barbieri wrote:
4 > > I want to do a crazy thing. I want to migrate my gentoo installation from a
5 > > chroot to a VM (both on the same host). The host is debian but I can only
6 > > use SSH. What do you suggest to do?
7 >
8 > There are VMWare applications to convert a physical installation of an OS to a
9 > VM disk, but since the guest OS is linux, the way I would do it would be:
10 >
11 > 1. Create a virtual disk of the desired size.
12 > 2. Attach a LiveCD to the VM and boot with it.
13 > 3. Use the LiveCD environment to partition/format/mount the VM disk.
14 > 4. Use rsync to copy the filesystem contents from the chroot to the VM
15 > partitions.
16 > 5. Edit the copied fstab to correspond to the VM disk partition UUIDs and
17 > potentially reinstall GRUB.
18 > 6. Unmount the VM disk partitions, shutdown the VM, detatch the LiveCD and
19 > restart the VM.
20 >
21 > You could use partclone instead of rsync, which would retain the same UUIDs
22 > and filesystems as the chrooted system and therefore simplify the migration.
23 >
24 > HTH.
25
26 As a chroot is not a complete system, you will also have to do some
27 more actions inside the VM
28 - Compile and install a kernel [1], probably with the VMware modules
29 to get better performance.
30 - Tell Grub to include that kernel in the list of boot options [2]
31 - Check that an init system is fully configured, you can choose
32 between OpenRC or SystemD [3]
33 - Configure networking inside the VM [4] and in VMware on the host
34 - Add services like SSH to system start to be able to connect to the VM
35
36 As you can see, this will be a mix of a fresh install and a migration
37 of your chroot. Basically you can read through the Gentoo Handbook to
38 see what steps are necessary for the VM to boot.
39 When you copy the chroot files into the VM they will overwrite files
40 from the Stage3.
41 I believe the best step to do this is just before the "Installing
42 tools" chapter, but their may be side effects I don't anticipate...
43
44 The good thing about a VM is that if anything goes wrong, you just
45 trash it and restart !
46 Tell us how things turn out for you.
47
48 Best regards
49 Mickaël Bucas
50
51 [1] https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel
52 [2] https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Bootloader
53 [3] https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Base
54 [4] https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/System