New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install grub in template's root.img #2577

Closed
marmarek opened this Issue Jan 14, 2017 · 4 comments

Comments

Projects
None yet
1 participant
@marmarek
Member

marmarek commented Jan 14, 2017

This is required to boot a template (or an AppVM based on it) as HVM - #2185 .
In our current root.img layout there is no partition table and not enough space before filesystem start, so it's tricky to get grub working there. Technically it's possible using not-recommended "blocklist" method, but better add a partition table and move filesystem to the first partition, leaving enough space before for grub.

Another issue is that grub don't like dm-linear (if not set through LVM) and fail to resolve /dev/mapper/dmroot.

A checklist:

  • move filesystem to a partition (template builder) - do this optionally, to still support building old template formats
  • actually install grub there
  • look for root filesystem on the first partition (while constructing dmroot in initramfs)
  • adjust fstab if needed
  • adjust /etc/default/grub to disable disk UUID usage - it's unreliable when filesystem will be visible as both /dev/xvda1 (possibly read-only device) and /dev/mapper/dmroot (always read-write device - in AppVM with a CoW layer)
@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Jan 14, 2017

Member

As for grub not liking /dev/mapper/dmroot - since in TemplateVM (where grub will be installed) /dev/xvda (and /dev/xvda1) is read-write, maybe we should mount this one directly, instead of /dev/mapper/dmroot? The problem is it will not match root= parameter nor /etc/fstab (and we can't change those, as it will also affect AppVM - where dmroot should still be used). But maybe it isn't a problem?

Member

marmarek commented Jan 14, 2017

As for grub not liking /dev/mapper/dmroot - since in TemplateVM (where grub will be installed) /dev/xvda (and /dev/xvda1) is read-write, maybe we should mount this one directly, instead of /dev/mapper/dmroot? The problem is it will not match root= parameter nor /etc/fstab (and we can't change those, as it will also affect AppVM - where dmroot should still be used). But maybe it isn't a problem?

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Jan 14, 2017

Member

Interesting thing - when /dev/mapper/dmroot is set using dm-linear on /dev/xvda1 (with offset 0), grub2-install fails (at least on Fedora 23). But if it's dm-linear on /dev/xvda (with offset pointing at the first partition - 2048), then it's ok. Very strange. And also dmroot setup looks much more non-obvious than before :/

Member

marmarek commented Jan 14, 2017

Interesting thing - when /dev/mapper/dmroot is set using dm-linear on /dev/xvda1 (with offset 0), grub2-install fails (at least on Fedora 23). But if it's dm-linear on /dev/xvda (with offset pointing at the first partition - 2048), then it's ok. Very strange. And also dmroot setup looks much more non-obvious than before :/

marmarek added a commit to marmarek/qubes-linux-utils that referenced this issue Jan 23, 2017

initramfs: move qubes_cow_setup hook to pre-trigger
This hook require new device nodes to appear in /dev. If devtmpfs is
used, it's not a problem ("simple" initramfs case), but otherwise udevd
is needed - and it isn't running in pre-udev hook yet.

QubesOS/qubes-issues#2577

marmarek added a commit to marmarek/qubes-linux-utils that referenced this issue Jan 23, 2017

initramfs: add support for root.img with partition table
Installing grub on root.img require some space before the filesystem.
Create it by adding partition table to root.img. This commit take care
of assembling dmroot device when such partition table is present, while
preserving compatibility with partition-less images.

QubesOS/qubes-issues#2577

marmarek added a commit to marmarek/qubes-linux-utils that referenced this issue Feb 27, 2017

initramfs: move qubes_cow_setup hook to pre-trigger
This hook require new device nodes to appear in /dev. If devtmpfs is
used, it's not a problem ("simple" initramfs case), but otherwise udevd
is needed - and it isn't running in pre-udev hook yet.

QubesOS/qubes-issues#2577

marmarek added a commit to marmarek/qubes-linux-utils that referenced this issue Feb 27, 2017

initramfs: add support for root.img with partition table
Installing grub on root.img require some space before the filesystem.
Create it by adding partition table to root.img. This commit take care
of assembling dmroot device when such partition table is present, while
preserving compatibility with partition-less images.

QubesOS/qubes-issues#2577

marmarek added a commit to marmarek/qubes-linux-utils that referenced this issue Apr 8, 2017

initramfs: move qubes_cow_setup hook to pre-trigger
This hook require new device nodes to appear in /dev. If devtmpfs is
used, it's not a problem ("simple" initramfs case), but otherwise udevd
is needed - and it isn't running in pre-udev hook yet.

QubesOS/qubes-issues#2577

marmarek added a commit to marmarek/qubes-linux-utils that referenced this issue Apr 8, 2017

initramfs: add support for root.img with partition table
Installing grub on root.img require some space before the filesystem.
Create it by adding partition table to root.img. This commit take care
of assembling dmroot device when such partition table is present, while
preserving compatibility with partition-less images.

QubesOS/qubes-issues#2577

@qubesos-bot qubesos-bot referenced this issue in QubesOS/updates-status Apr 9, 2017

Closed

linux-utils v4.0.0 (r4.0) #32

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Jun 2, 2017

Member

In preparation for PVHv2 it may be good idea to create also GPT and ESP (/boot/efi) - http://markmail.org/message/5ycdxlta2j77ttz2

Member

marmarek commented Jun 2, 2017

In preparation for PVHv2 it may be good idea to create also GPT and ESP (/boot/efi) - http://markmail.org/message/5ycdxlta2j77ttz2

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Jun 7, 2017

Member

And maybe instead of installing grub (i386) there, use UEFI to load VM-provided kernel, right now (i.e. even before real PVHv2)? This would greatly simplify VM setup, and maybe also slightly improve startup time. At the cost of slightly more complex stubdomain - need to load ovmf instead of seabios.
This approach would mean the same template layout for both pre-PVHv2 and PVHv2 templates.

Member

marmarek commented Jun 7, 2017

And maybe instead of installing grub (i386) there, use UEFI to load VM-provided kernel, right now (i.e. even before real PVHv2)? This would greatly simplify VM setup, and maybe also slightly improve startup time. At the cost of slightly more complex stubdomain - need to load ovmf instead of seabios.
This approach would mean the same template layout for both pre-PVHv2 and PVHv2 templates.

@marmarek marmarek referenced this issue Jun 7, 2017

Open

Stubdomain related bugs/todos #2849

4 of 6 tasks complete

marmarek added a commit to marmarek/old-qubes-core-agent-linux that referenced this issue Jun 14, 2017

Ship grub configuration
Qubes VM require few config options in grub. Ship appropriate
configuration. Debian have grub.d support, so it can be done cleanly.
On Fedora, /etc/default/grub needs to be modified. Still keep the
options in separate file, but include it manually from
/etc/default/grub.

QubesOS/qubes-issues#2577

marmarek added a commit to marmarek/qubes-builder-rpm that referenced this issue Jun 14, 2017

marmarek added a commit to marmarek/qubes-linux-template-builder that referenced this issue Jun 14, 2017

Add support for template with partition table on root.img
When TEMPLATE_ROOT_WITH_PARTITIONS is set, include (GPT) partition table
and install actual OS on the first one. This allows installing grub, or
other bootloader.

Fixes QubesOS/qubes-issues#2577

marmarek added a commit to marmarek/qubes-builder-debian that referenced this issue Jun 14, 2017

WIP Install grub when root.img have partitions
When TEMPLATE_ROOT_WITH_PARTITIONS=1, install grub on the root.img

WIP: This doesn't work yet - template do not boot, wait in "grub rescue"
mode, failing to find a device with some UUID.

QubesOS/qubes-issues#2577

marmarek added a commit to marmarek/qubes-builder that referenced this issue Jun 14, 2017

marmarek added a commit to marmarek/old-qubes-core-agent-linux that referenced this issue Jun 21, 2017

Update grub configuration
This configuration isn't included twice - it's Debian post-installation
script of grub that copy settings to /etc/default/grub, which results in
parameters being duplicated. Leave it as is for now.

Add GRUB_TIMEOUT=0 for faster VM startup.

QubesOS/qubes-issues#2577

marmarek added a commit to marmarek/qubes-builder-debian that referenced this issue Jun 24, 2017

Install grub when root.img have partitions
When TEMPLATE_ROOT_WITH_PARTITIONS=1, install grub on the root.img

QubesOS/qubes-issues#2577

@qubesos-bot qubesos-bot referenced this issue in QubesOS/updates-status Jun 24, 2017

Closed

core-agent-linux v4.0.2 (r4.0) #86

marmarek added a commit to marmarek/qubes-builder-rpm that referenced this issue Jun 24, 2017

marmarek added a commit to marmarek/qubes-builder-rpm that referenced this issue Jul 5, 2017

template: do not mount modules.img when booting VM-provided kernel
Mounting /lib/modules/$(uname -r) from dom0 is not needed when the
kernel is provided by the VM itself. In fact this script would do
nothing in such a case anyway.

QubesOS/qubes-issues#2577

marmarek added a commit to marmarek/qubes-linux-utils that referenced this issue Sep 24, 2017

initramfs: move qubes_cow_setup hook to pre-trigger
This hook require new device nodes to appear in /dev. If devtmpfs is
used, it's not a problem ("simple" initramfs case), but otherwise udevd
is needed - and it isn't running in pre-udev hook yet.

QubesOS/qubes-issues#2577

(cherry picked from commit 5c7c54a)

@qubesos-bot qubesos-bot referenced this issue in QubesOS/updates-status Sep 24, 2017

Closed

linux-utils v3.2.5 (r3.2) #222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment