Squeeze Chroot

From Rescatux Wiki

Jump to: navigation, search

Contents

Introduction

I want to be able to build debian live cd images that are based on squeeze, because it seems that the best debian live scripts are there, and i386 ones because some lenny i386 debian live images (rescatux 0.08 and previous versions) were known not to work at amd64 systems (boot error) but I think I know how to build kind of amd64-i386 hybrid images.

My current system is as follows: Unstable. I boot with an i386 kernel.

I have already download an squeeze mirror and I am going to describe here how to achieve this chroot.

I am going to base most of the steps here on Installing apps in a 32-bit chroot in AMD64 Debian system.

(Actually the first versions are going to be copy-and-paste-from-the-original so check the original document for avoiding surprises. Whatever, when I am finished, I will remove this notice.)

Install the chroot

Minimal Debian system, although I ended up with about 400 MB of stuff in it.

Create a new empty directory

mkdir /home/adrian/gnu/rescatux/squeeze_chroot

Make sure you've got the 'debootstrap' package installed

apt-get install debootstrap

install Debian Squeeze, i386 version, base system to the newly created directory:

I am going to use my local mirror. You can use http://ftp.debian.org/debian/ instead

debootstrap --arch i386 squeeze /home/adrian/gnu/rescatux/squeeze_chroot http://127.0.0.1/squeeze_debian/

That will pull quite a few packages. Once it is done, you should see a normal Debian root directory tree inside.

Add the library path of your chroot to your /etc/ld.so.conf

( I mean your original /etc/ld.so.conf, not the one from the chroot )

/usr/X11R6/lib
# chroot squeeze system libs
/home/adrian/gnu/rescatux/squeeze_chroot/lib
/home/adrian/gnu/rescatux/squeeze_chroot/usr/lib
/home/adrian/gnu/rescatux/squeeze_chroot/usr/X11R6/lib
/home/adrian/gnu/rescatux/squeeze_chroot/usr/local/lib

Now run ldconfig to update your linker's cache

$ ldconfig

Bind Mount

To run an application inside the chroot you will need some parts of your 64bit system tree inside the chroot. This can be achieved with a bind mount. In this example we will bind /tmp to the chroot for the X11 sockets which are in /tmp, and bind /home to access the home directories from within the chroot. You may also want to mount the /proc and /sys filesystems within the chroot. Edit your fstab and add the required paths:

# squeeze chroot
/home           /home/adrian/gnu/rescatux/squeeze_chroot/home none   bind            0       0
/tmp            /home/adrian/gnu/rescatux/squeeze_chroot/tmp  none   bind            0       0
/proc           /home/adrian/gnu/rescatux/squeeze_chroot/proc proc   defaults        0       0
/dev            /home/adrian/gnu/rescatux/squeeze_chroot/dev  none   bind            0       0

Mount them

mount /home/adrian/gnu/rescatux/squeeze_chroot/home
mount /home/adrian/gnu/rescatux/squeeze_chroot/tmp
mount /home/adrian/gnu/rescatux/squeeze_chroot/proc
mount /home/adrian/gnu/rescatux/squeeze_chroot/dev

WARNING: The above means that should you ever decide to remove the chroot:

rm -rf /home/adrian/gnu/rescatux/squeeze_chroot/

then ALL the bind-mounted partitions, including your $HOME, are also going to be deleted! So make sure to unmount them first.

Users

Personally I only need /etc/hosts file.

You will also need to set up the relevant users in the chroot. Copy your /etc/passwd, /etc/shadow , /etc/hosts and /etc/group files to the chroot.

Test inside chroot applications

At this point you should be able to run applications within the chroot. Change to your chroot (you must be root to do this):

chroot /home/adrian/gnu/rescatux/squeeze_chroot

Try to run something

cat /etc/apt/sources.list

The above command should give you the contents of 32-bit sources.list (doh!). Now it's good time to edit it if you are planning on installing some more stuff there (Skype?)

To get out of the chroot back to your 64-bit main system, simply type

exit

Install debian live scripts inside chroot

Inside the chroot:

apt-get install live-helper

Minor tweaks

Sudo

I also need sudo inside the chroot

Inside the chroot:

apt-get install sudo

Outside the chroot:

cp --parents /etc/sudoers /home/adrian/gnu/rescatux/squeeze_chroot/

Mtab

Inside the chroot you will avoid df problems and thus apt-get problems with:

cat /proc/mounts > /etc/mtab

Isohybrid

TO BE CONFIRMED

apt-get install syslinux

to avoid the following error:

226834 extents written (443 MB)
binary.sh: 5: isohybrid: not found
P: Begin unmounting filesystems...
Personal tools