From 6be6879db7933d8111531bb11a6ee4aae4a9fade Mon Sep 17 00:00:00 2001 From: Olivier Sallou Date: Tue, 30 Jul 2013 11:21:09 +0200 Subject: [PATCH] fix grub install --- providers/one/__init__.py | 2 +- providers/one/assets/grub.d/40_custom | 5 +++-- providers/one/tasks/boot.py | 5 +++++ providers/one/tasks/filesystem.py | 17 ++++++++++------- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/providers/one/__init__.py b/providers/one/__init__.py index 7cc01a7..ebabe0e 100644 --- a/providers/one/__init__.py +++ b/providers/one/__init__.py @@ -34,6 +34,7 @@ def tasks(tasklist, manifest): tasklist.add(filesystem.TuneVolumeFS()) tasklist.add(filesystem.CreateMountDir(), filesystem.MountVolume()) + #tasklist.add(filesystem.InstallMbr()) if manifest.bootstrapper['tarball']: tasklist.add(bootstrap.MakeTarball()) tasklist.add(bootstrap.Bootstrap(), @@ -46,7 +47,6 @@ def tasks(tasklist, manifest): #apt.AptUpgrade(), boot.ConfigureGrub(), filesystem.ModifyFstab(), - filesystem.InstallMbr(), boot.BlackListModules(), boot.DisableGetTTYs(), security.EnableShadowConfig(), diff --git a/providers/one/assets/grub.d/40_custom b/providers/one/assets/grub.d/40_custom index 9977def..56419c7 100644 --- a/providers/one/assets/grub.d/40_custom +++ b/providers/one/assets/grub.d/40_custom @@ -20,7 +20,7 @@ cat << EOF set default ${GRUB_DEFAULT} set timeout ${GRUB_TIMEOUT} insmod part_msdos -insmod ext4 +insmod ext2 insmod gettext set menu_color_normal=cyan/blue set meu_color_highlight=white/blue @@ -42,7 +42,8 @@ linux_entry () cat << EOF menuentry 'Debian GNU/Linux, ${version}' --class debian --class gnu-linux --class os { insmod part_msdos - insmod ext4 + insmod ext2 + set timeout ${GRUB_TIMEOUT} set root='(hd0,msdos1)' echo 'Loading Linux ${version}' linux ${rel_dirname}/${basename} root=${GRUB_DEVICE} ro ${args} diff --git a/providers/one/tasks/boot.py b/providers/one/tasks/boot.py index 58c0918..abedc65 100644 --- a/providers/one/tasks/boot.py +++ b/providers/one/tasks/boot.py @@ -35,6 +35,11 @@ class ConfigureGrub(Task): log_check_call(['/usr/sbin/chroot', info.root, 'cat', '/boot/grub/device.map']) log_check_call(['/usr/sbin/chroot', info.root, 'ln', '-s', '/boot/grub/grub.cfg', '/boot/grub/menu.lst']) + log_check_call(['/usr/sbin/chroot', info.root, 'update-initramfs', '-u']) + log_check_call(['/usr/sbin/chroot', info.root, 'ls', '-l', '/boot/']) + #sed_i(info.root+'/boot/grub/device.map','/dev/sda','/dev/mapper/loop0p1;') + log_check_call(['grub-install', '--boot-directory='+info.root+"/boot/", '/dev/loop0']) + #sed_i(info.root+'/boot/grub/device.map','/dev/mapper/loop0p1;','/dev/sda') class BlackListModules(Task): description = 'Blacklisting kernel modules' diff --git a/providers/one/tasks/filesystem.py b/providers/one/tasks/filesystem.py index 618d8e1..5b255c7 100644 --- a/providers/one/tasks/filesystem.py +++ b/providers/one/tasks/filesystem.py @@ -13,15 +13,17 @@ class FormatVolume(Task): mkmount = ['/usr/bin/qemu-img', 'create', '-f', 'raw', info.manifest.bootstrapper['image_file'], str(info.manifest.volume['size'])+'M'] log_check_call(mkmount) + loopcmd = ['/sbin/losetup', '/dev/loop0', info.manifest.bootstrapper['image_file']] + log_check_call(loopcmd) + # parted - log_check_call(['parted','-a', 'optimal', '-s', info.manifest.bootstrapper['image_file'], "mklabel", "msdos"]) - log_check_call(['parted', '-a', 'optimal', '-s', info.manifest.bootstrapper['image_file'], "--", "mkpart", "primary", "ext4", "1", "-1"]) - log_check_call(['parted','-a', 'optimal', '-s', info.manifest.bootstrapper['image_file'], "--", "set", "1", "boot", "on"]) - log_check_call(['kpartx','-a','-v', info.manifest.bootstrapper['image_file']]) + log_check_call(['parted','-a', 'optimal', '-s', '/dev/loop0', "mklabel", "msdos"]) + log_check_call(['parted', '-a', 'optimal', '-s', '/dev/loop0', "--", "mkpart", "primary", "ext4", "32k", "-1"]) + log_check_call(['parted','-s', '/dev/loop0', "--", "set", "1", "boot", "on"]) - #loopcmd = ['/sbin/losetup', '/dev/loop0', info.manifest.bootstrapper['image_file']] - #log_check_call(loopcmd) + #log_check_call(['kpartx','-a','-v', info.manifest.bootstrapper['image_file']]) + log_check_call(['kpartx','-a', '-v', '/dev/loop0']) mkfs = [ '/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem']), '-m', '1', '-v', '/dev/mapper/loop0p1'] log_check_call(mkfs) @@ -106,6 +108,7 @@ class UnmountVolume(Task): def run(self, info): log_check_call(['/bin/umount', info.root]) + #log_check_call(['partx','-d','/dev/loop0']) #log_check_call(['/sbin/losetup', '-d', '/dev/loop0']) log_check_call(['kpartx','-d', info.manifest.bootstrapper['image_file']]) @@ -145,4 +148,4 @@ class InstallMbr(Task): phase = phases.system_modification def run(self, info): - log_check_call(['install-mbr', info.manifest.bootstrapper['image_file']]) + log_check_call(['install-mbr', '-v', info.manifest.bootstrapper['image_file']])