[Vmdebootstrap-devel] Bug#767913: vmdebootstrap: Make room for grub on disk also when --bootsize is used
Petter Reinholdtsen
pere at hungry.com
Mon Nov 3 13:28:47 UTC 2014
Package: vmdebootstrap
Version: 0.4-3
Severity: important
Tags: patch
At the moment it is impossible to combine the --grub and --bootsize
options in vmdebootstrap:
root at tjener:~# vmdebootstrap --distribution=jessie --image=test.img --verbose --grub --bootsize=256M
Creating disk image
Creating partitions
Creating filesystem ext4
Mounting /dev/mapper/loop0p2 on /tmp/user/0/tmpMlrrJq
Creating filesystem ext2
Mounting /dev/mapper/loop0p1 on /tmp/user/0/tmpMlrrJq/boot/
Debootstrapping
Give root an empty password
Removing udev persistent cd and net rules
Setting up networking
Updating the initramfs
Configuring grub2
Failed. Is grub2-common installed? Using extlinux.
Installing extlinux
Cleaning up
root at tjener:~#
Dropping --bootsize work:
root at tjener:~# vmdebootstrap --distribution=jessie --image=test.img --verbose --grub
Creating disk image
Creating partitions
Creating filesystem ext4
Mounting /dev/mapper/loop0p1 on /tmp/user/0/tmppsKvPT
Debootstrapping
Give root an empty password
Removing udev persistent cd and net rules
Setting up networking
Updating the initramfs
Configuring grub2
Installing extlinux
Cleaning up
root at tjener:~#
The reason is that --bootsize causes the /boot partition to start on
sector 0 on the disk, not leaving any space for grub to use. I
discovered this while working on the btrfs patch, but submit this as a
separate bug report to make sure the fix is not lost even if no-one have
time to look at the btrfs issue.
This patch solve the issue by ensuring 1 MiB at the start of the disk is
reserved when --bootsize is used, to make sure it behave the same way
vmdebootstrap (and parted) is working when --bootsize isn't used.
--- vmdebootstrap.orig 2014-10-18 20:35:19.000000000 +0200
+++ vmdebootstrap 2014-11-03 05:34:47.319278095 +0100
@@ -243,13 +272,14 @@
self.runcmd(['parted', '-s', self.settings['image'],
'mklabel', 'msdos'])
if self.settings['bootsize'] and self.settings['bootsize'] is not '0%':
- bootsize = str(self.settings['bootsize'] / (1024 * 1024))
+ reserved = 1 # MiB space for boot loader / grub
+ bootend = str(reserved + (self.settings['bootsize'] / (1024 * 1024)))
self.runcmd(['parted', '-s', self.settings['image'],
- 'mkpart', 'primary', 'fat16', '0', bootsize])
+ 'mkpart', 'primary', 'fat16', str(reserved), bootend])
else:
- bootsize = '0%'
+ bootend = '0%'
self.runcmd(['parted', '-s', self.settings['image'],
- 'mkpart', 'primary', bootsize, '100%'])
+ 'mkpart', 'primary', bootend, '100%'])
self.runcmd(['parted', '-s', self.settings['image'],
'set', '1', 'boot', 'on'])
--
Happy hacking
Petter Reinholdtsen
More information about the Vmdebootstrap-devel
mailing list