Meego Wiki
Views

ARM/N900/Install/chroot

From MeeGo wiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
'''Under construction'''
'''Under construction'''
-
== Prepare chroot directory ==
+
Problem with chroot installation is finding space for it. SD card and Mydocs would have plenty of space but they use FAT32 so it can't be used directly. Solution is to mount loopback images. Easies way to get started is to use a prebuilt loopback image.
-
Problem with chroot installation is finding space for it. Flash card would have plenty of space but that uses FAT32 so it can't be used directly. We can however create image and loopback mount it.
+
 +
If a prebuilt loopback image is not yet available, you can create it from a provided tar ball.
 +
== Creating a loopback image from a tar ball ==
Create 2GB image file
Create 2GB image file
  dd if=/dev/zero of=/home/user/MyDocs/meego-image bs=1024 count=2097152
  dd if=/dev/zero of=/home/user/MyDocs/meego-image bs=1024 count=2097152
Line 11: Line 12:
Create mount point and loopback mount the image
Create mount point and loopback mount the image
-
  export MEEGO_ROOT="/mnt/meego"
+
  export MEEGO_ROOT="/mnt/meego_root"
  mkdir $MEEGO_ROOT
  mkdir $MEEGO_ROOT
  mount -o loop /home/user/MyDocs/meego-image $MEEGO_ROOT
  mount -o loop /home/user/MyDocs/meego-image $MEEGO_ROOT
Line 18: Line 19:
  tar xzf <meego-image> -C $MEEGO_ROOT
  tar xzf <meego-image> -C $MEEGO_ROOT
-
== Mount system directories ==
+
Umount the image
-
Mounts for chroot environment
+
  umount $MEEGO_ROOT
-
mount -o bind /proc $MEEGO_ROOT/proc
+
-
mount -o bind /sys  $MEEGO_ROOT/sys
+
-
mount -o bind /dev  $MEEGO_ROOT/dev
+
-
mount -o bind /dev/pts $MEEGO_ROOT/dev/pts
+
-
+
-
mount -o bind /var/lib/dbus/ $MEEGO_ROOT/var/lib/dbus/
+
-
mount -o bind /usr/share/fonts $MEEGO_ROOT/usr/share/fonts
+
-
+
-
mount -t tmpfs tmpfs  $MEEGO_ROOT/tmp
+
-
mount -t tmpfs tmpfs $MEEGO_ROOT/var/run
+
-
== Setup ==
+
You now have a loopback image ready to be chrooted into
-
Copy resolv.conf for networking
+
-
cp /etc/resolv.conf $MEEGO_ROOT/etc/resolv.conf
+
-
 
+
-
== Start your engines ==
+
-
Starting chroot
+
-
cd $MEEGO_ROOT
+
-
chroot $MEEGO_ROOT /bin/bash
+
-
 
+
-
== Cleanup ==
+
-
Don't forget to unmount all the system directories that were mounted inside chroot. '''You might have to setup MEEGO_ROOT again after leaving chroot'''.
+
-
cd ~
+
-
umount $MEEGO_ROOT/proc
+
-
umount $MEEGO_ROOT/sys
+
-
umount $MEEGO_ROOT/dev
+
-
umount $MEEGO_ROOT/dev/pts
+
-
+
-
umount $MEEGO_ROOT/var/lib/dbus/
+
-
umount $MEEGO_ROOT/usr/share/fonts
+
-
+
-
umount $MEEGO_ROOT/tmp
+
-
umount $MEEGO_ROOT/var/run
+
-
+
-
umount $MEEGO_ROOT
+
-
== Automating chroot with a script ==
+
== Chrooting into a loopback image ==
Using a script to chroot into an image makes the process faster and safer.
Using a script to chroot into an image makes the process faster and safer.
Copy the code below to a meego_chroot.sh script and remember to chmod +x it.
Copy the code below to a meego_chroot.sh script and remember to chmod +x it.
 +
Usage: ./meego_chroot <path_to_meego-arm-n900-loop.img>
Usage: ./meego_chroot <path_to_meego-arm-n900-loop.img>
 +
 +
You may always execute the commands below manually if you like. Changing the prompt is optional and you only need to do it once per image.
   #!/bin/sh
   #!/bin/sh
    
    
-
   # takes loopimage name as first parameter
+
   ### Prepare and mount the image ###
   MEEGO_IMAGE=$1
   MEEGO_IMAGE=$1
   MEEGO_ROOT=/mnt/meego_root
   MEEGO_ROOT=/mnt/meego_root
Line 71: Line 42:
   mount -o loop ${MEEGO_IMAGE} ${MEEGO_ROOT}
   mount -o loop ${MEEGO_IMAGE} ${MEEGO_ROOT}
    
    
-
   echo "Mounting some dirs inside the chroot environment..."
+
  ### Mount system directories ###
 +
   echo "Mounting system directories inside the chroot environment..."
   mount -o bind /proc ${MEEGO_ROOT}/proc
   mount -o bind /proc ${MEEGO_ROOT}/proc
   mount -o bind /sys  ${MEEGO_ROOT}/sys
   mount -o bind /sys  ${MEEGO_ROOT}/sys
Line 83: Line 55:
   mount -t tmpfs tmpfs  ${MEEGO_ROOT}/var/run                                                                     
   mount -t tmpfs tmpfs  ${MEEGO_ROOT}/var/run                                                                     
    
    
 +
  ### Setup ###
   rm -f ${MEEGO_ROOT}/etc/resolv.conf
   rm -f ${MEEGO_ROOT}/etc/resolv.conf
   cp /etc/resolv.conf ${MEEGO_ROOT}/etc/resolv.conf
   cp /etc/resolv.conf ${MEEGO_ROOT}/etc/resolv.conf
Line 89: Line 62:
   ln -s /proc/mounts ${MEEGO_ROOT}/etc/mtab
   ln -s /proc/mounts ${MEEGO_ROOT}/etc/mtab
    
    
-
   ### we can't change hostname, so we just change the prompt
+
   # Change the prompt -this is optional
   grep -q -s MeeGo ${MEEGO_ROOT}/root/.bashrc
   grep -q -s MeeGo ${MEEGO_ROOT}/root/.bashrc
   if [ "$?" -ne "0" ]; then
   if [ "$?" -ne "0" ]; then
Line 95: Line 68:
   fi
   fi
    
    
-
    
+
   ### Start your engines ###
   echo -e "chrooting to ${MEEGO_ROOT}...\n"
   echo -e "chrooting to ${MEEGO_ROOT}...\n"
   cd ${MEEGO_ROOT}
   cd ${MEEGO_ROOT}
   chroot ${MEEGO_ROOT} /bin/bash
   chroot ${MEEGO_ROOT} /bin/bash
    
    
-
    
+
   ### Cleanup ###
   echo "Cleaning mounts..."                                                                                       
   echo "Cleaning mounts..."                                                                                       
   cd ~
   cd ~

Revision as of 17:10, 8 April 2010

Under construction

Problem with chroot installation is finding space for it. SD card and Mydocs would have plenty of space but they use FAT32 so it can't be used directly. Solution is to mount loopback images. Easies way to get started is to use a prebuilt loopback image.

If a prebuilt loopback image is not yet available, you can create it from a provided tar ball.

Creating a loopback image from a tar ball

Create 2GB image file

dd if=/dev/zero of=/home/user/MyDocs/meego-image bs=1024 count=2097152

Create filesystem on image file

mkfs.ext3 /home/user/MyDocs/meego-image

Create mount point and loopback mount the image

export MEEGO_ROOT="/mnt/meego_root"
mkdir $MEEGO_ROOT
mount -o loop /home/user/MyDocs/meego-image $MEEGO_ROOT

Unpack Meego rootfs image there

tar xzf <meego-image> -C $MEEGO_ROOT

Umount the image

umount $MEEGO_ROOT

You now have a loopback image ready to be chrooted into

Chrooting into a loopback image

Using a script to chroot into an image makes the process faster and safer.

Copy the code below to a meego_chroot.sh script and remember to chmod +x it.

Usage: ./meego_chroot <path_to_meego-arm-n900-loop.img>

You may always execute the commands below manually if you like. Changing the prompt is optional and you only need to do it once per image.

 #!/bin/sh
 
 ### Prepare and mount the image ###
 MEEGO_IMAGE=$1
 MEEGO_ROOT=/mnt/meego_root
 mkdir -p ${MEEGO_ROOT}
 mount -o loop ${MEEGO_IMAGE} ${MEEGO_ROOT}
 
 ### Mount system directories ###
 echo "Mounting system directories inside the chroot environment..."
 mount -o bind /proc ${MEEGO_ROOT}/proc
 mount -o bind /sys  ${MEEGO_ROOT}/sys
 mount -o bind /dev ${MEEGO_ROOT}/dev
 mount -o bind /dev/pts ${MEEGO_ROOT}/dev/pts/
 
 mount -o bind /var/lib/dbus/ ${MEEGO_ROOT}/var/lib/dbus/
 mount -o bind /usr/share/fonts ${MEEGO_ROOT}/usr/share/fonts
 
 mount -t tmpfs tmpfs  ${MEEGO_ROOT}/tmp
 mount -t tmpfs tmpfs  ${MEEGO_ROOT}/var/run                                                                    
 
 ### Setup ###
 rm -f ${MEEGO_ROOT}/etc/resolv.conf
 cp /etc/resolv.conf ${MEEGO_ROOT}/etc/resolv.conf
 
 rm -f ${MEEGO_ROOT}/etc/mtab
 ln -s /proc/mounts ${MEEGO_ROOT}/etc/mtab
 
 # Change the prompt -this is optional
 grep -q -s MeeGo ${MEEGO_ROOT}/root/.bashrc
 if [ "$?" -ne "0" ]; then
   echo "export PS1=MeeGo-chroot:\\\w\\\\\$" >> ${MEEGO_ROOT}/root/.bashrc
 fi
 
 ### Start your engines ###
 echo -e "chrooting to ${MEEGO_ROOT}...\n"
 cd ${MEEGO_ROOT}
 chroot ${MEEGO_ROOT} /bin/bash
 
 ### Cleanup ###
 echo "Cleaning mounts..."                                                                                      
 cd ~
 umount ${MEEGO_ROOT}/dev/pts
 umount ${MEEGO_ROOT}/dev
 umount ${MEEGO_ROOT}/sys
 umount ${MEEGO_ROOT}/proc
 
 umount ${MEEGO_ROOT}/var/lib/dbus/
 umount ${MEEGO_ROOT}/usr/share/fonts
 
 umount ${MEEGO_ROOT}/tmp
 umount ${MEEGO_ROOT}/var/run
 
 umount ${MEEGO_ROOT}
 echo
Personal tools