I'm writing a script that takes a master KVM image, converts it to VDI, makes a few changes to it, and offers it up for download.
I need to update the kernel boot parameters for some of the newly created images. Normally one would edit the GRUB_CMDLINE_LINUX_DEFAULT setting in /etc/default/grub, and then run update-grub. Of course, I can only do this in a chroot, which fails: '/usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).'
Bind mounting /dev from the running system into the chroot allows update-grub to run, but results in a broken grub.cfg (wrong root device from the image's perspective).
If I just use sed to add the kernel parameters I need, it will get the image booting, but subsequent runs of update-grub (from inside the now-running image) will cause trouble.
So my current solution is:
- edit parameters in /etc/default/grub
- bind mount /dev into the chroot
- run update-grub in the chroot
- use sed to fix erroneous device nodes in /boot/grub/grub.cfg
Please tell me there is a better way.