2.4.
Virtualizando un Ubuntu Desktop
Subir un nivel
En este ejemplo queremos crear un Ubuntu Intrepid Hearon, y como queremos que esté paravirtualizado, utilizaremos misma técnica que hemos utilizado antes al crear el servidor virtual con debian: debootstrap.
Para poder hacerlo, es imprescindible que en la carpeta /usr/lib/xen-tools/ del servidor fÃsico exista un enlace o "soft link" con el nombre intrepid.d . Si no existiera no sabrÃa como instalarlo.
root@IMH01XEN01:~# cd /usr/lib/xen-tools/
root@IMH01XEN01:/usr/lib/xen-tools# ls -la
total 72
drwxr-xr-x 9 root root 4096 2008-10-24 10:37 .
drwxr-xr-x 87 root root 32768 2008-12-10 17:46 ..
drwxr-xr-x 2 root root 4096 2008-10-24 10:37 centos-4.d
drwxr-xr-x 2 root root 4096 2008-10-24 10:37 centos-5.d
-rwxr-xr-x 1 root root 4409 2008-04-06 03:12 common.sh
drwxr-xr-x 2 root root 4096 2008-10-24 10:37 dapper.d
drwxr-xr-x 2 root root 4096 2008-10-24 10:37 debian.d
drwxr-xr-x 2 root root 4096 2008-12-10 17:53 edgy.d
lrwxrwxrwx 1 root root    8 2008-10-24 10:37 etch.d -> debian.d
lrwxrwxrwx 1 root root   15 2008-10-24 10:37 fedora-core-4.d -> fedora-core-6.d
lrwxrwxrwx 1 root root   15 2008-10-24 10:37 fedora-core-5.d -> fedora-core-6.d
drwxr-xr-x 2 root root 4096 2008-10-24 10:37 fedora-core-6.d
lrwxrwxrwx 1 root root   15 2008-10-24 10:37 fedora-core-7.d -> fedora-core-6.d
lrwxrwxrwx 1 root root    6 2008-10-24 10:37 feisty.d -> edgy.d
drwxr-xr-x 2 root root 4096 2008-10-24 10:37 gentoo.d
lrwxrwxrwx 1 root root    6 2008-10-24 10:37 gutsy.d -> edgy.d
lrwxrwxrwx 1 root root    6 2008-10-24 10:37 hardy.d -> edgy.d
lrwxrwxrwx 1 root root    8 2008-10-24 10:37 lenny.d -> debian.d
lrwxrwxrwx 1 root root    8 2008-10-24 10:37 sarge.d -> debian.d
lrwxrwxrwx 1 root root    8 2008-10-24 10:37 sid.d -> debian.d
Como no existe, lo creamos nosotros:
root@IMH01XEN01:/usr/lib/xen-tools# ln -s edgy.d intrepid.d
Hay que hacer algo parecido para debootstrap:
cd /usr/share/debootstrap/scripts/Â
ln -s edgy intrepid
Ahora con este comando creamos la máquina virtual:
root@IMH01XEN01:/usr/lib/xen-tools# xen-create-image install-method=deboottstrap --hostname=XenUbuntuDesktop01 --dist=intrepid --mirror=http://es.archive.ubuntu.com/ubuntu/ --lvm=volgroupxen --fs=ext3 --dhcp --kernel=/2.6.24-21-xen --force --initrd=/boot/initrd.img-2.6.24-21-xen --arch=amd64 --size=10G –swap=1G
Este es el resultado:
General Information
--------------------
Hostname      : XenUbuntuDesktop01
Distribution  : intrepid
Partitions    : swap           1G   (swap)
                 /              10G  (ext3)
Image type    : full
Memory size   : 128Mb
Kernel path   : /2.6.24-21-xen
Initrd path   : /boot/initrd.img-2.6.24-21-xen
Networking Information
----------------------
IP Address    : DHCP [MAC: 00:16:3E:84:99:66]
Removing /dev/volgroupxen/XenUbuntuDesktop01-swap - since we're forcing the install
Removing /dev/volgroupxen/XenUbuntuDesktop01-disk - since we're forcing the install
Creating swap on /dev/volgroupxen/XenUbuntuDesktop01-swap
Done
Creating ext3 filesystem on /dev/volgroupxen/XenUbuntuDesktop01-disk
Done
Installation method: debootstrap
Done
Running hooks
Done
No role scripts were specified. Skipping
Creating Xen configuration file
Done
All done
Logfile produced at:
    /var/log/xen-tools/XenUbuntuDesktop01.log
Si queremos ver cómo ha ido la instalación, podemos mirar el log:
/var/log/xen-tools/XenUbuntuDesktop01.log
Antes de arrancar, repasamos la configuración. Editamos el fichero de configuración:
cd /etc/xen
nano XenUbuntuDesktop01.cfg
En el parámetro kernel yo tenÃa esto:
kernel     = '/2.6.24-21-xen'Â
Y lo he dejado asÃ:
kernel     = '/boot/vmlinuz-2.6.24-21-xen'
Ahora para poner en marcha la máquina virtual:
xm create XenUbuntuDesktop01.cfg ; xm console XenUbuntuDesktop01
Como resultado nos da una consola de login, y podrás acceer como root (sin password).
La IP la coge a través de DHCP, tendrás que ejecutar ifconfig para ver cual tiene.
Por defecto no se instala gnome, y como nosotros lo vamos a necesitar lo instalamos:
apt-get install xorg gnome-core
Para poder conectarnos al Ubuntu Desktop mediante VNC primero tenemos que instalar el servidor de VNC en el ubuntu virtual
sudo apt-get install vnc4server
Ahora hay que configurarlo. En caso contrario al conectarnos no podremos utilizar Gnome. Instalamos nano y editamos el fichero de configuración.
apt-get install nano
nano .vnc/xstartup
Esto es lo que trae por defecto:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
Lo dejamos asÃ:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
unset SESSION_MANAGER
gnome-session &
Ahora arrancamos vncserver:
vncserver :1
Nos pide que configuremos un password. Hay que apuntarlo porque lo necesitaremos para poder conectarnos desde otra máquina.
En adelante podremos conectarnos al Ubuntu virtual utilizando VNC.