Example #1
0
def ConfigureKernel():
    utils.LogStep('Configure Kernel')
    utils.Replace(
        '/etc/mkinitcpio.conf', 'MODULES=""',
        'MODULES="virtio virtio_blk virtio_pci virtio_scsi virtio_net"')
    utils.Replace('/etc/mkinitcpio.conf', 'autodetect ', '')
    utils.Run([
        'mkinitcpio', '-g', '/boot/initramfs-linux.img', '-k',
        '/boot/vmlinuz-linux', '-c', '/etc/mkinitcpio.conf'
    ])
Example #2
0
def InstallBootloader(device, uuid, debugmode):
    utils.LogStep('Install Syslinux bootloader')
    '''
  utils.Run(['syslinux-install_update', '-i', '-a', '-m'])
  '''
    utils.Run(['blkid', '-s', 'PTTYPE', '-o', 'value', device])
    utils.CreateDirectory('/boot/syslinux')
    utils.CopyFiles('/usr/lib/syslinux/bios/*.c32', '/boot/syslinux/')
    utils.Run(['extlinux', '--install', '/boot/syslinux'])
    utils.Replace('/boot/syslinux/syslinux.cfg', 'sda3', 'sda1')
    utils.Run(['fdisk', '-l', device])
    utils.Run([
        'dd', 'bs=440', 'count=1', 'conv=notrunc',
        'if=/usr/lib/syslinux/bios/mbr.bin',
        'of=%s' % device
    ])

    boot_params = [
        'console=ttyS0,38400',
        'CONFIG_KVM_GUEST=y',
        'CONFIG_KVM_CLOCK=y',
        'CONFIG_VIRTIO_PCI=y',
        'CONFIG_SCSI_VIRTIO=y',
        'CONFIG_VIRTIO_NET=y',
        'CONFIG_STRICT_DEVMEM=y',
        'CONFIG_DEVKMEM=n',
        'CONFIG_DEFAULT_MMAP_MIN_ADDR=65536',
        'CONFIG_DEBUG_RODATA=y',
        'CONFIG_DEBUG_SET_MODULE_RONX=y',
        'CONFIG_CC_STACKPROTECTOR=y',
        'CONFIG_COMPAT_VDSO=n',
        'CONFIG_COMPAT_BRK=n',
        'CONFIG_X86_PAE=y',
        'CONFIG_SYN_COOKIES=y',
        'CONFIG_SECURITY_YAMA=y',
        'CONFIG_SECURITY_YAMA_STACKED=y',
    ]
    if debugmode:
        boot_params += [
            'systemd.log_level=debug',
            'systemd.log_target=console',
            'systemd.journald.forward_to_syslog=yes',
            'systemd.journald.forward_to_kmsg=yes',
            'systemd.journald.forward_to_console=yes',
        ]
    boot_params = ' '.join(boot_params)
    boot_spec = '    APPEND root=UUID=%s rw append %s' % (uuid, boot_params)
    utils.ReplaceLine('/boot/syslinux/syslinux.cfg', 'APPEND root=', boot_spec)