Differences
This shows you the differences between two versions of the page.
tools:xen [2015/07/29 00:40] darron |
tools:xen [2016/07/21 18:45] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== XEN Debian 8 appliance ==== | ||
- | Download the net install [[http:// | ||
- | |||
- | Alternatively, | ||
- | installation. | ||
- | |||
- | == BOOT == | ||
- | |||
- | apt-get install sysvinit-core sysvinit sysvinit-utils | ||
- | |||
- | configure sshd root login | ||
- | configure inittab getty hvc0 | ||
- | |||
- | == REBOOT == | ||
- | |||
- | apt-get remove --purge --auto-remove systemd | ||
- | |||
- | < | ||
- | /bin/echo -e ' | ||
- | /bin/echo -e ' | ||
- | /bin/echo -e ' | ||
- | /bin/echo -e ' | ||
- | </ | ||
- | === Debian 8 installation === | ||
- | |||
- | Boot the image to perform the installation process and select `Install' | ||
- | |||
- | From the language selection pages I chose the following. | ||
- | < | ||
- | English => United Kingdom => British English | ||
- | </ | ||
- | |||
- | After loading components from the CD, we enter some basic but essential host information. | ||
- | < | ||
- | hostname: xen | ||
- | domain name: example.com | ||
- | root password: XXX | ||
- | full name of new user: ABC XYZ | ||
- | username: ABC | ||
- | password: XXX | ||
- | </ | ||
- | |||
- | The next step is partitioning. Initially we choose Guided partitioning and after edit the automatic choice for the root partition. | ||
- | < | ||
- | Guided Partitioning - use entire disk and set up LVM | ||
- | All files in one partition (recommended for new users) | ||
- | Write the changes to disks and configure LVM? YES | ||
- | </ | ||
- | |||
- | Do not select finish just yet, go up the menu. | ||
- | < | ||
- | Configure the Logical Volume Manager | ||
- | Write the changes to disks and configure LVM? YES | ||
- | | ||
- | root | ||
- | | ||
- | | ||
- | | ||
- | root | ||
- | | ||
- | 8GB | ||
- | | ||
- | </ | ||
- | |||
- | Inspect the partition list and select the root entry created above. | ||
- | < | ||
- | LVM VG xen-vg, LV root - 8.0 GB Linux device-mapper (linear) | ||
- | #1 | ||
- | | ||
- | Mount point: / | ||
- | Mount options: [x] noatime | ||
- | | ||
- | | ||
- | | ||
- | |||
- | Done setting up the partition | ||
- | </ | ||
- | |||
- | Finally, we finish creating the disk layout. | ||
- | < | ||
- | Finish partitioning and write changes to disk | ||
- | Write the changes to disks? YES | ||
- | </ | ||
- | |||
- | After some time installing the base system, the package selection process will begin. | ||
- | |||
- | First select a mirror, I chose UK. | ||
- | < | ||
- | United Kingdom => ftp.uk.debian.org | ||
- | Continue | ||
- | </ | ||
- | |||
- | Wait for some time. | ||
- | < | ||
- | Participate in the package usage Survey? NO | ||
- | </ | ||
- | |||
- | Finally we reach the software selection menu. | ||
- | |||
- | It's important to deselect every entry using the space bar and only select ssh server. | ||
- | < | ||
- | [*] SSH server | ||
- | Continue | ||
- | </ | ||
- | |||
- | Once installation is done the boot loader is installed and we are finished. | ||
- | < | ||
- | Install the GRUB boot loader to the master boot record? YES | ||
- | </ | ||
- | |||
- | Remove the ejected CD. | ||
- | < | ||
- | Installation complete | ||
- | Continue | ||
- | </ | ||
- | |||
- | === Debian 8 update === | ||
- | Login, update the system and then reboot it. | ||
- | < | ||
- | apt-get update | ||
- | apt-get dist-upgrade | ||
- | reboot | ||
- | </ | ||
- | |||
- | === Debian sysvinit === | ||
- | Login and replace systemd with sysvinit. | ||
- | |||
- | apt-get install sysvinit-core sysvinit sysvinit-utils | ||
- | |||
- | Configure sshd root login (if required). | ||
- | Configure inittab getty hvc0 (if this is a VM). | ||
- | |||
- | Now reboot, login again and finish the job off. | ||
- | |||
- | apt-get remove --purge --auto-remove systemd | ||
- | < | ||
- | /bin/echo -e ' | ||
- | /bin/echo -e ' | ||
- | /bin/echo -e ' | ||
- | /bin/echo -e ' | ||
- | </ | ||
- | |||
- | === XEN Debian 8 installation === | ||
- | |||
- | Install Xen kernel and tools. | ||
- | < | ||
- | apt-get install --no-install-recommends xen-linux-system xen-tools lvm2 bridge-utils | ||
- | dpkg-divert --divert / | ||
- | echo ' | ||
- | update-grub | ||
- | </ | ||
- | |||
- | Here is an example set up for an Ethernet bridge. | ||
- | |||
- | Edit the interface file. | ||
- | < | ||
- | vi / | ||
- | </ | ||
- | |||
- | Change the IP addresses for your host and network. | ||
- | < | ||
- | auto lo | ||
- | iface lo inet loopback | ||
- | |||
- | auto eth0 | ||
- | iface eth0 inet manual | ||
- | |||
- | auto xenbr0 | ||
- | iface xenbr0 inet static | ||
- | bridge_ports eth0 | ||
- | address X.X.X.X | ||
- | netmask 255.255.255.X | ||
- | gateway X.X.X.X | ||
- | </ | ||
- | |||
- | Finally, reboot into Xen. | ||
- | < | ||
- | reboot | ||
- | </ | ||
- | |||
- | === XEN VM installation === | ||
- | |||
- | Using the Xen tools we create a Debian Wheezy virtual machine with 1GB RAM and 16GB disk space. | ||
- | < | ||
- | xen-create-image --cache=yes --fs=ext4 --memory=1GB --size=16G --swap=1G --vcpus=1 --gateway=X.X.X.X --ip=X.X.X.X --netmask=255.255.255.X --hostname=vm0 --lvm=xen-vg --dist=wheezy | ||
- | </ | ||
- | |||
- | The creation process will take some time, outputting the following. | ||
- | < | ||
- | General Information | ||
- | -------------------- | ||
- | Hostname | ||
- | Distribution | ||
- | Mirror | ||
- | Partitions | ||
- | / | ||
- | Image type : | ||
- | Memory size : 1GB | ||
- | Kernel path : / | ||
- | Initrd path : / | ||
- | |||
- | Networking Information | ||
- | ---------------------- | ||
- | IP Address 1 : X.X.X.X [MAC: XX: | ||
- | Netmask | ||
- | Gateway | ||
- | |||
- | |||
- | Creating swap on / | ||
- | Done | ||
- | |||
- | Creating ext4 filesystem on / | ||
- | Done | ||
- | Installation method: debootstrap | ||
- | |||
- | Running hooks | ||
- | Done | ||
- | |||
- | No role scripts were specified. | ||
- | |||
- | Creating Xen configuration file | ||
- | Done | ||
- | |||
- | No role scripts were specified. | ||
- | Setting up root password | ||
- | Generating a password for the new guest. | ||
- | All done | ||
- | |||
- | |||
- | Logfile produced at: | ||
- | / | ||
- | |||
- | Installation Summary | ||
- | --------------------- | ||
- | Hostname | ||
- | Distribution | ||
- | MAC Address | ||
- | IP Address(es) | ||
- | RSA Fingerprint : XX: | ||
- | Root Password | ||
- | </ | ||
- | |||
- | === XEN VM maintenance === | ||
- | |||
- | List VM images. | ||
- | < | ||
- | xen-list-images | ||
- | Name: vm0 | ||
- | Memory: 1024 MB | ||
- | IP: X.X.X.X | ||
- | </ | ||
- | |||
- | Run VM with a console. | ||
- | < | ||
- | xl create -c / | ||
- | </ | ||
- | |||
- | Run a VM silently without a console. | ||
- | < | ||
- | xl create -q / | ||
- | </ | ||
- | |||
- | Attach a console to a running VM. | ||
- | < | ||
- | xl console vm0 | ||
- | </ | ||
- | |||
- | List VMs. | ||
- | < | ||
- | xl list | ||
- | Name ID Mem VCPUs State | ||
- | Domain-0 | ||
- | vm0 2 1024 | ||
- | </ | ||
- | |||
- | Shut down VM. | ||
- | < | ||
- | xl shutdown vm0 | ||
- | </ | ||
- | |||
- | Auto-start a VM at boot time. | ||
- | < | ||
- | mkdir -p / | ||
- | ln / | ||
- | </ | ||
- | === XEN LVM disk maintenance === | ||
- | |||
- | If we shut down a VM we can perform disk maintenance on it's virtual disk from Domain 0. | ||
- | |||
- | First ensure that the target VM is off-line. Here we only have 1 VM so our output only shows Domain 0 and | ||
- | our target vm-0 is not running. | ||
- | < | ||
- | xl list | ||
- | Name ID Mem VCPUs State | ||
- | Domain-0 | ||
- | </ | ||
- | |||
- | Now inspect the volumes for our target. | ||
- | < | ||
- | lvs | grep vm0 | ||
- | vm0-disk xen-vg -wi-a----- 16.00g | ||
- | vm0-swap xen-vg -wi-a----- | ||
- | </ | ||
- | |||
- | We will increase the size of the virtual disk and leave swap alone. | ||
- | < | ||
- | lvextend --size 24G / | ||
- | Size of logical volume xen-vg/ | ||
- | Logical volume vm0-disk successfully resized | ||
- | lvs | grep vm0 | ||
- | vm0-disk xen-vg -wi-a----- 24.00g | ||
- | vm0-swap xen-vg -wi-a----- | ||
- | </ | ||
- | |||
- | We must extend the size of the file system contained in the volume. | ||
- | |||
- | First check the disk for errors. | ||
- | < | ||
- | fsck -fy / | ||
- | fsck from util-linux 2.25.2 | ||
- | e2fsck 1.42.12 (29-Aug-2014) | ||
- | Pass 1: Checking inodes, blocks, and sizes | ||
- | Pass 2: Checking directory structure | ||
- | Pass 3: Checking directory connectivity | ||
- | Pass 4: Checking reference counts | ||
- | Pass 5: Checking group summary information | ||
- | / | ||
- | </ | ||
- | |||
- | And now resize it. | ||
- | < | ||
- | resize2fs / | ||
- | resize2fs 1.42.12 (29-Aug-2014) | ||
- | Resizing the filesystem on / | ||
- | The filesystem on / | ||
- | </ | ||
- | |||
- | The VM can now be restarted with an increased disk capacity. | ||
- | |||
- | < | ||
- | root@vm0:~# df -h / | ||
- | Filesystem | ||
- | / | ||
- | </ | ||
- | === XEN LVM swap maintenance === | ||
- | |||
- | We may discover that a choice for a swap partition size was incorrect so we may resize it. | ||
- | |||
- | In this example we will resize the Domain 0 swap partition but we can also resize the swap partition of a VM in a similar fashion. | ||
- | |||
- | First we take the swap partition off-line. | ||
- | < | ||
- | cat / | ||
- | Filename | ||
- | / | ||
- | swapoff -a | ||
- | </ | ||
- | |||
- | Now we inspect the volumes. | ||
- | < | ||
- | lvs | ||
- | LV | ||
- | root | ||
- | swap_1 | ||
- | vm0-disk xen-vg -wi-a----- 16.00g | ||
- | vm0-swap xen-vg -wi-a----- | ||
- | </ | ||
- | |||
- | We can reduce the size of an off-line swap partition with no dangerous side-effects, | ||
- | < | ||
- | lvreduce --size 2G / | ||
- | WARNING: Reducing active logical volume to 2.00 GiB | ||
- | THIS MAY DESTROY YOUR DATA (filesystem etc.) | ||
- | Do you really want to reduce swap_1? [y/n]: y | ||
- | Size of logical volume xen-vg/ | ||
- | Logical volume swap_1 successfully resized | ||
- | </ | ||
- | |||
- | We can also increase the size, for example, if the above step was incorrect. | ||
- | < | ||
- | lvresize --size 5G / | ||
- | Size of logical volume xen-vg/ | ||
- | Logical volume swap_1 successfully resized | ||
- | </ | ||
- | |||
- | Now we rebuild the swap. | ||
- | < | ||
- | mkswap / | ||
- | mkswap: / | ||
- | Setting up swapspace version 1, size = 2097148 KiB | ||
- | no label, UUID=3ac8493d-4dee-4309-9a01-953560ede126 | ||
- | </ | ||
- | |||
- | And remount it. | ||
- | < | ||
- | swapon -a | ||
- | cat / | ||
- | Filename | ||
- | / | ||
- | </ |