Home Travel Trip Journals Eastern Europe - 2006 Displaying items by tag: Howto
Thursday, 01 November 2012 07:33

Add a CD to a VM

Prerequisites

  • XCP/Xenserver

Adding a CD to a running VM is not a difficult task if you know which commands to use. By adding I mean we're going to insert a virtual CD disk into a virtual machine using our little virtual hands. ;-)

 

1. Get the name of your Virtual Machine

In this case the name is CentOS6 and the UUID is cefb9f88-0424-6701-5ba1-070490c69203.

[ root@cloud2 ~/bin ] xe vm-list
     uuid ( RO)           : cefb9f88-0424-6701-5ba1-070490c69203
          name-label ( RW): CentOS6
         power-state ( RO): running

 

2. Get the name of the CD disk

In this case our disk is named CentOS-6.3-x86_64-LiveCD.iso.

[ root@cloud2 ~/bin ] xe cd-list
    uuid ( RO)          : 0549c68a-e38d-4cd8-9974-ba0b9167ff5a
        name-label ( RW): CentOS-6.3-x86_64-LiveCD.iso

 

3. Identify a free Virtual Block Device number

Use the VM UUID that we retrieved in step 1.

[ root@cloud2 ~/bin ] xe vm-param-get uuid=cefb9f88-0424-6701-5ba1-070490c69203 \
param-name=allowed-VBD-devices 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15

 

4. Add the CD to the VM. Use the VM UUID from step 1, the CD name from step 2 and the VBD device number from step 3.

[ root@cloud2 ~/bin ] xe vm-cd-add uuid=cefb9f88-0424-6701-5ba1-070490c69203 \
device=5 cd-name=CentOS-6.3-x86_64-LiveCD.iso

 

5. Verify using xe vm-cd-list

 By using xe vm-cd-list we can list the CD's currently plugged into our VM.

 

[ root@cloud2 ~/bin ] xe vm-cd-list uuid=cefb9f88-0424-6701-5ba1-070490c69203 
CD 0 VBD:
uuid ( RO)             : 40f6b5c9-14fd-4379-d82c-d0ff34472a04
    vm-name-label ( RO): 955300270
            empty ( RO): false
       userdevice ( RW): 5


CD 0 VDI:
uuid ( RO)             : 0549c68a-e38d-4cd8-9974-ba0b9167ff5a
       name-label ( RW): CentOS-6.3-x86_64-LiveCD.iso
    sr-name-label ( RO): NFS ISO
     virtual-size ( RO): 725614592

 

6. Unplugging the CD disk

When done with the CD you can unplug it even easier. We specify the VM UUID and tell it to eject the CD which it does. 

 

 [ root@cloud2 ~/bin ] xe vm-cd-eject uuid=cefb9f88-0424-6701-5ba1-070490c69203

 

Published in Xenserver Howtos
Monday, 05 November 2012 10:26

Add a hard disk to a VM

Installing from an XCP/Xenserver template usually gives you one Virtual Disk to install the operating system on. Depending on your needs this disk may not be large enough. Following is a tutorial on how to add an additional disk to a virtual machine.

Terminology: 

 

Virtual Machine - A virtual machine is a computer that's virtualized and running on a hypervisor. In our case the hypervisor is Xen Cloud Platform/Xenserver. The Virtual Machine can be running any operating system.

Virtual Disk Image - Think of a Virtual Disk Image as a hard drive.

Storage Repository - A "box" storing Virtual Disk Images. Think of this as an external box storing virtual hard drives. The virtual hard drives are the Virtual Disk Images mentioned above.

Virtual Block Device - A Virtual Block Device connects a Virtual Disk Image to a Virtual Machine. In traditional computer terms you could think of it as the cable. 

The process for adding a hard drive to a real computer

  1. Insert the disk in the hard drive box
  2. Connect the cable to the hard drive box
  3. Insert the cable into the Computer

The process of adding a new Virtual Disk for a Virtual Machine is 

  1. Create a new Virtual Disk Image
  2. Create a new Virtual Block Device for it
  3. Connect the Virtual Block Device to the Virtual Machine

 

1. Get available free space

You will need to know how much free space is available on your Storage Repository.

[ root@cloud2 ~ ] xe sr-list
uuid ( RO)                : 36bf480a-5df9-4453-50f0-2bac4a86cb42
              name-label ( RW): localsr-cloud1
    name-description ( RW): 
                         host ( RO): cloud1.acs.edcc.edu
                        type ( RO): lvm
           content-type ( RO): user

Now that we have the Storage Repository's UUID number (36bf480a-5df9-4453-50f0-2bac4a86cb42) we can use xe sr-list again to give us the physical size and how much space is being utilized.

[ root@cloud2 ~ ] xe sr-list uuid=36bf480a-5df9-4453-50f0-2bac4a86cb42 \
params=physical-utilisation,physical-size
physical-utilisation ( RO) : 214752559104 physical-size ( RO): 991600574464

Quick math (991600574464 - 214752559104 = 776848015360) shows us that we have about 776 MB free.

2. Create the Virtual Disk Image

Now that we know the available space on the storage repository we can make a new Virtual Disk Image using xe vdi-create.

[ root@cloud2 ~ ] xe vdi-create sr-uuid=bd1ac90d-7c23-dc07-dfa3-edc9f1cd73c4 \
name-label=DATADISK type=user virtual-size=100GiB
ee9c5daa-392c-4a0d-a5c1-4ebb7caabd73

This command outputs the VDI's UUID. You can get information about any VDI using the xe vdi-list command.

[ root@cloud2 ~ ] xe vdi-list uuid=ee9c5daa-392c-4a0d-a5c1-4ebb7caabd73 
uuid ( RO)                : ee9c5daa-392c-4a0d-a5c1-4ebb7caabd73
          name-label ( RW): DATADISK
 name-description ( RW): 
                  sr-uuid ( RO): bd1ac90d-7c23-dc07-dfa3-edc9f1cd73c4
            virtual-size ( RO): 107374182400
               sharable ( RO): false
             read-only ( RO): false

The result of xe vm-list shows that the virtual size of the VDI is about 100 GB and it's name-label is DATADISK. To add this new disk to a VM I'll need to get the VM's UUID number by using xe vm-list.

[ root@cloud2 ~ ] xe vm-list name-label=CentOS6
     uuid ( RO)           : cefb9f88-0424-6701-5ba1-070490c69203
     name-label ( RW): CentOS6
      power-state ( RO): running

 

3. Get the available Virtual Block Device numbers

We will also need to know which Virtual Block Device numbers are available. We can use the xe vm-param-get command for this.

[ root@cloud2 ~ ] xe vm-param-get uuid=cefb9f88-0424-6701-5ba1-070490c69203 \ 
param-name=allowed-VBD-devices
7; 8; 9; 10; 11; 12; 13; 14; 15

In summary:

  1. VDI UUID is ee9c5daa-392c-4a0d-a5c1-4ebb7caabd73
  2. VM UUID is cefb9f88-0424-6701-5ba1-070490c69203
  3. Available VBD numbers are 7, 8, 9, 10, 11, 12, 13, 14 and 15

 

4. Create the Virtual Block Device

Create the Virtual Block Device (VBD) using the xe vbd-create command and the VM UUID, VDI UUID and the first available VBD number.

[ root@cloud2 ~ ] xe vbd-create device=7 vm-uuid=cefb9f88-0424-6701-5ba1-070490c69203 \ 
vdi-uuid=ee9c5daa-392c-4a0d-a5c1-4ebb7caabd73 bootable=false mode=RW type=Disk
333ab620-3ee1-0420-d31a-217e4ef1df45

I created Virtual Block Device 7 (device=7). Using device=0 would have given me a /dev/dev/xvda which I already have. The xe-param-get command showed my first available Virtual Block Device number was 7. Notice that we associated the Virtual Disk Image (VDI) to the Virtual Machine (VM) by using a Virtual Block Device (VBD).

5. Plug in the disk to the VM

The VM won't see the disk yet as it hasn't been "plugged in". We can do this by either rebooting the VM or using the xe vbd-plug command. Let's plug the VBD into the running VM.

[ root@cloud2 ~ ]  xe vbd-plug uuid=333ab620-3ee1-0420-d31a-217e4ef1df45

6. Verify that it worked

Log into the VM via ssh or xenconsole and see if the disk appeared by catting /proc/partitions.

[root@Centos6 ~]# cat /proc/partitions
major minor  #blocks  name

 202        0    8388608 xvda
 202        1     102400 xvda1
 202        2    8285184 xvda2
 253        0    7733248 dm-0
 253        1     524288 dm-1
 202       16  104857600 xvdb

Published in Xenserver Howtos
Saturday, 14 January 2012 01:34

Automated install of CentOS 6 VM (32 bit)

Note: Updated for XCP 1.5b/1.6

Install Type

  • Non-interactive
  • Network boot
  • Commandline
  • Paravirtualized

Prerequisites

  • XCP/Xenserver
  • Access to Internet
  • Working DHCP server
  • Working DNS name resolution

Introduction

This tutorial was written in the spirit of my CentOS 6 virtual machine (32 bit) installation on Xen howto which was based on the CentOS 5 version of the same. In those tutorials I created a disk, downloaded a kernel, kickstart file plus a xen config file which installed CentOS using the kickstart file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a CentOS mirror locally then downloading my files and editing them.

I've recently migrated a lot of my XEN systems to Xen Cloud Platform and it's a very different animal indeed. However, I still needed a system of creating CentOS Virtual Machines in that same manner. I didn't want to download a CentOS install DVD or need a graphical login to install the OS thus this tutorial was born.

It uses the very same CentOS 6 kickstart file from my site as the Xen tutorial. It also uses the very same CentOS 6 repositories on the Internet so in a lot aspects it IS the same tutorial crafted for XCP but will be a bit shorter.

 More after the jump.

Published in Xenserver Howtos
Thursday, 17 November 2011 09:55

Automated install of CentOS 6 VM (64 bit)

Note: updated for XCP 1.5b/1.6 and Xenserver 6.x.

Install Type

  • Non-interactive
  • Network boot
  • Commandline
  • Paravirtualized

Prerequisites

  • XCP/Xenserver
  • Access to Internet
  • Working DHCP server
  • Working DNS name resolution

Introduction

This tutorial was written in the spirit of my CentOS 6 virtual machine (64 bit) installation on Xen howto which was based on the CentOS 5 version of the same. In those tutorials I created a disk, downloaded a kernel, kickstart file plus a xen config file which installed CentOS using the kickstart file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a CentOS mirror locally then downloading my files and editing them.

I've recently migrated a lot of my XEN systems to Xen Cloud Platform and it's a very different animal indeed. However, I still needed a system of creating CentOS Virtual Machines in that same manner. I didn't want to download a CentOS install DVD or need a graphical login to install the OS thus this tutorial was born.

It uses the very same CentOS 6 kickstart file from my site as the Xen tutorial. It also uses the very same CentOS 6 repositories on the Internet so in a lot aspects it IS the same tutorial crafted for XCP but will be a bit shorter.

 

Published in Xenserver Howtos
Thursday, 14 August 2014 23:48

Automated install of CentOS 7 VM (64 bit)

Install Type

  • Non-interactive
  • Network boot
  • Commandline
  • Paravirtualized

Prerequisites

  • XCP/Xenserver
  • Access to Internet
  • Working DHCP server
  • Working DNS name resolution

Introduction

This tutorial was written in the spirit of my CentOS 6 virtual machine (64 bit) installation on Xen howto. In that tutorial I created a disk, downloaded a kernel, kickstart file plus a xen config file which installed CentOS using the kickstart file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a CentOS mirror locally then downloading my files and editing them.

I now use Xenserver and it's a very different animal indeed. However, I still needed a system of creating CentOS Virtual Machines in that same manner. I didn't want to download a CentOS install DVD or need a graphical login to install the OS thus this tutorial was born.

This tutorial is for CentOS version 7. 

 

Published in Xenserver Howtos

Note: This is not totally automated yet. I need to fix several things.

Install Type

  • Non-interactive
  • Network boot
  • Commandline
  • Paravirtualized

Prerequisites

  • XCP/Xenserver
  • Access to Internet
  • Working DHCP server
  • Working DNS name resolution
 

Introduction

In this tutorial I create a disk, download a kernel, preseed file and install Debian Wheezy using the preseed file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a Ubuntu mirror locally then downloading my files and editing them.

 

 Note: This tutorial is designed so you can copy and paste the text inside the boxes. I don't actually type any of this in and neither should you.

 

1. Getting the network info

This line gets the Network UUID for xenbr0. If you're using a different bridge you will want to insert it here. Get a list of XCP networks with xe network-list. This network is connected to the outside interface. This tutorial requires there to be a DHCP server on this network answering requests and providing network access to the Internet.

NETUUID=$(xe network-list bridge=xenbr0 --minimal)

2. Creating the VM and setting parameters

Here we create a new template from the Debian Squeeze template. Then we create the VM from the new Debian template, create a network interface and add it to our network from step one. Additional settings are for configuring the install repository and specifying thepreseed file from my site. The last setting turns off VNC so we can watch the install via a text console (very important in my environment).  Even if you can't see all the text below just highlight and paste. The text is there even if it's not visible.

 

TMPLUUID=$(xe template-list | grep -B1 'name-label.*Debian.*Squeeze.*64-bit' | awk -F: '/uuid/{print $2}'| tr -d " ")
VMUUID=$(xe vm-install new-name-label="Debian Wheezy" template=${TMPLUUID}) 
xe vif-create vm-uuid=${VMUUID} network-uuid=${NETUUID} mac=random device=0
xe vm-param-set uuid=${VMUUID} other-config-install-repository=http://ftp.us.debian.org/debian/
xe vm-param-set uuid=${VMUUID} other-config:debian-release=wheezy
xe vm-param-set uuid=${VMUUID} other-config:install-methods=http,cdrom,ftp,nfs
xe vm-param-set uuid=${VMUUID} PV-args="netcfg/get_hostname=Wheezy debian-installer/locale=en_US console-keymaps-at/keymap=us console-setup/layoutcode=us console-setup/ask_detect=false interface=eth0 netcfg/disable_dhcp=false preseed/url=http://grantmcwilliams.com/files/preseed-debian-wheezy.cfg console=hvc0"
xe vm-param-set uuid=${VMUUID} other-config:disable_pv_vnc=1

3. Starting the VM and watching the install

The VM installs without any interaction from the user at this point. It is however, nice to watch it using xenconsole. Once it's done installing it will shutdown.

If you're using XCP 1.0/1.1

xe vm-start uuid=$VMUUID
DOMID=$(xe vm-list uuid=${VMUUID} params=dom-id --minimal)
/usr/lib/xen/bin/xenconsole ${DOMID}

If you're using XCP 1.5b/1.6

xe vm-start uuid=$VMUUID ; xe console uuid=$VMUUID

4. Starting the VM and configuring settings

We need to boot the VM up again and using xenconsole log in to reset the finish configuration.

If you're using XCP 1.0/1.1

xe vm-start uuid=$VMUUID
DOMID=$(xe vm-list uuid=${VMUUID} params=dom-id --minimal)
/usr/lib/xen/bin/xenconsole ${DOMID}

If you're using XCP 1.5b/1.6

xe vm-start uuid=$VMUUID
xe console uuid=$VMUUID

Now that your Debian Wheezy VM is running you can login. The password was automatically set by the preseed file.

  • Username: debian
  • Password: password

Reset the ubuntu users password.  If you want to keep the IP assignment dynamic note the ip address.

5. Shutting down the VM and re-enabling VNC

If you're going to use XVP or some other method of connecting to the VMs direct VNC connection you'll need to enable it.

xe vm-shutdown uuid=$VMUUID
xe vm-param-remove uuid=${VMUUID} other-config:disable_pv_vnc
xe vm-start uuid=$VMUUID

7. Export our VM for safe keeping

Before you start modifying the base Debian Wheezy image you should back it up.

xe vm-export uuid=$VMUUID filename=DebianWheezy-base.xva

Be aware that you may not have enough space on the Control Domain's disk to export it. A good solution (and shorter than explaining how to add disks to the control domain) is to mount an nfs volume and export it there.

mount nfsserver:/share /media/share
xe vm-export uuid=$VMUUID filename=/media/share/DebianWheezy-base.xva

This would mount the NFS share on nfsserver to /media/share. The exported disk would be saved on the NFS share.

 

Published in Xenserver Howtos
Sunday, 09 November 2014 21:36

Automated install of Fedora 20 VM (32 bit)

Note: updated for XCP 1.5b/1.6 and Xenserver 6.x

Install Type

  • Non-interactive
  • Network boot
  • Commandline
  • Paravirtualized

Prerequisites

  • XCP/Xenserver
  • Access to Internet
  • Working DHCP server
  • Working DNS name resolution

Introduction

This tutorial was originally written for CentOS and has been adapted for Fedora 20. 

Published in Xenserver Howtos
Sunday, 09 November 2014 00:00

Automated install of Fedora 20 VM (64 bit)

Note: updated for XCP 1.5b/1.6 and Xenserver 6.x

Install Type

  • Non-interactive
  • Network boot
  • Commandline
  • Paravirtualized

Prerequisites

  • XCP/Xenserver
  • Access to Internet
  • Working DHCP server
  • Working DNS name resolution

Introduction

This tutorial was originally written for CentOS and has been adapted for Fedora 20 x86_64. 

Published in Xenserver Howtos

Note: This has not really been tested yet. I wanted to get it up here so people can start using it and I can work on it.

Install Type

  • Non-interactive
  • Network boot
  • Commandline
  • Paravirtualized

Prerequisites

  • XCP/Xenserver
  • Access to Internet
  • Working DHCP server
  • Working DNS name resolution
 

Introduction

In this tutorial I create a disk, download a kernel, preseed file and install Kali LInux using the preseed file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a Ubuntu mirror locally then downloading my files and editing them.

 

 Note: This tutorial is designed so you can copy and paste the text inside the boxes. I don't actually type any of this in and neither should you.

 

1. Getting the network info

This line gets the Network UUID for xenbr0. If you're using a different bridge you will want to insert it here. Get a list of XCP networks with xe network-list. This network is connected to the outside interface. This tutorial requires there to be a DHCP server on this network answering requests and providing network access to the Internet.

NETUUID=$(xe network-list bridge=xenbr0 --minimal)

 

2. Creating the VM and setting parameters

Here we create a new template from the Debian Squeeze template. Then we create the VM from the new Debian template, create a network interface and add it to our network from step one. Additional settings are for configuring the install repository and specifying thepreseed file from my site. The last setting turns off VNC so we can watch the install via a text console (very important in my environment).  Even if you can't see all the text below just highlight and paste. The text is there even if it's not visible.

 

TMPLUUID=$(xe template-list | grep -B1 'name-label.*Debian.*Squeeze.*64-bit' | awk -F: '/uuid/{print $2}'| tr -d " ")
VMUUID=$(xe vm-install new-name-label="Kali Linux" template=${TMPLUUID}) 
xe vif-create vm-uuid=${VMUUID} network-uuid=${NETUUID} mac=random device=0
xe vm-param-set uuid=${VMUUID} other-config-install-repository=http://http.kali.org
xe vm-param-set uuid=${VMUUID} other-config:debian-release=kali
xe vm-param-set uuid=${VMUUID} other-config:install-methods=http,cdrom,ftp,nfs
xe vm-param-set uuid=${VMUUID} PV-args="netcfg/get_hostname=Kali debian-installer/locale=en_US console-keymaps-at/keymap=us console-setup/layoutcode=us console-setup/ask_detect=false interface=eth0 netcfg/disable_dhcp=false preseed/url=http://grantmcwilliams.com/files/preseed-kali-linux.cfg console=hvc0"
xe vm-param-set uuid=${VMUUID} other-config:disable_pv_vnc=1

 

3. Starting the VM and watching the install

The VM installs without any interaction from the user at this point. It is however, nice to watch it using xenconsole. Once it's done installing it will shutdown.

If you're using XCP 1.0/1.1

xe vm-start uuid=$VMUUID
DOMID=$(xe vm-list uuid=${VMUUID} params=dom-id --minimal)
/usr/lib/xen/bin/xenconsole ${DOMID

If you're using XCP 1.5b/1.6

xe vm-start uuid=$VMUUID ; xe console uuid=$VMUUID

4. Starting the VM and configuring settings

We need to boot the VM up again and using xenconsole log in to reset the finish configuration.

If you're using XCP 1.0/1.1

xe vm-start uuid=$VMUUID
DOMID=$(xe vm-list uuid=${VMUUID} params=dom-id --minimal)
/usr/lib/xen/bin/xenconsole ${DOMID}

 

If you're using XCP 1.5b/1.6

xe vm-start uuid=$VMUUID
xe console uuid=$VMUUID

 

Now that your Kali Linux VM is running you can login. The password was automatically set by the preseed file.

  • Username: root
  • Password: password

Reset the root users password.  If you want to keep the IP assignment dynamic note the ip address.

5. Shutting down the VM and re-enabling VNC

If you're going to use XVP or some other method of connecting to the VMs direct VNC connection you'll need to enable it.

xe vm-shutdown uuid=$VMUUID
xe vm-param-remove uuid=${VMUUID} other-config:disable_pv_vnc
xe vm-start uuid=$VMUUID

 

7. Export our VM for safe keeping

Before you start modifying the base Kali Linux image you should back it up.

xe vm-export uuid=$VMUUID filename=Kali-Linux-base.xva

 

 

Be aware that you may not have enough space on the Control Domain's disk to export it. A good solution (and shorter than explaining how to add disks to the control domain) is to mount an nfs volume and export it there.

mount nfsserver:/share /media/share
xe vm-export uuid=$VMUUID filename=/media/share/Kali-Linux-base.xva

 

This would mount the NFS share on nfsserver to /media/share. The exported disk would be saved on the NFS share.

 

Published in Xenserver Howtos

Note: Updated to work with XCP 1.5b/1.6

Install Type

  • Non-interactive
  • Network boot
  • Commandline
  • Paravirtualized

Prerequisites

  • XCP/Xenserver
  • Access to Internet
  • Working DHCP server
  • Working DNS name resolution
 

Introduction

In this tutorial I create a disk, download a kernel, preseed file and install Ubuntu using the preseed file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a Ubuntu mirror locally then downloading my files and editing them.

 

Published in Xenserver Howtos
Page 1 of 4