mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
manage use of virtio for disk, add doc
This commit is contained in:
parent
385eac14a1
commit
61f97ab068
5 changed files with 99 additions and 13 deletions
|
@ -10,8 +10,7 @@
|
|||
"bootstrapper": {
|
||||
"mount_dir": "/mnt/target",
|
||||
"image_file": "/tmp/one.img",
|
||||
"tarball": true,
|
||||
"device": "/dev/sda"
|
||||
"tarball": true
|
||||
},
|
||||
"image": {
|
||||
"name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}",
|
||||
|
|
54
manifests/one-virtio.manifest
Normal file
54
manifests/one-virtio.manifest
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"provider" : "raw",
|
||||
"virtualization": "virtio",
|
||||
"credentials" : {
|
||||
"access-key": null,
|
||||
"secret-key": null,
|
||||
"root": "test"
|
||||
},
|
||||
|
||||
"bootstrapper": {
|
||||
"mount_dir": "/mnt/target",
|
||||
"image_file": "/tmp/one.img",
|
||||
"tarball": true
|
||||
},
|
||||
"image": {
|
||||
"name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}",
|
||||
"description": "Debian {release} {architecture} ({virtualization})"
|
||||
},
|
||||
"system": {
|
||||
"release" : "wheezy",
|
||||
"architecture": "amd64",
|
||||
"timezone" : "UTC",
|
||||
"locale" : "en_US",
|
||||
"charmap" : "UTF-8",
|
||||
"mirror" : "ftp://ftp.fr.debian.org/debian/"
|
||||
},
|
||||
"volume": {
|
||||
"backing" : "raw",
|
||||
"filesystem": "ext4",
|
||||
"size" : 1024
|
||||
},
|
||||
"plugins": {
|
||||
"admin_user": {
|
||||
"enabled": false
|
||||
},
|
||||
"build_metadata": {
|
||||
"enabled": false,
|
||||
"path" : "/root/build-metadata-{ami_name}"
|
||||
},
|
||||
"prebootstrapped": {
|
||||
"enabled": false,
|
||||
"snapshot": ""
|
||||
},
|
||||
"opennebula": {
|
||||
"enabled": true
|
||||
},
|
||||
"user_packages": {
|
||||
"enabled": true,
|
||||
"repo": [ "apache2" ],
|
||||
"local": []
|
||||
}
|
||||
|
||||
}
|
||||
}
|
16
providers/raw/REAME.md
Normal file
16
providers/raw/REAME.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
# RAW provider
|
||||
|
||||
This provider creates a raw image file. It can be combined with opennebula plugin to add OpenNebula contextualization.
|
||||
|
||||
By default, it creates a network interface configured with DHCP.
|
||||
|
||||
# Configuration
|
||||
|
||||
## provider
|
||||
|
||||
*raw* : use this provider
|
||||
|
||||
##virtualization
|
||||
|
||||
* ide: basic disk emulation (/dev/sda)
|
||||
* virtio: Virtio emulation (for KVM), provides better disk performances (/dev/vda)
|
|
@ -18,22 +18,43 @@ class ConfigureGrub(Task):
|
|||
for cfg in [os.path.join(grubd, f) for f in os.listdir(grubd)]:
|
||||
os.chmod(cfg, os.stat(cfg).st_mode & ~ x_all)
|
||||
|
||||
from common.tools import log_check_call
|
||||
from shutil import copy
|
||||
|
||||
script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/grub.d/40_custom'))
|
||||
script_dst = os.path.join(info.root, 'etc/grub.d/40_custom')
|
||||
copy(script_src, script_dst)
|
||||
os.chmod(script_dst, rwxr_xr_x)
|
||||
|
||||
from common.tools import sed_i
|
||||
if info.manifest.virtualization == 'virtio':
|
||||
modules_path = os.path.join(info.root,
|
||||
'etc/initramfs-tools/modules')
|
||||
with open(modules_path, 'a') as modules:
|
||||
modules.write("\nvirtio_pci\nvirtio_blk\n")
|
||||
|
||||
|
||||
grub_def = os.path.join(info.root, 'etc/default/grub')
|
||||
|
||||
from common.tools import log_check_call
|
||||
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(['grub-install', '--boot-directory='+info.root+"/boot/", '/dev/loop0'])
|
||||
|
||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
|
||||
|
||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
|
||||
|
||||
from common.tools import sed_i
|
||||
if info.manifest.virtualization == 'virtio':
|
||||
grub_cfg = os.path.join(info.root, 'boot/grub/grub.cfg')
|
||||
sed_i(grub_cfg, 'sda', 'vda')
|
||||
device_map = os.path.join(info.root,
|
||||
'boot/grub/device.map')
|
||||
sed_i(device_map, 'sda', 'vda')
|
||||
#log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
|
||||
|
||||
|
||||
|
||||
class BlackListModules(Task):
|
||||
description = 'Blacklisting kernel modules'
|
||||
phase = phases.system_modification
|
||||
|
|
|
@ -138,14 +138,10 @@ class ModifyFstab(Task):
|
|||
mount_opts.append('nobarrier')
|
||||
fstab_path = os.path.join(info.root, 'etc/fstab')
|
||||
with open(fstab_path, 'a') as fstab:
|
||||
fstab.write(('/dev/sda1 / {filesystem} {mount_opts} 1 1\n'
|
||||
device = '/dev/sda1'
|
||||
if info.manifest.virtualization == 'virtio':
|
||||
device = '/dev/vda1'
|
||||
|
||||
fstab.write((device+' / {filesystem} {mount_opts} 1 1\n'
|
||||
.format(filesystem=info.manifest.volume['filesystem'].lower(),
|
||||
mount_opts=','.join(mount_opts))))
|
||||
log_check_call(['/usr/sbin/chroot', info.root, 'cat', '/etc/fstab'])
|
||||
|
||||
class InstallMbr(Task):
|
||||
description = 'Install MBR'
|
||||
phase = phases.system_modification
|
||||
|
||||
def run(self, info):
|
||||
log_check_call(['install-mbr', '-v', info.manifest.bootstrapper['image_file']])
|
||||
|
|
Loading…
Add table
Reference in a new issue