Gentoo Archives: gentoo-user

From: R0b0t1 <r030t1@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] QEMU on a partition
Date: Fri, 02 Mar 2018 15:33:12
Message-Id: CAAD4mYiB_n2a=ixT9N2byZt7B3tA+9ajJjRmiHhA4irjz1aDUw@mail.gmail.com
In Reply to: Re: [gentoo-user] QEMU on a partition by Mick
1 On Fri, Mar 2, 2018 at 9:00 AM, Mick <michaelkintzios@×××××.com> wrote:
2 > On Friday, 2 March 2018 11:34:09 GMT Peter Humphrey wrote:
3 >> On Friday, 2 March 2018 11:12:36 GMT Helmut Jarausch wrote:
4 >> > Hi,
5 >> >
6 >> > I'd like to install a second Gentoo system on a partition by running
7 >> > QEMU using that partition (directly) - this is to create and update a
8 >> > Gentoo
9 >> > system with different CFLAGS (for an older machine).
10 >
11 > The QEMU guest's complete filesystem is contained within a *virtual* disk
12 > image. As far as the host OS is concerned, the guest's disk with all
13 > partitions on it, is a file. You can store this image file wherever you want
14 > and map the QEMU on the host to launch it.
15 >
16
17 You can pass a block device directly to QEMU, and this is recommended
18 for performance reasons. I have a Windows 10 VM that was passed an
19 entire SSD; it runs fine, and you can take the disk and plug it into
20 other computers. Passing a partition is a little different, if you
21 wish to load it directly, you would need to chainload it with GRUB, as
22 the MBR/GPT information would be duplicated.
23
24 All OP needs to do is pass something like "-drive
25 file=/dev/block,if=virtio". There should be more options, such as AIO
26 implementation, but you likely won't need to mess with them.
27
28
29 >
30 >> > Having no experience in such setups my initial problem is how to
31 >> > install grub2 on that partition (only). I don't want to modify the MBR
32 >> > of the whole drive containing that partition.
33 >
34 > You do not install the guest's GRUB or any other boot loader on the host's
35 > partition. You install it within the virtual disk after you have launched the
36 > guest having attached a LiveCD to it, using QEMU.
37 >
38
39 If you pass a block device the MBR/GPT information will be stored
40 there. In the case of passing a partition, this means you can't boot
41 it "directly" because the BIOS/EFI firmware can't read it.
42
43 >
44 >> I do the same for my Atom machine by NFS-exporting its /usr/portage to a
45 >> chroot on my main machine. The question of booting doesn't arise; all that's
46 >> needed is a copy of /etc/portage* and the world file. If that sounds
47 >> interesting I can show you some more detail.
48 >>
49 >> * Things like -march and --jobs differ to suit the host machine, but that's
50 >> about all.
51 >
52 > As noted above you'll need to set up CFLAGS in the guest's make.conf file to
53 > suit the *guest* platform and its CPU. Setting up "-march=native" won't work
54 > here.
55 >
56
57 QEMU should, by default, emulate the host processor exactly if your
58 machine has VT-x. The VM runs directly on the processor and all
59 instructions are available except the virtualization ones, but you can
60 enable nested VT-x or the AMD equivalent.
61
62 Cheers,
63 R0b0t1

Replies

Subject Author
Re: [gentoo-user] QEMU on a partition Mick <michaelkintzios@×××××.com>
Re: [gentoo-user] QEMU on a partition Grant Taylor <gtaylor@×××××××××××××××××××××.net>