fix grub install

This commit is contained in:
Olivier Sallou 2013-07-30 11:21:09 +02:00
parent af7dcebb25
commit 6be6879db7
4 changed files with 19 additions and 10 deletions

View file

@ -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(),

View file

@ -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}

View file

@ -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'

View file

@ -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']])