View previous topic :: View next topic |
Author |
Message |
adrelanos n00b
Joined: 11 Dec 2014 Posts: 6
|
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3136
|
Posted: Sat Jan 10, 2015 8:08 pm Post subject: |
|
|
I've been looking for a similar tool.
To make me happy it must:
- be easy and quick to run
- provide up-to-date system
- not require agent inside OS to be assembled.
So far I'm fairly happy about portage for the hard part - building up-to-date image - even though I'm still figuring it out.
Anyway, here what I have right now:
build directory contains:
etc/portage/ target/
etc/portage is there to let me have different keywords, use and mask atributes than host.
Components necessary to create a new system image:
- baselayout (USE build - important)
- stuff you want to have installed
optionaly:
- kernel (copy from host's /boot - or prepare dedicated kernel image on host. I'm not going to recompile it inside VM anyway )
to build new system use:
emerge -bk --config-root=./ --root=target/ baselayout <desired stuff>
Notice: the created system will not be self-sufficient. There will be no portage, no headers, etc. Just a single-purposed dummy.
Anyway, after emerge completes, it would be handy to tune configs a bit. E.g. creating users, changing passwords or enabling serial console. Probably sed or patch would do the trick.
Now, there are many ways to stuff that system into a VM. Raw image is one (reasonably easy to prepare), PXE is another (even easier, once you have all servers set up), qemu also supports direct boot, never tried it but there might not be any need to stuff it into an image at all. This being said, i'm gonna yet figure out what way of booting will be the most convenient. Qcow is interesting as it provides snapshots and live migration (also migration to a file, so we can dump the whole running VM to disk) |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Sat Jan 10, 2015 11:07 pm Post subject: |
|
|
You don't need distro-specific hacks to do this with Gentoo - just create the VM disk image, partition and mount it using qemu-nbd, then do a normal chroot install. (You could also try a non-chroot install from the host using the $ROOT variable, but that's undocumented.) |
|
Back to top |
|
|
adrelanos n00b
Joined: 11 Dec 2014 Posts: 6
|
Posted: Sat Jan 10, 2015 11:29 pm Post subject: |
|
|
Ant P. wrote: | You don't need distro-specific hacks to do this with Gentoo |
You don't need tools to do this for other distributions either. At least not for Debian centric ones. Those tools are in essence just scripts do only things that one could manually do as well.
Ant P. wrote: | just create the VM disk image, partition and mount it using qemu-nbd, then do a normal chroot install. |
Partitioning and making the image grub bootable is non-trivial - at least for me. With the apparent absence of instructions for doing so, and without spending at least a few hours looking how other tools are doing and and replicating this, I couldn't do it. Hence, I asked if there is any existing automation for it. Also to prevent duplicating work. _________________ ... |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3136
|
Posted: Sun Jan 11, 2015 10:00 am Post subject: |
|
|
Ah, so that's the problem for you. Ok, here's a tip on turning filesystems into images:
Quote: | dd if=/dev/zero of=vmimage.img bs=50M count=200 # create roughly 10 GB empty file using 50MB buffer
mkfs.ext2 vmimage.img # format file with ext2, you can use any other format if you like it more
mkdir vmimage
mount -o loop vmimage.img vmimage # mount image so you can access and modify it's content
rsync -av <path to root directory of the filesystem you want inside the image> vmimage
umount vmimage
|
the bold line is the tricky part the rest goes pretty much the same way handbook describes it. Including installing grub. You launch it the very same way you would on any other device\
I wonder if anyone has a better way to build the system from outside. I mean, better than mine, described earlier, with emerge (which is not good enough mostly because it's not yet complete) |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Sun Jan 11, 2015 11:42 am Post subject: |
|
|
szatox,
You can even chroot into the image to install your boot loader so it just works when you boot the VM. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
Progman3K l33t
Joined: 03 Jan 2004 Posts: 773
|
Posted: Thu Jan 29, 2015 8:53 pm Post subject: |
|
|
NeddySeagoon wrote: | szatox,
You can even chroot into the image to install your boot loader so it just works when you boot the VM. |
How would you do that if you were hosting an arm VM inside an amd64 host?
Thanks for your insight |
|
Back to top |
|
|
KaZeR Apprentice
Joined: 04 Feb 2004 Posts: 291 Location: Au fond, à droite.
|
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Fri Jan 30, 2015 9:29 pm Post subject: |
|
|
Progman3K,
You can't use grub on ARM, its full of Intel 16 bit (real mode) and 32 bit asm.
However qemu can emulate ARM, so you can do any steps that need to be done inside the VM in qemu.
It will be slow but it still works. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
Progman3K l33t
Joined: 03 Jan 2004 Posts: 773
|
Posted: Thu Feb 05, 2015 9:36 pm Post subject: |
|
|
NeddySeagoon wrote: | Progman3K,
You can't use grub on ARM, its full of Intel 16 bit (real mode) and 32 bit asm.
However qemu can emulate ARM, so you can do any steps that need to be done inside the VM in qemu.
It will be slow but it still works. |
Thanks for saving me the time trying to get it to compile for arm, NeddySeagoon!
I am trying to get a qemu (aqemu) arm vm operational but I'm having problems getting the networking to function. |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3136
|
Posted: Fri Feb 06, 2015 8:13 pm Post subject: |
|
|
What about easy mode AKA user mode?
Don't provide any params regarding networking, it should use some defaults allowing your guest OS access the internet the same way any application could. You won't be able to access guest os from your pc, but this often is a minor problem. |
|
Back to top |
|
|
|