Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
New Gentoo in qemu: Format vda as partition instead of disk
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2549

PostPosted: Fri Jan 22, 2016 3:22 am    Post subject: New Gentoo in qemu: Format vda as partition instead of disk Reply with quote

Hi,

I'm installing a new gentoo guest on a gentoo host. I want it to be really simple, meaning one partition if I can manage it.

I have an lvm volume on the host as the disk storage. It shows up in the guest as /dev/vda.

It would be awesome if I could simply format that as ext4 and go, rather than formatting it as a separate disk.

The host is UEFI boot, if it's simple to do this with the guest then I'm fine with that. Only then I'll need a separate partition, which blows my whole plan out of the water unless I can allocate another small LVM volume just for that?

Thanks.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43178
Location: 56N 3W

PostPosted: Fri Jan 22, 2016 8:23 pm    Post subject: Reply with quote

1clue,

If you format the whole volume, there is nowhere for a partition table.
That upsets BIOS and bootloaders.

With EFI, it might work for booting but you would be stuck with VFAT
VFAT does not support symlinks, *NIX permissions and so on so you could not install *NIX there.

In my KVMs I donate a logical volume from the host as storage for the KVM then use it as a disk.
There is no host file system on the logical volume, so overhead is minimal.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2549

PostPosted: Fri Jan 22, 2016 8:59 pm    Post subject: Reply with quote

That's not the answer I was hoping for but it is the one I expected. Thanks.
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2549

PostPosted: Fri Jan 22, 2016 9:00 pm    Post subject: Reply with quote

So with a uefi host, is it better to stick with uefi guests too?
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1746

PostPosted: Fri Jan 22, 2016 10:11 pm    Post subject: Reply with quote

Quote:
It would be awesome if I could simply format that as ext4 and go, rather than formatting it as a separate disk.
So... You want to use the whole device rather than partition it. Well, considering you're making a VM, there is really no reason not to do that. At least as long as you can boot.

A few tricks you might like:
* PXE boot
* separate, reusable boot drive image (you might only need one kernel for all the machines and attach different systems to them)
* direct linux boot. Provide the paths to kernel and initramfs on qemu's command line. I happened to boot from /dev/null this way.

Quote:
So with a uefi host, is it better to stick with uefi guests too?
No, it's not related. It was a cheat avoiding running bootloader without partition table. And you'd have to patch qemu yourself, AFAIR UEFI has never been merged.

Skipping the partition table will only save you one MB so it's nothing in terms of space, but it has another advantage: it's easier to mount at the host.
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2549

PostPosted: Fri Jan 22, 2016 10:28 pm    Post subject: Reply with quote

I might play with this direct linux boot.

I just wish I could have a partition that could be mounted by the host as well as the guest.

And another thing, I thought Gentoo's minimal iso would support virtio drivers by now. :x
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1746

PostPosted: Sat Jan 23, 2016 10:41 am    Post subject: Reply with quote

Yes, you can mount it at your host. In fact it's a part of the building process, which means there is no use for minimal iso at all.
You can build everything with your host, copy it into a drive image (yes, yes, just formatted, without partition table), and then _JUST_ boot the VM with
-kernel <path to kernel> [-initrd <path to initramfs>] -drive file=<path to disk image>,cache=none,if=virtio
Heh, gotta get myself together and finally write a script for building this stuff. Preferably a usable one this time, rather than a prototype :lol:

Ah, there is also virtfs available in qemu. Never tried it, but it looks promising in term of your desire to mount some things at guest and host.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43178
Location: 56N 3W

PostPosted: Sat Jan 23, 2016 10:50 am    Post subject: Reply with quote

1clue,

At the host, a partitioned logical volume looks like a partitioned drive.
You can mount the individual partitions with the offset= parameter to mount.

You can probably use losetup to scan the host logical volume for partitions, then mount them.
Warning - losetup did not work with GPT last time I tried.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2549

PostPosted: Sun Jan 24, 2016 2:57 am    Post subject: Reply with quote

Hmm. I'll still need a kernel because one of the guests will be a linux advanced router. Another will be pfSense. They'll be nested.

It occurs to me that since my /usr/src is a separate volume I can share it across vms. Contemplating having portage directories be shared too. I'll need to do some cleanup.

This is really interesting. I've never colored outside the lines with kvm before.
Back to top
View user's profile Send private message
TigerJr
Guru
Guru


Joined: 19 Jun 2007
Posts: 504
Location: /dev/x0

PostPosted: Sun Jan 24, 2016 7:01 am    Post subject: Reply with quote

szatox wrote:
then _JUST_ boot the VM with
-kernel <path to kernel> [-initrd <path to initramfs>] -drive file=<path to disk image>,cache=none,if=virtio


Don't you think that you need to use paravirtual kernel for that with all things of paravirtualization drivers and pvgrub bootloader?

NeddySeagoon wrote:

You can probably use losetup to scan the host logical volume for partitions, then mount them.
Warning - losetup did not work with GPT last time I tried.


losetup is a good thing - you can mount qcow2 format in filesystem(i mounted file with gpt partition not long ago), or you can use raw format and mount raw file in another filesystem with simple
Code:
mount -t ext4 -o loop gentoo-image.raw /mnt/gentoo
like loop fs
_________________

Do not update portage without hotdog!

Xenogentooway?
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1746

PostPosted: Sun Jan 24, 2016 10:13 am    Post subject: Reply with quote

Quote:
Don't you think that you need to use paravirtual kernel for that with all things of paravirtualization drivers and pvgrub bootloader?
Of course, if you want to use virtio you need suport for virtio. Still you don't have to build that kernel _inside_ the VM. You can do that on host, and using direct boot you don't even have to copy it into the system image. Kernel, initramfs and userland (disk image) are separate files in this case. Unless you rely on modules loaded after leaving initramfs, which requires you to copy modules into userland. It's possible to completely avoid it though.

Quote:
It occurs to me that since my /usr/src is a separate volume I can share it across vms.
You don't need /usr/src inside your VMs. In fact, /usr/portage and the Gentoo toolchain are not necessary either (though having them might be more comfortable for you).
Virtual machine is not a physical one. Physical servers exist only when they are powered on. For virtual it's no longer true. You don't need the guest OS to provide you access to the assigned resources: you can just as well ask the host OS for that even when guest is powered off. Use it to your advantage :)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43178
Location: 56N 3W

PostPosted: Sun Jan 24, 2016 10:28 am    Post subject: Reply with quote

szatox,

szatox wrote:
You don't need /usr/src inside your VMs. In fact, /usr/portage and the Gentoo toolchain are not necessary either ... Physical servers exist only when they are powered on. For virtual it's no longer true.


Thank you ... that will be an interesting thing to play with next time I set up a KVM box.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2549

PostPosted: Mon Jan 25, 2016 1:29 am    Post subject: Reply with quote

My guests will not have the same kernel or the same @world as the host. That's why I have VMs instead of everything on one box.

I love the idea of sharing the large volume bits if I can, but not if I have to have a VM exactly the same as the host. I'm perfectly fine having one /usr/src, I'm perfectly fine with a unified /usr/portage, I'm definitely interested in sharing anything that will always be the same on any up-to-date Gentoo box. I will need to keep each compiled kernel and each @world and USEs separate.

I've been using VMware and Parallels in my job for about 15 years now. I've occasionally used KVM also, both personally and with my job. But I've never used LVM storage for it, and I've never tried anything fancy like what we're talking about here.

I was going to try to set up the host with distcc and have the guests just borrow the host cores, so to speak. Still think that might be a good way to go, all things considered.

This is all pretty heavy stuff for me, I'm going to need to digest it and plan things out. Again.

Thanks.
Back to top
View user's profile Send private message
TigerJr
Guru
Guru


Joined: 19 Jun 2007
Posts: 504
Location: /dev/x0

PostPosted: Mon Jan 25, 2016 6:17 am    Post subject: Reply with quote

1clue wrote:

I've been using VMware and Parallels in my job for about 15 years now. I've occasionally used KVM also, both personally and with my job. But I've never used LVM storage for it, and I've never tried anything fancy like what we're talking about here.


I didn't use parallels, but working with VMware. I think that VMware didn't work with lvm, but can use ISCSI FCoE NFS CIFS and can't use another disk formats(qcow2) only vmdk.
_________________

Do not update portage without hotdog!

Xenogentooway?
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2549

PostPosted: Mon Jan 25, 2016 5:23 pm    Post subject: Reply with quote

What's the best way to have a partition open r/w in both the host and the guest simultaneously?

VMware just doesn't support this, period. Parallels lets you share drives, folders whatever. Do I need to set up an nfs share or can I do it with something easier and faster?

Thanks.
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1746

PostPosted: Mon Jan 25, 2016 5:50 pm    Post subject: Reply with quote

3 ways:
1) use clustered FS that allows you actively using a single volumes from 2 machines at the same time
2) use file-level protocol like NFS or virtfs
3) dont-do-that-for-anything-of-any-importance-at-all flush buffers at guest before you acess from host, flush buffers at host before you access from guest.
Back to top
View user's profile Send private message
TigerJr
Guru
Guru


Joined: 19 Jun 2007
Posts: 504
Location: /dev/x0

PostPosted: Tue Jan 26, 2016 9:02 am    Post subject: Reply with quote

1clue wrote:
What's the best way to have a partition open r/w in both the host and the guest simultaneously?

VMware just doesn't support this, period. Parallels lets you share drives, folders whatever. Do I need to set up an nfs share or can I do it with something easier and faster?

Thanks.


Host can boot only from iSCSI or FCoE due to the protocols limitation, but guest can boot from CIFS, NFS, iSCSI, FCoE .

NFS have bonus with easy resizing.
CIFS easier to setup than NFS but iSCSI and FCoE is faster.
iSCSI can rise latency and CPU usage due a network errors, packet encapsulation, network overload and speed would be lower.
FCoE need 10gb\s network adapter with jumbo frames support.
_________________

Do not update portage without hotdog!

Xenogentooway?
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5761

PostPosted: Mon Feb 01, 2016 5:52 pm    Post subject: Reply with quote

1clue wrote:
What's the best way to have a partition open r/w in both the host and the guest simultaneously?

VMware just doesn't support this, period. Parallels lets you share drives, folders whatever. Do I need to set up an nfs share or can I do it with something easier and faster?

Thanks.

Your best bet would be 9pfs, which qemu has special support for: http://wiki.qemu.org/Documentation/9psetup

I have my portage things netmounted via sshfs-fuse, that's also an option (though needlessly inefficient in a VM setup).
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2549

PostPosted: Thu Feb 04, 2016 5:42 pm    Post subject: Reply with quote

The 9p option seems to be what I'm after. Thanks.

Gotta recompile my host kernel for this, and had to do it anyway because of new kernel with things I want.

Thanks again everyone!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum