Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tools:xen [2015/07/29 00:40]
darron [XEN Debian 8 appliance]
tools:xen [2016/07/21 18:45]
Line 1: Line 1:
-==== XEN Debian 8 appliance ==== 
  
-Download the net install [[http://without-systemd.org/wiki/images/debian-testing-amd64-netinst.iso|ISO]] and create a bootable CD or flash drive. 
- 
-Alternatively, you may install Jessie then remove and replace systemd after installation. 
- 
-=== Debian 8 installation === 
- 
-Boot the image to perform the installation process and select `Install'. 
- 
-From the language selection pages I chose the following. 
-<code> 
-English => United Kingdom => British English 
-</code> 
- 
-After loading components from the CD, we enter some basic but essential host information. 
-<code> 
-hostname: xen 
-domain name: example.com 
-root password: XXX 
-full name of new user: ABC XYZ 
-username: ABC 
-password: XXX 
-</code> 
- 
-The next step is partitioning. Initially we choose Guided partitioning and after edit the automatic choice for the root partition. 
-<code> 
-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 
-</code> 
- 
-Do not select finish just yet, go up the menu. 
-<code> 
-Configure the Logical Volume Manager 
-  Write the changes to disks and configure LVM? YES 
-     Delete Logical Volume 
-       root 
-     Create Logial Volume 
-       xen-vg 
-         Logical Volume Name 
-           root 
-         Logical Volume Size 
-           8GB 
-     Finish 
-</code> 
- 
-Inspect the partition list and select the root entry created above. 
-<code> 
-LVM VG xen-vg, LV root - 8.0 GB Linux device-mapper (linear) 
-  #1 
-     Use-as: Ext4 journaling file system 
-     Mount point: / 
-     Mount options: [x] noatime 
-     Label: root 
-     Reserved Blocks: 1% 
-     Typical usage: standard 
-      
-     Done setting up the partition 
-</code> 
- 
-Finally, we finish creating the disk layout. 
-<code> 
-Finish partitioning and write changes to disk 
-  Write the changes to disks? YES 
-</code> 
- 
-After some time installing the base system, the package selection process will begin. 
- 
-First select a mirror, I chose UK. 
-<code> 
-United Kingdom => ftp.uk.debian.org 
-  Continue 
-</code> 
- 
-Wait for some time. 
-<code> 
-Participate in the package usage Survey? NO 
-</code> 
- 
-Finally we reach the software selection menu. 
- 
-It's important to deselect every entry using the space bar and only select ssh server. 
-<code> 
-[*] SSH server 
-  Continue 
-</code> 
- 
-Once installation is done the boot loader is installed and we are finished. 
-<code> 
-Install the GRUB boot loader to the master boot record? YES 
-</code> 
- 
-Remove the ejected CD. 
-<code> 
-Installation complete 
-  Continue 
-</code> 
- 
-=== Debian 8 update === 
-Login, update the system and then reboot it. 
-<code> 
-apt-get update 
-apt-get dist-upgrade 
-reboot 
-</code> 
- 
-=== 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 
-<code> 
-/bin/echo -e 'Package: systemd\nPin: origin ""\nPin-Priority: -1' > /etc/apt/preferences.d/systemd 
-/bin/echo -e '\nPackage: *systemd*\nPin: origin ""\nPin-Priority: -1' >> /etc/apt/preferences.d/systemd 
-/bin/echo -e '\nPackage: systemd:amd64\nPin: origin ""\nPin-Priority: -1' >> /etc/apt/preferences.d/systemd 
-/bin/echo -e '\nPackage: systemd:i386\nPin: origin ""\nPin-Priority: -1' >> /etc/apt/preferences.d/systemd 
-</code> 
- 
-=== XEN Debian 8 installation === 
- 
-Install Xen kernel and tools. 
-<code> 
-apt-get install --no-install-recommends xen-linux-system xen-tools lvm2 bridge-utils 
-dpkg-divert --divert /etc/grub.d/08_linux_xen --rename /etc/grub.d/20_linux_xen 
-echo 'GRUB_CMDLINE_XEN="dom0_mem=512M"' >> /etc/default/grub 
-update-grub 
-</code> 
- 
-Here is an example set up for an Ethernet bridge. 
- 
-Edit the interface file. 
-<code> 
-vi /etc/network/interfaces 
-</code> 
- 
-Change the IP addresses for your host and network. 
-<code> 
-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 
-</code> 
- 
-Finally, reboot into Xen. 
-<code> 
-reboot 
-</code> 
- 
-=== XEN VM installation === 
- 
-Using the Xen tools we create a Debian Wheezy virtual machine with 1GB RAM and 16GB disk space. 
-<code> 
-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 
-</code> 
- 
-The creation process will take some time, outputting the following. 
-<code> 
-General Information 
--------------------- 
-Hostname       :  vm0 
-Distribution   :  wheezy 
-Mirror         :  http://ftp.uk.debian.org/debian/ 
-Partitions     :  swap            1G    (swap) 
-                  /               16G   (ext4) 
-Image type     :  full 
-Memory size    :  1GB 
-Kernel path    :  /boot/vmlinuz-3.16.0-4-amd64 
-Initrd path    :  /boot/initrd.img-3.16.0-4-amd64 
- 
-Networking Information 
----------------------- 
-IP Address 1   : X.X.X.X [MAC: XX:XX:XX:XX:XX:XX] 
-Netmask        : 255.255.255.X 
-Gateway        : X.X.X.X 
- 
- 
-Creating swap on /dev/xen-vg/vm0-swap 
-Done 
- 
-Creating ext4 filesystem on /dev/xen-vg/vm0-disk 
-Done 
-Installation method: debootstrap 
- 
-Running hooks 
-Done 
- 
-No role scripts were specified.  Skipping 
- 
-Creating Xen configuration file 
-Done 
- 
-No role scripts were specified.  Skipping 
-Setting up root password 
-Generating a password for the new guest. 
-All done 
- 
- 
-Logfile produced at: 
-         /var/log/xen-tools/vm0.log 
- 
-Installation Summary 
---------------------- 
-Hostname        :  vm0 
-Distribution    :  wheezy 
-MAC Address     :  XX:XX:XX:XX:XX:XX 
-IP Address(es)  :  X.X.X.X  
-RSA Fingerprint :  XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX 
-Root Password   :  XXXXXXXXXXXXXXXXXXXXXXX 
-</code> 
- 
-=== XEN VM maintenance === 
- 
-List VM images. 
-<code> 
-xen-list-images 
-Name: vm0 
-Memory: 1024 MB 
-IP: X.X.X.X 
-</code> 
- 
-Run VM with a console. 
-<code> 
-xl create -c /etc/xen/vm0.cfg  
-</code> 
- 
-Run a VM silently without a console. 
-<code> 
-xl create -q /etc/xen/vm0.cfg 
-</code> 
- 
-Attach a console to a running VM. 
-<code> 
-xl console vm0 
-</code> 
- 
-List VMs. 
-<code> 
-xl list 
-Name                                        ID   Mem VCPUs      State   Time(s) 
-Domain-0                                       512         r-----     313.4 
-vm0                                          2  1024         -b----       5.5 
-</code> 
- 
-Shut down VM. 
-<code> 
-xl shutdown vm0 
-</code> 
- 
-Auto-start a VM at boot time. 
-<code> 
-mkdir -p /etc/xen/auto 
-ln /etc/xen/vm0.cfg /etc/xen/auto 
-</code> 
-=== 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. 
-<code> 
-xl list 
-Name                                        ID   Mem VCPUs      State   Time(s) 
-Domain-0   
-</code> 
- 
-Now inspect the volumes for our target. 
-<code> 
-lvs | grep vm0 
-  vm0-disk xen-vg -wi-a----- 16.00g 
-  vm0-swap xen-vg -wi-a-----  1.00g 
-</code> 
- 
-We will increase the size of the virtual disk and leave swap alone. 
-<code> 
-lvextend --size 24G /dev/xen-vg/vm0-disk 
-  Size of logical volume xen-vg/vm0-disk changed from 16.00 GiB (4096 extents) to 24.00 GiB (6144 extents). 
-  Logical volume vm0-disk successfully resized 
-lvs | grep vm0 
-  vm0-disk xen-vg -wi-a----- 24.00g                                                     
-  vm0-swap xen-vg -wi-a-----  1.00g   
-</code> 
- 
-We must extend the size of the file system contained in the volume. 
- 
-First check the disk for errors. 
-<code> 
-fsck -fy /dev/xen-vg/vm0-disk  
-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 
-/dev/mapper/xen--vg-vm0--disk: 15147/1048576 files (0.4% non-contiguous), 226267/4194304 blocks 
-</code> 
- 
-And now resize it. 
-<code> 
-resize2fs /dev/xen-vg/vm0-disk  
-resize2fs 1.42.12 (29-Aug-2014) 
-Resizing the filesystem on /dev/xen-vg/vm0-disk to 6291456 (4k) blocks. 
-The filesystem on /dev/xen-vg/vm0-disk is now 6291456 (4k) blocks long. 
-</code> 
- 
-The VM can now be restarted with an increased disk capacity. 
- 
-<code> 
-root@vm0:~# df -h / 
-Filesystem      Size  Used Avail Use% Mounted on 
-/dev/xvda2       24G  499M   22G   3% / 
-</code> 
-=== 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. 
-<code> 
-cat /proc/swaps  
-Filename                                Type            Size    Used    Priority 
-/dev/dm-1                               partition       6361084 0       -1 
-swapoff -a 
-</code> 
- 
-Now we inspect the volumes. 
-<code> 
-lvs 
-  LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert 
-  root     xen-vg -wi-ao----  7.45g 
-  swap_1   xen-vg -wi-a-----  6.07g 
-  vm0-disk xen-vg -wi-a----- 16.00g 
-  vm0-swap xen-vg -wi-a-----  1.00g 
-</code> 
- 
-We can reduce the size of an off-line swap partition with no dangerous side-effects, this wouldn't be true if it were a data partition. 
-<code> 
-lvreduce --size 2G /dev/xen-vg/swap_1  
-  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/swap_1 changed from 6.07 GiB (1553 extents) to 2.00 GiB (512 extents). 
-  Logical volume swap_1 successfully resized 
-</code> 
- 
-We can also increase the size, for example, if the above step was incorrect. 
-<code> 
-lvresize --size 5G /dev/xen-vg/swap_1 
-  Size of logical volume xen-vg/swap_1 changed from 2.00 GiB (512 extents) to 5.00 GiB (1280 extents). 
-  Logical volume swap_1 successfully resized 
-</code> 
- 
-Now we rebuild the swap. 
-<code> 
-mkswap /dev/xen-vg/swap_1  
-mkswap: /dev/xen-vg/swap_1: warning: wiping old swap signature. 
-Setting up swapspace version 1, size = 2097148 KiB 
-no label, UUID=3ac8493d-4dee-4309-9a01-953560ede126 
-</code> 
- 
-And remount it. 
-<code> 
-swapon -a 
-cat /proc/swaps  
-Filename                                Type            Size    Used    Priority 
-/dev/dm-1                               partition       2097148 0       -1 
-</code>