Beorn

From Cnwiki

(Difference between revisions)
Jump to: navigation, search
((5: Add extra disk drive))
((5: Add extra disk drive))
Line 167: Line 167:
Sources:  
Sources:  
-
- Adding the extra disk: [http://www.thegeekstuff.com/2015/02/add-memory-cpu-disk-to-kvm-vm/ Add extra disk on virtualization server]
+
- Adding the extra disk: [http://www.thegeekstuff.com/2015/02/add-memory-cpu-disk-to-kvm-vm/ Add extra disk on virtualization server]
-
- Partioning: [http://www.howtogeek.com/106873/how-to-use-fdisk-to-manage-partitions-on-linux/ Partition a disk in Ubuntu]
+
- Partioning: [http://www.howtogeek.com/106873/how-to-use-fdisk-to-manage-partitions-on-linux/ Partition a disk in Ubuntu]
-
- Mounting the partition: [https://linuxexpresso.wordpress.com/2010/03/14/mount-partitions-in-terminal-fstab/ Mount partition in Ubuntu]
+
- Mounting the partition: [https://linuxexpresso.wordpress.com/2010/03/14/mount-partitions-in-terminal-fstab/ Mount partition in Ubuntu]

Revision as of 13:20, 9 June 2016

Beorn is a virtualisation server, providing virtual machines for research and student projects. The server was purchased in December 2015 and has been named after Beorn, the character of The Hobbit.

This page contains static information, i.e. guides and hardware documentation. For more dynamic content, i.e. currently deployed virtual machines and their network address allocations, please see Ressource assignment and deployed VMs on Beorn.

Contents

Hardware Characteristics

The server has the following characteristics:

• DELL PowerEdge R430

• Processor: Intel Xeon E5-2630 v3, 8 cores 16 threads @ 2.40GHz

• RAM: 2x16GB, 2133MHz

• Storage: 2x400GB SSD, hardware RAID1

• Network Adapter: 2x1GBit Ethernet

The server is placed in the server room inside the laboratory (Edison 331) mounted on the middle rack, and has three years of basic warranty provided by DELL, running from ~December 2015.

Server installation guide

This installation guide follows the guide on Radagast. If you encounter problems, or would like more information regarding the software components installed, try looking at that page first.

1: Install Ubuntu

Install Ubuntu 14.04 LTS from USB drive (use standard lab admin account as user).
Create your own superuser (http://www.liquidweb.com/kb/how-to-add-a-user-and-grant-root-privileges-on-ubuntu-14-04/).

2: Install SSH

Install SSH:

  $sudo apt-get install openssh-server

Save public key on server: Sec. 6 in https://www.howtoforge.com/ssh_key_based_logins_putty_p2.
Remember to turn off password authentication: Sec. 9 in https://www.howtoforge.com/ssh_key_based_logins_putty_p4

3: Install virtualization components

Install components:

  $sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

Add user to libvirtd group:

  ~$ sudo adduser <username> libvirtd

4: Setup bridge (cannot be done via SSH)

Shutdown network connection, take a backup of the interfaces file and enter the interfaces file:

  ~$ sudo ifdown em1
  ~$ sudo cp /etc/network/interfaces /etc/network/interfaces.factory-defaults
  ~$ sudo chmod a-w /etc/network/interfaces
  ~$ sudo editor /etc/network/interfaces

Change the file to:

  # This file describes the network interfaces available on your system
  # and how to activate them. For more information, see interfaces(5).
  
  # The loopback network interface
  auto lo
  iface lo inet loopback
  
  # # The primary network interface
  # auto em1
  # iface em1 inet dhcp
  
  # Bridged network interface
  auto br0
  iface br0 inet dhcp
       bridge_ports em1
       bridge_stp off

Bring up the new bridge:

  ~$ sudo ifup br0

5: Create the build-command script

Create and enter the script file:

  $sudo nano /var/lib/libvirt/images/build-command.sh

Change the file to:

  vmbuilder kvm ubuntu \
         --hostname <insert> \
         --user <insert> \
         --pass <insert> \
         --libvirt qemu:///system \
         --addpkg openssh-server \
         --addpkg linux-image-generic \
         --destdir=./image \
         --flavour virtual \
         --bridge br0 \
         --mac 02:00:02:06:00:<insert last two digits> \
         --suite trusty \
         --cpus 1 \
         --mem 1024 \
         --swapsize=1024 \
         --rootsize 10000

Guide for creating virtual machines

In this guide, the user "jhj" creates a virtual machine (VM) named "VirtualMachine1" with the IP address "10.29.1.61". The MAC address, "02:00:02:06:00:07", used in the guide is from the MAC-IP address pair for "10.29.1.61" found in Ressource assignment and deployed VMs on Beorn.

1: Create folder

Go to the VM images folder, create a new directory for the machine (MachineName.InitialsOfCreator), copy the build-script template to the directory and enter the directory:

  $cd /var/lib/libvirt/images/
  $sudo mkdir VirtualMachine1.jhj
  $sudo cp build-command.sh VirtualMachine1.jhj/
  $cd VirtualMachine1.jhj

2: Edit and run the build-script

Enter the build-script:

  $sudo nano buildcommand.sh

Modify the build-script:

  vmbuilder kvm ubuntu \
         --hostname VirtualMachine1 \
         --user test \
         --pass test \
         --libvirt qemu:///system \
         --addpkg openssh-server \
         --addpkg linux-image-generic \
         --destdir=./image \
         --flavour virtual \
         --bridge br0 \
         --mac 02:00:02:06:00:07 \
         --suite trusty \
         --cpus 1 \
         --mem 1024 \
         --swapsize=1024 \
         --rootsize 10000

3: Create and start the VM

Run the script (takes a couple of minutes) to create the VM:

  $sudo sh buildcommand.sh

Start the VM:

  $virsh start VirtualMachine1

4: Access the VM

Access the VM through SSH using the IP address "10.29.1.61". Remember that the IP address was assigned to the VM because you used the MAC address from the MAC-IP pair in Ressource assignment and deployed VMs on Beorn.

See following guide for using SSH key-authentication instead of password authentication: https://www.howtoforge.com/ssh_key_based_logins_putty

(5: Add extra disk drive)

This is ONLY necessary if you desire to mount an extra disk to your VM (E.g. if you want to simulate a production environment server running with a separate disk for data storage).

Start by going to the directory of the VM and create an extra disk (on the virtualization server). In this example, we create a 15GB disk:

  $cd /var/lib/libvirt/images/VirtualMachine1.jhj/
  $qemu-img create -f raw VirtualMachine1-disk2.img 15G

Attach the disk to the VM:

  $virsh attach-disk VirtualMachine1 --source /var/lib/libvirt/images/VirtualMachine1.jhj/VirtualMachine1-disk2.img --target sdb --persistent

The rest of should step is done on the virtual machine, so SSH into it. Now partition the new disk (just press enter when it suggests default values):

  $sudo fdisk /dev/sdb
  $Command (m for help): n
  $Partition type:
  $   p   primary (0 primary, 0 extended, 4 free)
  $   e   extended
  $Select (default p): p
  $Partition number (1-4, default 1):
  $Using default value 1
  $First sector (2048-83886079, default 2048):
  $Using default value 2048
  $Last sector, +sectors or +size{K,M,G} (2048-83886079, default 83886079):
  $Using default value 83886079

Create a "data" directory with read/write permission, and mount the partition to it:

  $cd /
  $sudo mkdir -m 777 Data
  $sudo mount -t auto -v /dev/sdb /data

Now your partition is mounted, and you can access it through the "data" folder:

  $cd /data

Sources: - Adding the extra disk: Add extra disk on virtualization server - Partioning: Partition a disk in Ubuntu - Mounting the partition: Mount partition in Ubuntu

Personal tools