build vm with vmdebootstrap
This commit is contained in:
parent
4f28c2c548
commit
9d0b50bced
4 changed files with 97 additions and 36 deletions
66
vm/build.sh
66
vm/build.sh
|
|
@ -1,30 +1,46 @@
|
|||
#!/bin/sh
|
||||
size=1048576 #in MB
|
||||
arch=amd64 #i368 or amd64
|
||||
password=pandora
|
||||
#!/bin/bash
|
||||
cd "`dirname "$0"`"
|
||||
BASE=`pwd`
|
||||
VERSION=`cd ..;git rev-list HEAD --count`
|
||||
TARGET=${BASE}/pandora-r${VERSION}.vdi
|
||||
SIZE=1T
|
||||
RELEASE=trusty
|
||||
|
||||
hypervisor=vbox #vbox or kvm
|
||||
if [ "$MIRROR" = "" ]; then
|
||||
MIRROR="--mirror http://archive.ubuntu.com/ubuntu/"
|
||||
fi
|
||||
|
||||
extra=""
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
echo "you need to run $0 as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#make available as pandora.local
|
||||
extra="--addpkg avahi-daemon"
|
||||
# make sure ubuntu-archive-keyring is installed
|
||||
test -e /usr/share/keyrings/ubuntu-archive-keyring.gpg || apt-get install ubuntu-archive-keyring
|
||||
|
||||
#to create and include in libvirt:
|
||||
#hypervisor=kvm
|
||||
#extra="--libvirt qemu:///system"
|
||||
|
||||
base=$(pwd)
|
||||
sudo vmbuilder $hypervisor ubuntu --suite=trusty \
|
||||
--verbose --debug \
|
||||
--arch $arch \
|
||||
--dest $base/pandora \
|
||||
vmdebootstrap \
|
||||
--image ${TARGET}.img \
|
||||
--size ${SIZE} \
|
||||
--sparse \
|
||||
--distribution=${RELEASE} \
|
||||
$MIRROR \
|
||||
--enable-dhcp \
|
||||
--no-serial-console \
|
||||
--no-kernel \
|
||||
--package "linux-image-generic" \
|
||||
--package "avahi-daemon" \
|
||||
--package "ssh" \
|
||||
--mbr \
|
||||
--grub \
|
||||
--sudo \
|
||||
--lock-root-password \
|
||||
--user pandora/pandora \
|
||||
--hostname pandora \
|
||||
--swapsize 512 \
|
||||
--rootsize $size \
|
||||
--user pandora \
|
||||
--pass $password \
|
||||
--addpkg linux-image-generic \
|
||||
--components main,universe,multiverse \
|
||||
--firstboot=$base/firstboot.sh \
|
||||
$extra
|
||||
--customize "${BASE}/prepare.sh" \
|
||||
--log ${TARGET}.log --log-level debug --verbose
|
||||
|
||||
echo "Installing pan.do/ra in VM"
|
||||
qemu-system-x86_64 -enable-kvm -name pandora -m 1024 -drive "format=raw,file=${TARGET}.img" -vnc :2
|
||||
rm -rf "${TARGET}"
|
||||
/usr/bin/VBoxManage convertfromraw -format VDI "${TARGET}.img" "${TARGET}"
|
||||
rm "${TARGET}.img"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue