summaryrefslogtreecommitdiff
path: root/install-VM-grongo
diff options
context:
space:
mode:
Diffstat (limited to 'install-VM-grongo')
-rwxr-xr-xinstall-VM-grongo44
1 files changed, 33 insertions, 11 deletions
diff --git a/install-VM-grongo b/install-VM-grongo
index c6cd666..f9d928a 100755
--- a/install-VM-grongo
+++ b/install-VM-grongo
@@ -22,7 +22,7 @@
set -e
set -u
-SUITE=jessie
+SUITE=stretch
hostlistfile=/root/VMs/host-list
MIRROR=http://ftp.at.debian.org/debian
@@ -167,14 +167,23 @@ fi
ip6addr="$ip6prefix$hostno:1"
-echo '2048,,L,*' | sfdisk -u S --Linux "$rootdev"
+echo '2048,,L,*' | sfdisk -u S "$rootdev"
kpartx -v -p "-p" -a "$rootdev" -s
cleanup+=("kpartx -d -p '-p' -v '$rootdev'")
part1="/dev/mapper/$(basename $rootdev)-p1"
mkfs.ext4 "$part1"
+if vgs "vg_$guest" > /dev/null 2>&1 ; then
+ echo >&2 "Error: Volume group vg_$guest already exists."
+ exit 1
+fi
+
if [ "$lvmsize" != "" ] ; then
- pvcreate "$lvmdev"
+ # pvcreate "$lvmdev" || read dummy
+ # we want to remove the vg from our local metadata config, but we do not
+ # affect the devices, so add it to the beginning of the list so it gets run
+ # when the devices are all gone.
+ cleanup=("vgremove 'vg_$guest'" "${cleanup[@]}")
vgcreate "vg_$guest" "$lvmdev"
fi
@@ -216,6 +225,7 @@ rm -fv etc/udev/rules.d/70-persistent-*
mkdir -p etc/udev/rules.d/
touch etc/udev/rules.d/75-persistent-net-generator.rules
+mkdir -p etc/network
cat > etc/network/interfaces << EOF
auto lo
iface lo inet loopback
@@ -242,14 +252,18 @@ EOF
### A couple packages
mv etc/apt/sources.list etc/apt/sources.list.d/debian.list
-echo "deb http://security.debian.org/ jessie/updates main" > etc/apt/sources.list.d/security.list
-echo "deb $MIRROR jessie-updates main" > etc/apt/sources.list.d/updates.list
+echo "deb http://security.debian.org/ ${SUITE}/updates main" > etc/apt/sources.list.d/security.list
+echo "deb $MIRROR ${SUITE}-updates main" > etc/apt/sources.list.d/updates.list
chroot . apt-get update
echo "Apt::Install-Recommends 0;" > etc/apt/apt.conf.d/local-recommends
+
chroot . apt-get install -y locales-all net-tools iproute ifupdown dialog vim netbase udev psmisc usbutils pciutils
chroot . apt-get install -y iputils-ping telnet bind9-host lvm2
sed -i -e 's/issue_discards = 0/issue_discards = 1/' etc/lvm/lvm.conf
+# init stuff
+chroot . apt-get install -y systemd systemd-sysv initscripts
+
### Set up kernel and bootloader
chroot . apt-get install -y linux-image-amd64
DEBIAN_FRONTEND=noninteractive chroot . apt-get install -y grub2
@@ -264,7 +278,7 @@ rm -v dev/new-root*
cp -av `readlink -f "$rootdev"` dev/sda
cp -av `readlink -f "$part1"` dev/sda1
rm -f boot/grub/device.map
-sed -i -e 's/^GRUB_CMDLINE_LINUX=""$/GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"/' etc/default/grub
+sed -i -e 's/^GRUB_CMDLINE_LINUX=""$/GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8 net.ifnames=0"/' etc/default/grub
cat >> etc/default/grub <<EOF
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
@@ -291,6 +305,9 @@ APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
EOF
+### more packages
+chroot . apt-get install -y libpam-systemd dbus cron logrotate rsyslog qemu-guest-agent acpi-support-base lldpd
+
## trim
mkdir -p etc/cron.daily
tee > etc/cron.daily/local-trim-ext4 << 'EOF'
@@ -308,17 +325,18 @@ chmod +x etc/cron.daily/local-trim-ext4
cat >> etc/systemd/timesyncd.conf << EOF
Servers=172.22.130.1
EOF
-ln -s /lib/systemd/system/systemd-timesyncd.service etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service
+if ! [ -e etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service ] ; then
+ ln -s /lib/systemd/system/systemd-timesyncd.service etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service
+fi
### first boot
cat > first-boot.sh << EOF
#!/bin/bash
set -e
+set -x
sleep 10
-apt-get install -y acpi-support-base lldpd
-apt-get install -y libpam-systemd dbus
-apt-get install -y cron logrotate
-apt-get install -y rsyslog
+#apt-get install -y XXX
+update-initramfs -u
sed -i -e '/first-boot.sh/d' etc/rc.local
/etc/cron.daily/local-trim-ext4
rm /first-boot.sh
@@ -404,6 +422,10 @@ cat << EOF
<console type='pty'>
<target type='serial' port='0'/>
</console>
+ <channel type='unix'>
+ <source mode='bind'/>
+ <target type='virtio' name='org.qemu.guest_agent.0'/>
+ </channel>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>