X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=input%2Fhowto%2Finstall-kvm.creole;h=0286f1e82bfe2ad67c682a2bd49a35e26b4e5fed;hb=3507c51343b0adb6fd1d352892b40d8654819e4a;hp=20752e74f277e35b8f87ad5928bacde8e92a375c;hpb=df09d9faf9de3e75b82152da05d6a7b7a1cfd85a;p=mirror%2Fdsa-wiki.git diff --git a/input/howto/install-kvm.creole b/input/howto/install-kvm.creole index 20752e7..0286f1e 100644 --- a/input/howto/install-kvm.creole +++ b/input/howto/install-kvm.creole @@ -12,7 +12,7 @@ setup_env() { echo -n "New hostname: " && export LC_ALL=C && read guest && - target=/mnt/target && + target="/mnt/target-$guest" && mirror=`cat /etc/apt/sources.list /etc/apt/sources.list.d/debian.list 2>/dev/null | awk '/^deb.*debian/ {print $2; exit}'` && vgdefault=`vgdisplay -c | awk -F: '{print $1;exit}' | sed 's/ *//g'` && echo -n "Volume group? [$vgdefault]: " && @@ -35,9 +35,15 @@ setup_env() { dev_boot="/dev/mapper/$vg-$guest--boot" && echo "Root device will be $dev_root" && echo "Boot device will be $dev_boot" && - fs=ext3 + fs=ext4 + fi && + if [ "$vg" != "" ]; then + dev_swap="/dev/mapper/$vg-$guest--swap" + elif [ -d /SWAPFILES ]; then + dev_swap=/SWAPFILES/$guest-swap + else + echo "No idea how to do swap" && false fi && - dev_swap="/dev/mapper/$vg-$guest--swap" && echo -n "Use a /boot filesystem (strongly recommended)? [Y/n] " && read use_boot && echo "Swap device will be $dev_swap" && @@ -93,7 +99,7 @@ trivial. fi && cd "$target" && - debootstrap --variant=minbase --keyring=/usr/share/keyrings/debian-archive-keyring.gpg squeeze . "$mirror" + debootstrap --variant=minbase --keyring=/usr/share/keyrings/debian-archive-keyring.gpg stable . "$mirror" }}} And finalize the setup: @@ -116,13 +122,13 @@ EOF rm -fv etc/apt/sources.list && ( ! [ -e /etc/apt/sources.list ] || cp /etc/apt/sources.list etc/apt/sources.list) (cp -v /etc/apt/sources.list.d/* etc/apt/sources.list.d/ || true ) && - cp -v /etc/apt/preferences etc/apt/ && + ( ! [ -e /etc/apt/preferences ] || cp -v /etc/apt/preferences etc/apt/ ) && apt-key exportall | chroot . apt-key add - && chroot . apt-get update && echo "Apt::Install-Recommends 0;" > etc/apt/apt.conf.d/local-recommends && - chroot . apt-get install net-tools iproute ifupdown dialog vim netbase xfsprogs && + chroot . apt-get install -y net-tools iproute ifupdown dialog vim netbase xfsprogs && cp -av `readlink -f $dev_root` dev/`basename $dev_root` && - DEBIAN_FRONTEND=noninteractive chroot . apt-get install grub2 && + DEBIAN_FRONTEND=noninteractive chroot . apt-get install -y grub2 && cat > etc/kernel-img.conf << EOF && do_symlinks = no do_initrd = yes @@ -132,7 +138,7 @@ EOF cp -av `readlink -f $dev_boot""1` dev/`basename $dev_boot`1 && chroot . grub-install --modules=part_msdos /dev/`basename $dev_boot` && # install a kernel image - chroot . apt-get install linux-image-2.6-amd64 && + chroot . apt-get install -y linux-image-2.6-amd64 && sed -i -e 's/^#GRUB_TERMINAL=console/GRUB_TERMINAL=console/' etc/default/grub && echo "(hd0) /dev/`basename $dev_boot`" > boot/grub/device.map && chroot . update-grub && @@ -143,7 +149,7 @@ EOF echo "(hd0) /dev/`basename $dev_root`" > boot/grub/device.map && chroot . grub-install /dev/"`basename $dev_root`" && # install a kernel image - chroot . apt-get install linux-image-2.6-amd64 && + chroot . apt-get install -y linux-image-2.6-amd64 && sed -i -e 's/^#GRUB_TERMINAL=console/GRUB_TERMINAL=console/' etc/default/grub && chroot . update-grub fi && @@ -158,7 +164,7 @@ And a fstab and a boot loader config # doesn't work: chroot . update-grub rootuuid=`blkid -s UUID -o value "$dev_root"` && swapuuid=`blkid -s UUID -o value "$dev_swap"` && - if [ "$fs" = "ext3" ]; then + if [ "$fs" = "ext4" ]; then rootopts="errors=remount-ro" else rootopts="defaults" @@ -193,6 +199,14 @@ And set a password: chroot . passwd }}} +Set a nameserver config that works once the VM has booted. Later in the process we will install unbound anyway. +{{{ +cat > etc/resolv.conf << EOF +nameserver 8.8.8.8 +search debian.org +EOF +}}} + And unmount: {{{ @@ -207,7 +221,7 @@ And unmount: === virsh setup === -Setup a new kvm domain by creating a new file in /etc/da-virt/`hostname/$guest.xml. +Setup a new kvm domain by creating a new file in /etc/dsa-kvm/`hostname/$guest.xml. * Properly configure hostname * Pick a new uuid ({{{uuidgen}}})