fixes for loopback and filesystem setup

This commit is contained in:
Olivier Sallou 2013-07-26 14:16:40 +02:00
parent 1fe0d56bc3
commit cb4b2aad19
3 changed files with 21 additions and 10 deletions

View file

@ -46,6 +46,7 @@ def tasks(tasklist, manifest):
#apt.AptUpgrade(),
boot.ConfigureGrub(),
filesystem.ModifyFstab(),
#filesystem.InstallMbr(),
boot.BlackListModules(),
boot.DisableGetTTYs(),
security.EnableShadowConfig(),

View file

@ -12,12 +12,19 @@ class FormatVolume(Task):
def run(self, info):
mkmount = ['/usr/bin/qemu-img', 'create', '-f', 'raw', info.manifest.bootstrapper['image_file'], str(info.manifest.volume['size'])+'M']
log_check_call(mkmount)
#ddcmd = ['/bin/dd', 'if=/dev/zero', 'bs=1024', 'conv=notrunc', 'count='+str(info.manifest.volume['size']), 'of='+info.manifest.bootstrapper['image_file']]
#log_check_call(ddcmd)
loopcmd = ['/sbin/losetup', '/dev/loop0', info.manifest.bootstrapper['image_file']]
log_check_call(loopcmd)
mkfs = [ '/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem']), '-m', '1', '-v', '/dev/loop0']
log_check_call(mkfs)
# 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']])
#loopcmd = ['/sbin/losetup', '/dev/loop0', info.manifest.bootstrapper['image_file']]
#log_check_call(loopcmd)
mkfs = [ '/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem']), '-m', '1', '-v', '/dev/mapper/loop0p1']
log_check_call(mkfs)
@ -28,7 +35,8 @@ class TuneVolumeFS(Task):
def run(self, info):
#dev_path = info.bootstrap_device['path']
dev_path = info.manifest.bootstrapper['image_file']
#dev_path = info.manifest.bootstrapper['image_file']
dev_path = '/dev/mapper/loop0p1'
# Disable the time based filesystem check
log_check_call(['/sbin/tune2fs', '-i', '0', dev_path])
@ -66,8 +74,7 @@ class MountVolume(Task):
msg = 'Something is already mounted at {root}'.format(root=info.root)
raise TaskError(msg)
log_check_call(['/bin/mount', '-t', info.manifest.volume['filesystem'], '/dev/loop0', info.root])
log_check_call(['/bin/mount', '-t', info.manifest.volume['filesystem'], '/dev/mapper/loop0p1', info.root])
class MountSpecials(Task):
description = 'Mounting special block devices'
@ -99,7 +106,8 @@ class UnmountVolume(Task):
def run(self, info):
log_check_call(['/bin/umount', info.root])
log_check_call(['/sbin/losetup', '-d', '/dev/loop0'])
#log_check_call(['/sbin/losetup', '-d', '/dev/loop0'])
log_check_call(['kpartx','-d', info.manifest.bootstrapper['image_file']])
@ -138,3 +146,4 @@ class InstallMbr(Task):
def run(self, info):
log_check_call(['/usr/sbin/chroot', info.root, 'install-mbr', '/dev/sda'])
log_check_call(['/usr/sbin/chroot', info.root, 'fdisk', '-l', '/dev/sda'])

View file

@ -23,6 +23,7 @@ class ImagePackages(Task):
# Add some basic packages we are going to need
include = set(['udev',
'mbr',
'parted',
'openssh-server',
# We could bootstrap without locales, but things just suck without them, error messages etc.
'locales',