Ubuntu 9.10 schroot in 10.04

*** Update: First and foremost, I take no credit for any of this post’s content. I am really just taking what others have done (which I have links to bellow) and am putting it on my blog for a personal reference and hopefully the small changes that I made to their guides will help someone somewhere.

I have recently upgraded to Ubuntu 10.04 (love it with an SSD) and now am in the progress of making changes to Cyanogen’s Custom Android ROM with the help of fellow RIT Student: Allen Voter. Information on that process will come later…

So the goal of this post will be to install a 32-bit chroot of 9.10 in my fresh install of 10.04 as 9.10 is easier to build and test Cyanogen’s custom Android rom. I have modified some guides from here and here. I have also elected to use schroot as it allows for easy chroot access.

  1. First, we must install schroot and debootstrap:
    $ sudo apt-get install schroot debootstrap
  2. Next, we need to configure/edit the /etc/schroot/schroot.conf file so schroot will do our bidding:
    [karmic]
    description=karmic
    type=directory
    location=/var/chroot/karmic
    priority=3
    users=YOUR_USER
    groups=SOME_GROUP_LIKE_users
    root-groups=YOUR_ADMIN_USER
    run-setup-scripts=true
    run-exec-scripts=true

    Make the necessary changes to best suit your needs and apparently, the run-* lines are not necessary for 10.04 or later.

  3. Now that we have schroot configured, we need to do the install, which I think is called “creating the chroot”:
    $ sudo debootstrap --arch i386 karmic /var/chroot/karmic http://mirrors.rit.edu/ubuntu/

    Again, modify the command to match what you changed in step 2. This will take some time. Also note that the last command is a single line.

  4. Congratulations, once this is complete, your chroot is ready! Keep in mind that there are no X packages installed and this is basically a command line install (we will fix this in a minute). Now for posterity, we should update the system:
    $ schroot -c karmic -u root apt-get update
    $ schroot -c karmic -u root apt-get upgrade

    You may also want to install some software (we install Firefox so the system will grab the X components):
    $ schroot -c karmic -u root apt-get install firefox

  5. Well, as you can see, the length of this command could be problematic if you need to install many things or want to do something with root. If we take our base systems user, passwords, and sudoers files and place them in the chroot environment, we can interact with the system in a much easier way:$ sudo cp /etc/{resolv.conf,passwd,group,shadow,sudoers} /var/chroot/karmic/etcThis now allows us to get straight into the shell and it should act just like your host system.
  6. To drop straight into a chroot shell:
    $ schroot -c karmic
    (karmic)superman@mycomputer:~$
  7. Finally, you may want to run some X applications:
    $ xhost +localhost
    localhost being added to access control list
    $ schroot -c karmic -p firefox
  8. I have yet to figure out what exactly the xhost command does and not really sure if this needs to be run every time you start up a shell, but if/when I figure it out, I will update this post. Comment number 1 from Nk says that xhost allows or denies access to the X server and will persist until there is a restart of X. Sounds good enough for me, thanks Nk!

A great feature of this schroot method is that your home directory is auto-mounted so both the host and the chroot have access to the same folder.

Great! You now have a chroot environment to do testing, development, and just playing around. Another useful thing to use chrooting for is running 64-bit software. You could change this installation a bit to pull the 64-bit install of Ubuntu instead and you could run 64-bit apps inside a 32-bit host. Awesome. Now that I have this set up, my plan is to use it for building Cyanogen’s Android ROM so stay tuned for posts on how that worked.

2 Responses to “Ubuntu 9.10 schroot in 10.04”

  1. Nk said:

    May 07, 10 at 1:59 pm

    ASAIK, the xhost command enable or disable restricted access for your X server. So, in this case, you have to start it every time you restart your local X server (which means probably once per boot), and not before every command.

  2. spencer said:

    May 07, 10 at 2:53 pm

    Thanks Nk! I have updated my post.