Meego Wiki
Views

ARM/N900/Install/NFS

From MeeGo wiki
(Difference between revisions)
Jump to: navigation, search
(192.168.* replaced with 192.168.2.15 in Preparing the root file system chapter)
Line 1: Line 1:
= NFS-root over usb networking =
= NFS-root over usb networking =
-
This page describes howto make N900 boot a MeeGo root filesystem from your host (PC) using USB networking. MeeGo kernel needs to be flashed, but Maemo rootfs is left as it is. Two different approaches are described:
+
This page describes howto make N900 boot a MeeGo root filesystem from your host (PC) using USB networking. If you choose to load kernel and initrd, then nothing needs to be changed in your N900. Two different approaches are described:
* using initrd (no compilation of any sw components required)
* using initrd (no compilation of any sw components required)
* using customized kernel (requires kernel recompilation)
* using customized kernel (requires kernel recompilation)
Line 139: Line 139:
  mkfs.cramfs -b 4096 -n meego_initrd ./initrd/ initrd.img
  mkfs.cramfs -b 4096 -n meego_initrd ./initrd/ initrd.img
-
Now you can load your initrd with flasher and boot to nfs-root:
+
Now you can load your kernel + initrd with flasher and boot to nfs-root. Interface usb0 is assigned IP right after the loading.
-
  flasher -n initrd.img -l -b"root=/dev/ram0"
+
  sudo flasher -k /home/nfs/boot/vmlinuz-2.6.33.3-11.2-n900 -n initrd.img -l -b"root=/dev/ram0" ; \
 +
sleep 5 ; sudo ifconfig usb0 192.168.2.14
-
Voilá, you should see MeeGo booting.
+
Voilá, you should see MeeGo booting. It will take over a minute for xterm to appear.

Revision as of 07:45, 27 May 2010

Contents

NFS-root over usb networking

This page describes howto make N900 boot a MeeGo root filesystem from your host (PC) using USB networking. If you choose to load kernel and initrd, then nothing needs to be changed in your N900. Two different approaches are described:

  • using initrd (no compilation of any sw components required)
  • using customized kernel (requires kernel recompilation)

Initrd is the preferred method.

Requirements

  • USB networking
  • a MeeGo rootfs image extracted

Preparing the root filesystem

First, you have to get/make a MeeGo rootfs image. You can download a pre-built image (ARM/Meego_images_for_N900) or create your own (ARM/Creating ARM image using MeeGo Image Creator). Then you must make the (unpacked) rootfs available in a suitable location on your host system (e.g. /home/nfs/rootfs).

In case you have a raw image, you can mount it with an offset:

mkdir temp
mount -o loop,offset=512 root_image.raw temp

If you're creating your own rootfs image, you might want to install busybox there. So that you can easily get busybox for your initrd.

Next, make sure you have NFS server installed on your host and export the rootfs. In Ubuntu:

apt-get install nfs-kernel-server
echo '/home/nfs      192.168.2.15(rw,no_root_squash,no_subtree_check)' >> /etc/exports
exportfs -v -a

Currently, one hack for the (readymade) N900 rootfs image is needed. The nokia-usb-networking (provided by nokia-n900-configs package) messes up the networking when trying to use nfsroot. Simply remove it from the current default runlevel of the MeeGo rootfs:

rm /home/nfs/rootfs/etc/rc.d/rc3.d/S50nokia-usb-networking

Method 1: NFS-Root with initrd

This method involves using busybox from MeeGo and does not require kernel recompilation. You can more easily keep in sync with the MeeGo kernel.

Preparing initrd directory

First, you have to create a directory for preparing initrd. We'll create that under the rootfs directory (but you could create it anywhere you like, of course).

 mkdir /home/nfs/rootfs/initrd

You need some initial directories:

cd /home/nfs/rootfs/initrd
mkdir bin
mkdir sbin
mkdir proc
mkdir sys
mkdir dev
mkdir mnt
mkdir -p lib/modules

Some device nodes are needed by the kernel (note, these must be run as root to preserve device node properties):

cp -a /dev/console dev/
cp -a /dev/null dev/
cp -a /dev/ram0 dev
cp -a /dev/tty dev/
cp -a /dev/tty0 dev/
cp -a /dev/zero dev/

Copy kernel modules from your rootfs to the initrd (be sure to use correct kernel version):

cp -r /home/nfs/rootfs/lib/modules/2.6.28-19.1-n900/ lib/modules/

Installing Busybox

As the next step, you need Busybox. If you have busybox installed in you rootfs, you can simply:

cp /home/nfs/rootfs/sbin/busybox bin/

If you don't, you can get the binary e.g. by fetching the busybox rpm package and extracting the binary from there

mkdir tmp
cd tmp
wget http://repo.meego.com/MeeGo/devel/trunk/repo/arm/os/armv5tel/busybox-1.16.0-2.5.armv5tel.rpm
rpm2cpio busybox-1.16.0-2.5.armv5tel.rpm | cpio -id
cp sbin/busybox /home/nfs/rootfs/initrd/bin/
cd ..
rm -rf tmp

Now, you have the busybox binary installed. Currently, MeeGo does not have a statically compiled version of Busybox. Thus, you need some libraries as well:

cp /home/nfs/rootfs/lib/ld-linux.so.3 lib/
cp /home/nfs/rootfs/lib/libc.so.6 lib/
cp /home/nfs/rootfs/lib/libm.so.6 lib/

Last, you need to set up some links to the busybox binary:

cd bin
ln -s busybox sh
ln -s busybox mount
ln -s busybox modprobe
ln -s busybox sleep
ln -s busybox ifconfig
ln -s busybox echo
ln -s busybox umount
ln -s busybox pivot_root
ln -s busybox exec
ln -s busybox cd
ln -s busybox ls
ln -s busybox chroot
cd ..

Now, you're done with Busybox.

Making initrd to boot automatically

Next, make a script for doing the actual NFS-rooting and :

vim autonfsroot.sh
# edit the script, an example is found below
chmod a+x autonfsroot.sh
rm sbin/init
ln -s ../autonfsroot.sh sbin/init

Here's a simple example of autonfsroot.sh

#!/bin/sh
echo "Doing mounts..."
mount -t proc proc /proc
mount -t sysfs sysfs /sys

echo "Loading modules..."
modprobe sunrpc
modprobe auth_rpcgss
modprobe rpcsec_gss_krb5
modprobe nfs
modprobe phonet
modprobe g_nokia

sleep 2

echo "Configuring network interface..."
ifconfig usb0 192.168.2.15

echo "Mounting NFS..."
mount -t nfs -o nolock 192.168.2.14:/home/nfs/rootfs /mnt

echo "Unmounting proc and sys..."
umount /proc
umount /sys

echo "Switching to nfsroot..."
# switch_root does not seem to be working with cramfs
#exec switch_root /mnt /sbin/init
cd /mnt
pivot_root . mnt
exec chroot . /sbin/init

Of course, you could do more elaborate scripting, e.g. add automatic kernel command line parsing/analysis, but that's not covered here.

Making initrd image and booting

N900 requires cramfs initrd images. This is a bootloader restriction. Go back to the directory containing the initrd dir and then:

cd ..
mkfs.cramfs -b 4096 -n meego_initrd ./initrd/ initrd.img

Now you can load your kernel + initrd with flasher and boot to nfs-root. Interface usb0 is assigned IP right after the loading.

sudo flasher -k /home/nfs/boot/vmlinuz-2.6.33.3-11.2-n900 -n initrd.img -l -b"root=/dev/ram0" ; \
sleep 5 ; sudo ifconfig usb0 192.168.2.14

Voilá, you should see MeeGo booting. It will take over a minute for xterm to appear.


Method 2: NFS-Root with custom kernel

As a pre-requisite, you have to have environment for cross-building ARM binaries.

Then, you have to recompile kernel for N900. You must enable (built inside kernel, thus select '*', not 'M'):

* USB Gadget support (Device drivers -> USB Support -> USB Gadget support)
  * USB Gadget drivers (Device drivers -> USB Support -> USB Gadget support -> USB Gadget drivers)
    * Ethernet gadget
  * RNDIS Support (Device drivers -> USB support -> USB Gadget support -> RNDIS support)
* NFS support (File systems -> Network File systems -> NFS client support)
  * NFS-Root support (File systems -> Network File systems -> NFS client support -> Root file system on NFS)
* IP kernel autoconf (Networking support -> Networking options -> IP: kernel level autoconfiguration)
  * all sub-options

Compile and install modules

make
make modules_install INSTALL_MOD_PATH=/home/nfs/rootfs


After compilation is finished you can boot the new kernel with (assuming 192.168.2.14 is your host)

flasher -k arch/arm/boot/zImage -l -b"init=/sbin/preinit ip=192.168.2.15::192.168.2.14 root=/dev/nfs \
nfsroot=192.168.2.14:/home/nfs/rootfs rootdelay=2 rw console=ttyMTD console=tty0"


You can also hard code the kernel command line options as default when recompiling the kernel (Boot options -> default kernel command string). And further, you can of course flash the new kernel to the device. But still, you have to override the Nolo command line options with flasher

flasher -b
Personal tools