Exercise 2

Table of Contents

1 Introduction

In this exercise, you install and configure a second VM. This will be very similiar to the first one, so repeated instructions are omitted. Therefore it's useful to have instructions and your notes of the first exercise on the side. Click here for getting back the first exercise

This exercise can be read in PDF, HTML, and Text formats.

1.1 Homework

  • Some commands require sudo in front of them. This is not usually mentioned, and you have to apply it in the right moments. At the end of this exercise, analyze which commands required sudo and why.

1.2 Update: SSH keys

There is a new SSH key for mailkang. Update this to your both virtual machines.

2 Steps

2.1 Installation of KONE2

  • Open a new log (~/logs/KONE2.txt 1) and document your installation steps. Make notes with the accuarcy that you could follow the same steps without the instructions. Also make note of any weird things or problems that you encounter.
  • Make a disk image of size 3G in /ramdisk/TUNNUS.
  • Start virt-install with the following parameters:
-n KONE2 --memory 512 -w bridge=br0 --arch x86_64
--disk /ramdisk/TUNNUS/KONE2.img,bus=virtio
--location http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/installer-amd64
--graphics none --extra-args="console=ttyS0,115200n8 serial"
  • This is similiar to the previous exercise. Differences are the name, bootstrapping method and installation interface. This VM is booted from the Ubuntu 16.04 installer image that is fetched from the URL in --location argument. Instead of X tunneling, we use a virtual serial port to control this VM.
  • Look up the IP of your KONE2.
  • Use similiar settings as in the previous exercise. (Except for the hostname and IP address, of course.)
  • Install OpenSSH server in software selection menu 2. Use TUNNUS0 as the zero account.
  • You can jump to the next section and work on KONE1 while it's installing and doesn't require attention.

2.2 Do this part in KONE1

  • Document these steps in KONE1's own log.

2.2.1 Check resources and locale

  1. Turn off KONE1 and take a backup of its image.
  2. Make sure that KONE1 has exactly 256MB of configured RAM memory. If not, open the XML configuration with virsh edit KONE1 and change the amount of memory to 262144 (two locations in the beginning of the file).
  3. Check free disk space. If the disk is almost full, find out why and fix it.
  4. Inspect the locale in use (with the command locale) and all installed locales (-a flag). Install language-pack-fi and check the locales again. Find out about all supported Finnish locales with the command

    grep 'fi_' /usr/share/i18n/SUPPORTED

    and add the missing locales in the file /var/lib/locales/supported.d/local and then run dpkg-reconfigure locales. Check once more the output of the commands above and also what is in the file /etc/default/locale.

  5. Check the disk space again.
  6. Update the system (apt-get update; apt-get dist-upgrade).

2.2.2 Install lighttpd

  1. Install lighttpd. Test with a trivial index.html file.
  2. Configure virtual hosts to the different host names of your machine, s0NN.vm.it.jyu.fi and TUNNUS1.student.it.jyu.fi (here NN is the last number of the machine's IP address)
  3. Put different content to be delivered with your different vhosts. In TUNNUS1.student domain, include the string "TUNNUS1" in the page. In s0NN domain, include the string "kukkuu". Confirm that they are working as expected. (These will be checked by the script.)
  4. Check the disk space again.

2.2.3 Extend the disk to 4G

  1. Shutdown KONE1. Backup its disk image. Extend the image to 4GB with the command qemu-img resize ... 3
  2. Turn it on again. Print the partition table with fdisk -l /dev/vda and keep it at hand for the next step. For comparison, you can also look what parted -l /dev/vda prints.
  3. Edit the partition table (fdisk /dev/vda) by first removing all partitions. Then redo them so that the system partition starts from exactly the same location as previously, but is larger. Make swap partition of the same size inside the extended partition like it was previously. Set bootable flag and partition types.
  4. Save partition table and reboot.
  5. Extend the filesystem of the main partition (resize2fs).
  6. Check the disk space again.
  7. Initialize the swap partition (mkswap). Reuse the UUID. (see /etc/fstab).
  8. Enable the swap space (swapon -a) and check that it was successful by looking at /proc/swaps.

2.3 When KONE2 is ready

2.3.1 Post-install

  1. Connect to your machine. Make sure both ssh and serial connections work. After installation, serial connection can be opened with: virsh console TUNNUS2
  2. Close the serial connection with Ctrl-5 (Finnish keyboard) or Ctrl-] (as it says, escape character is ^]).
  3. Enable serial access to Grub's boot menu.

2.3.2 Setup instructors

  1. Install libpam-krb5 and acpid. Add user accounts of instructors and yourself as previously. Next we copy the keys from the previous install, saving a bit of time.
  2. Mount the backup disk image of KONE1 to KONE2 (virsh attach-disk)
  3. Copy the home directories (except that of the zero account) under /home from the backup to KONE2.
  4. Try logging in with your SSH key to see that it works. Then detach the backup image and remove it to free space in the host machine.
  5. Check the amount of free disk space.

2.3.3 Move disk image

  • Move disk image from /ramdisk to your home directory. Update the VM configuration in the hypervisor as necessary.

2.4 Finish

  • Save logs
  • sudo checker.sh 2
  • Leave VM running
  • Remember homework!

Footnotes:

1 in the lonka you were assigned to previously, and KONE/TUNNUS replaced with your username as usual.

2 Tick the OpenSSH Server box with space. Enter goes forward in this menu. Tab changes the area of focus. This step is important, as you might not be able to access your VM after installation without it!

3 Extending it to 5GB is fine as well, despite what the script says.

Date: 2019-03-08T13:32+0200

Author: Janne Uusitupa

Org version 7.9.3f with Emacs version 24

Validate XHTML 1.0