Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Main Support Categories > Installation & Upgrades
Register Reset Password Forum Help Forum Council Today's Posts

Installation & Upgrades
For questions about upgrading and installation of your new Ubuntu OS.

View Poll Results: Please rate the usefulness of this tutorial:
useful 1 50.00%
not useful (already implemented a solution) 0 0%
not useful (don't need it) 1 50.00%
no idea what it is 0 0%
Voters: 2. You may not vote on this poll

 
Thread Tools Display Modes
Old 1 Week Ago   #1
ac4000
5 Cups of Ubuntu
 
ac4000's Avatar
 
Join Date: Aug 2006
My beans are hidden!
Post HOW TO: install Lucid/10.04 LTS on Xen 3.1 with xen-tools/debootstrap

Following are the steps I took to install Lucid on Xen using Steve Kemp's fantastic xen-tools package. I did some cursory research and couldn't find any Lucid templates, so I modified the existing templates. It's not very elegant, but it appears to have gotten the job done (many VMs running for days now without problems).

UPDATE: The dev version of xen-tools, and presumably debootstrap, has lucid/pygrub support, so pretty soon these instructions will be redundant (i.e., you might take a look at those versions as well/instead).

System:
  • dom0 running Debian Lenny with kernel 2.6.26-2-xen-amd64 and Xen 3.2 (community, of course)
  • domU Ubuntu 10.04 LTS
  1. Copy files from edgy.d template (latest available) to lucid.d.
    Code:
    cp -r /usr/lib/xen-tools/edgy.d /usr/lib/xen-tools/lucid.d
  2. Link debootstrap gutsy profile (latest available) to lucid.
    Code:
    ln -s /usr/share/debootstrap/scripts/gutsy /usr/share/debootstrap/scripts/lucid
  3. Link current xen directory (many tools expect to find it here).
    Code:
    ln -s /usr/lib/xen-3.2-1 /usr/lib/xen
  4. Link pygrub to /usr/bin (many tools expect to find it here).
    Code:
    ln -s /usr/lib/xen/bin/pygrub /usr/bin/pygrub
  5. Modify /etc/xen-tools/xm.tmpl so that it lists root device first (pygrub requires this to work properly); replace the entire section following "# Disk device(s)." and preceding "# Hostname" with:
    Code:
    {
      for ( my $i = 0; $i <= $#PARTITIONS; $i++ )
      {
          if ( $PARTITIONS[$i]{'mountpoint'} eq '/' )
          {
              $OUT .= "root        = '/dev/$device" . ($i + 1) . " ro'\n";
          }
      }
      $OUT .= "disk        = [\n";
      for ( my $i = 0; $i <= $#PARTITIONS; $i++ )
      {
          if ( $PARTITIONS[$i]{'mountpoint'} eq '/' )
          {
                $OUT .= "                  '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n";
          }
      }
      for ( my $i = 0; $i <= $#PARTITIONS; $i++ )
      {
          if ( $PARTITIONS[$i]{'mountpoint'} ne '/' )
          {
                $OUT .= "                  '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n";
          }
      }
      $OUT .= "              ]\n";
    }
  6. Replace the entire contents of /usr/lib/xen-tools/lucid.d/30-disable-gettys with the following (to work with non-event.d, non-inittab, hvc0 setup):
    Code:
    #!/bin/sh
    #
    #  This script comments out all virtual terminals which aren't on the
    # first console - that must remain so that 'xm console ...' works
    # correctly.
    #
    # Steve
    # --
    # http://www.steve.org.uk/
    #
    # Updated for Lucid; DDS/ABC
    #
    
    prefix=$1
    
    
    #
    #  Source our common functions
    #
    if [ -e /usr/lib/xen-tools/common.sh ]; then
        . /usr/lib/xen-tools/common.sh
    else
        . ./hooks/common.sh
    fi
    
    
    #
    # Log our start
    #
    logMessage Script $0 starting
    
    #
    #  Remove the links for upstart
    #
    rm ${prefix}/etc/init/tty[!1].conf
    
    
    #
    #  Are we using an alternative serial device?
    #
    if [ ! -z "${serial_device}" ]; then
    
        serial_device=`basename ${serial_device}`
    
        # Let the user know.
        logMessage "Replacing default serial device (tty1) with ${serial_device}; having destroyed the rest"
    
        # replace existing device.
        mv ${prefix}/etc/init/tty1.conf ${prefix}/etc/init/${serial_device}.conf
        sed -i -e s/tty1/${serial_device}/ ${prefix}/etc/init/${serial_device}.conf
    
        # make sure that it is allowed to login.
        echo $serial_device >> ${prefix}/etc/securetty
    fi
    
    #
    #  Log our finish
    #
    logMessage Script $0 finished
  7. Create /etc/xen-tools/role.d/pygrub, and set its executable bit, with the following contents, to allow booting from the guest kernel, which is what I prefer (if you prefer to boot from dom0-supplied kernels, you can skip this); the script is based on Wejn's tremendously helpful pygrub script, which I modified to install a newer kernel version and the linux-virtual package; note that you'll need to use this role and the pygrub role:
    Code:
    #!/bin/sh
    #
    #  Configure the new image to be suitable for booting via pygrub
    #
    # Wejn
    # --
    # http://wejn.org/
    #
    # Updated for Lucid; DDS/ABC
    #
    
    
    prefix=$1
    
    
    #
    #  Source our common functions - this will let us install a Debian package.
    #
    if [ -e /usr/lib/xen-tools/common.sh ]; then
        . /usr/lib/xen-tools/common.sh
    else
        echo "Installation problem"
    fi
    
    
    #
    #  Update APT lists.
    #
    chroot ${prefix} /usr/bin/apt-get update
     
    
    #
    #  Install the packages
    #
    set -e
    installDebianPackage ${prefix} perl
    installDebianPackage ${prefix} libklibc
    installDebianPackage ${prefix} klibc-utils
    installDebianPackage ${prefix} initramfs-tools
    #installDebianPackage ${prefix} linux-image-2.6-xen-amd64
    installDebianPackage ${prefix} linux-virtual
    
    # Force initrd if none exists
    echo ${prefix}/boot/initrd* | grep -q 2\\.6
    if [ $? -ne 0 ]; then
            chroot ${prefix} update-initramfs -c -k `ls -1 ${prefix}/lib/modules/ | head -n 1`
    fi
    
    # Generate grub menu.lst
    LNZ=`basename \`ls -1 ${prefix}/boot/vmlinuz*|tail -n 1\``
    RD=`basename \`ls -1 ${prefix}/boot/initrd*|tail -n 1\``
    mkdir -p ${prefix}/boot/grub
    cat - <<-EOF > ${prefix}/boot/grub/menu.lst
    default         0
    timeout         5
    
    title           Debian/Ubuntu
    root            (hd0,0)
    kernel          /boot/$LNZ root=/dev/xvda2 ro
    initrd          /boot/$RD
    EOF
Be sure to edit your /etc/xen-tools/xen-tools.conf as appropriate (e.g., changing the distribution to lucid) and use --role=udev,pygrub when you run xen-create-image; also, comment out the kernel and initrd lines so xm defaults to pygrb; finally, you may also want to add the line "serial_console = hvc0" (no quotes) so that Xen provides the correct console based on the 30-disable-gettys script, above. (A diff between my working xen-tools.conf and the package version is at post #3, below). Note that this will create a VM with a root user (and password that you set if you enabled that option in xen-tools.conf). I've written a few roles to secure the installation, including disabling the root password, which I'll try to post if I have some time.

I can produce diffs, if there's interest in the above. Please jump in and modify the above, add to it, etc. As I said, it's not a very elegant solution, but I needed it quickly. (I also must apologize in advance if I'm not able to keep up with questions here, if there are any--we're a bit slammed with work at the moment.)

Last edited by ac4000; 6 Days Ago at 12:23 PM..
ac4000 is offline   Reply With Quote
Old 6 Days Ago   #2
tbaptista
First Cup of Ubuntu
 
Join Date: Oct 2005
Beans: 8
Re: HOW TO: install Lucid/10.04 LTS on Xen 3.1 with xen-tools/debootstrap

Great tutorial. Thanks.

I have one question.

The cfg file created for the domU had the normal kernel and initrd lines and not the pygrub bootloader line. I had to change that to enable pygrub.

And also the console stops working midway the boot sequence. After the following lines:

Quote:
Begin: Running /scripts/init-bottom ...
Done.
mountall: Disconnected from Plymouth
Do you have any idea why? I tried to put in the cfg file the extra parameter console=hvc0, but it didn't make any difference.

Best Regards,
Tiago Baptista
tbaptista is offline   Reply With Quote
Old 6 Days Ago   #3
ac4000
5 Cups of Ubuntu
 
ac4000's Avatar
 
Join Date: Aug 2006
My beans are hidden!
Re: HOW TO: install Lucid/10.04 LTS on Xen 3.1 with xen-tools/debootstrap

Tiago, thanks for pointing that out. In the tutorial, I missed the part where you need to comment out the kernel and initrd lines in xen-tools.conf, which causes xm to boot with pygrub (no need to call it explicitly). I will update the above.

As for the console disconnection, I have the line
Code:
serial_console = hvc0
in xen-tools.conf, but this is supposed to be the default. Try it and see if it changes things and, if it does, I will update the above.

Here's the diff between the package version and my xen-tools.conf:

Code:
--- xen-tools.conf      2008-09-29 19:08:11.000000000 -0400
+++ /etc/xen-tools/xen-tools.conf       2010-05-10 13:00:39.000000000 -0400

-# lvm = skx-vg
+lvm = xenvg

-swap   = 128Mb    # Swap size
+swap   = 512Mb    # Swap size

-dist   = etch     # Default distribution to install.
+dist   = lucid    # Default distribution to install.

-# passwd = 1
+#passwd = 1

-kernel      = /boot/vmlinuz-`uname -r`
-initrd      = /boot/initrd.img-`uname -r`
+# Undefined, to use pygrub.
+#kernel      = /boot/vmlinuz-`uname -r`
+#initrd      = /boot/initrd.img-`uname -r`

-# arch=[i386|amd64]
+arch=amd64

-# serial_device = hvc0 #default
+serial_device = hvc0 #default
+# serial_device = xvc0

-# disk_device = xvda #default
+disk_device = xvda #default
ac4000 is offline   Reply With Quote
Old 6 Days Ago   #4
tbaptista
First Cup of Ubuntu
 
Join Date: Oct 2005
Beans: 8
Re: HOW TO: install Lucid/10.04 LTS on Xen 3.1 with xen-tools/debootstrap

Yes, that solved both problems. Thanks.

Best,
Tiago
tbaptista is offline   Reply With Quote
Old 3 Days Ago   #5
umuro
Just Give Me the Beans!
 
umuro's Avatar
 
Join Date: Mar 2006
Location: Eindhoven, Netherlands
Beans: 59
Kubuntu 9.04 Jaunty Jackalope
Send a message via ICQ to umuro Send a message via MSN to umuro Send a message via Yahoo to umuro Send a message via Skype™ to umuro
Unhappy Re: HOW TO: install Lucid/10.04 LTS on Xen 3.1 with xen-tools/debootstrap

Followed the advice above. I get
Error: (2, 'Invalid kernel', 'xc_dom_find_loader: no loader found\n')

Any ideas?
umuro is offline   Reply With Quote
Old 3 Days Ago   #6
ac4000
5 Cups of Ubuntu
 
ac4000's Avatar
 
Join Date: Aug 2006
My beans are hidden!
Re: HOW TO: install Lucid/10.04 LTS on Xen 3.1 with xen-tools/debootstrap

Make sure pygrub is linked properly to /usr/bin/pygrub ... that's the first thing that jumps to mind. You could also try running pygrub directly and pointing it at the image or LV to make sure it's finding something to boot. If that doesn't work, would you mind posting the generated config file?
ac4000 is offline   Reply With Quote
Old 16 Hours Ago   #7
Fanani M. Ihsan
First Cup of Ubuntu
 
Join Date: May 2010
Beans: 1
Smile Re: HOW TO: install Lucid/10.04 LTS on Xen 3.1 with xen-tools/debootstrap

please help me :
i was try your tutorial , but whee i running xm create show error :

fanani@server:~# xm create /etc/xen/artivisi.com.cfg
Using config file "/etc/xen/artivisi.com.cfg".
Error: Boot loader didn't return any data!

my /etc/xen-tools/xen-tools.conf file : here
my /etc/xen/artivisi.com.cfg file : here

can u help me .
Thank for all

Fanani M. Ihsan is offline   Reply With Quote
Old 15 Hours Ago   #8
ac4000
5 Cups of Ubuntu
 
ac4000's Avatar
 
Join Date: Aug 2006
My beans are hidden!
Re: HOW TO: install Lucid/10.04 LTS on Xen 3.1 with xen-tools/debootstrap

Everything looks in order (my cfg doesn't have the "extra" line at the bottom, but I doubt that's causing the problem). That said, I haven't tried this on an image, only on LVMs, so you might need to call pygrub explicitly. You could try pointing pygrub at the image to see if you get a result (if you don't, it means it can't find the boot image for some reason).

Something like this should work:

Code:
pygrub /opt/serveratv/domains/artivisi.com/disk.img
ac4000 is offline   Reply With Quote

Bookmarks

Tags
lucid, pygrub, xen, xen-tools


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:27 AM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry