Maemo Shell Environment Fixups
April 20, 2006 on 2:28 pm | In maemo, nokia770 |I am Linux geek and by definition that makes me a shell geek also. My (formerly) greatest frustration was entering long strings of commands through the pickboard interface on the 770 everytime i had to reflash it. Of course i wouldn’t have to reflash it so often if i wasn’t breaking the root filesystem so often. But i do.
As a result i developed a fairly consistent set of procedures for reinstallation with a supporting script. The overall impact to the root filesystem is minimal (nothing like the ravenwolf script - however i did borrow a few lines of script from it). Here it is:
Activating Debug / Root Mode (every install)
In order to place the 770 in root mode, you have to use the Linux Flasher.
- Boot to linux, download the linux flasher from http://maemo.org/downloads/d3.php.
- Connect the 770 to the USB cable (to the PC).
- Enter ‘chmod +x flasher’ to make sure it is executable.
- Enter ‘./flasher –enable-rd-mode –reboot‘
- Place the 770 in ‘brick mode’ by (a) powering it down (b) hold the home button down, (c) press the power button until the USB symbol appears at the upper right corner of the display. This mode places the internal flash memory on the USB interface so it can be updated from the PC.
- The 770 will reboot when it is completed.
Repartioning External Flash (as necessary)
In order to extend the root file system and create a swapspace on the external flash card, we need to repartition the card. The first partition must be the VFAT partition. Maemo treats this partiton as special, in that it maps into the file manager directly and will map to the USB interface when the connected to a PC (but only if it is VFAT). Any other Linux partition can be persistantly mounted by the 770. By creating symbolic links from this partition back to the root file system, we can offload the internal memory.
- Boot your PC to Linux. Login as root.
- Connect the 770 to the USB.
- enter ‘mkdir /mnt/770′ to create a mount point.
- enter ‘fdisk /dev/sda’ to repartition the card. Delete the current vfat partition, create a new (smaller) vfat partition1 and a linux partition for the balance of the card. Write the partition table and exit.
- enter ‘mkfs.vfat /dev/sda1 to create the vfat filesystem.
- enter ‘mkfs.ext2 /dev/sda2 to create the ext2 filesystem. ext3 is not appropriate for a flash file system.
- enter ‘mount /dev/sda2 /mnt/770′ to mount the ext2 partition.
- enter ‘dd if=/dev/zero of=/mnt/770/swapfile bs=1024 count=24576′ to create a swapfile.
- enter ‘mkswap /mnt/770/swapfile’ to format it as a swapfile
- enter ‘umount /mnt/770′ to unmount the partition.
- unplug the 770 from the computer and reboot the 770.
Installations Part 1 (every install)
Before we can do anything interesting with our Nokia 770 we need to have the following mimimal applications installed. These include:
- osso-xterm at http://770.fs-security.com/xterm/
These tools will allow you to open a terminal and edit. After installation follow these steps to configure and verify operation.
Updating Passwords
There are two users defined on the maemo image. These would be ‘user’ with no password , and ‘root’ with a password of ‘rootme’. Update the passwords as follows:
- Open xterm.
- enter ’sudo gainroot’ to change user to root.
- enter ’su -’
- enter ‘passwd -l root’ to lock the root account.
- enter ‘passwd root’ to change the root password
- enter ‘passwd user’ to change the user password
Installing Apps Part 1
In this section we will install the baseline applications for the nokia 770. These include:
- bluetooth keyboard plugin at http://770.fs-security.com/keyboards.html
- iputils at http://www.opbyte.it/maemo/
- openssh at ftp://ftp.infradead.org/pub/maemo
- python runtime at http://pymaemo.sourceforge.net/
- sbnetmon at http://tabletcorner.com - Status bar Network Monitor
- slocate at http://lucidvisions.com/
- vim at http://www.bleb.org/software/770/#vim
- mug-usbnet at http://maemo.feelslikeburning.com/
- mug-pkgtools at http://maemo.feelslikeburning.com/
Running the Filesystem Fixups
Copy the following script into a file and execute from the root of the filesystem. It creates a number of symbolic links so that all of the binaries are now in the path, the lib paths are updated and a few files in the ‘wrong place’ are linked to the more appropriate location. The most invasive fixup is to automount /dev/mmcblk0p2 (as ext2 filesystem) at /MMC, if it exists.
Each fixup tests to determine if it has already been ‘fixed’, and only applies the fixup if necessary, so it can be run multiple times without impact.
#!/bin/sh
MMC_Mount=/MMC
MMC_Device=/dev/mmcblk0p2
#
# test if user is root / exit if not
#
if [ `id -u` != 0 ]; then
echo $0: only root can do that && exit
fi
#
# MMC automount code
#
if [ ! -e $MMC_Mount -a -b MMC_Device ]; then
echo "creating $MMC_Mount mountpoint and automounting $MMC_Device"
cd /
echo $0: save | tee -a $MMC.log
cp -p /etc/fstab /etc/fstab.baseline
echo /dev/mmcblk0p2 $MMC ext2 defaults,noatime 0 0 >>/etc/fstab
cp -p /etc/init.d/minircS /etc/init.d/minircS.baseline
sed -ir 's|(/sbin/udevstart)$|1;mount /dev/mmcblk0p2|' /etc/init.d/minircS
cp -p /etc/init.d/minireboot /etc/init.d/minireboot.baseline
sed -ir 's|(/media/mmc1)|/dev/mmcblk0p1 /dev/mmcblk0p2|' /etc/init.d/minireboot
cp -p /etc/init.d/minishutdown /etc/init.d/minishutdown.baseline
sed -ir 's|(/media/mmc1)|/dev/mmcblk0p1 /dev/mmcblk0p2|' /etc/init.d/minishutdown
mkdir -p $MMC && mount /dev/mmcblk0p2
else
echo "either $MMC_Mount already exists or $MMC_Device does not exist - bypassing automount scripts"
fi
#
# linking the install directories into the path
#
if [ ! -d /usr/local ]; then
echo "/usr/local does not appear to exist - creating"
mkdir /usr/local
else
echo "/usr/local appears to exist"
fi
#
if [ ! -h /usr/local/bin ]; then
echo "/usr/local/bin symbolic link does not appear to exist - creating"
ln -s /var/lib/install/usr/bin /usr/local/bin
else
echo "/usr/local/bin symbolic link appears to exist"
fi
#
if [ ! -h /usr/local/sbin ]; then
echo "/usr/local/sbin symbolic link does not appear to exist - creating"
ln -s /var/lib/install/usr/sbin /usr/local/sbin
else
echo "/usr/local/sbin symbolic link appears to exist"
fi
#
if [ ! -h /usr/local/lib ]; then
echo "/usr/local/lib symbolic link does not appear to exist - creating"
ln -s /var/lib/install/usr/lib /usr/local/lib
echo "refreshing lib cache"
ldconfig
else
echo "/usr/local/lib symbolic link appears to exist"
fi
#
# Linking the MMC and / directories into the File Manager
#
if [ ! -h /home/user/MyDocs/Root ]; then
echo "/home/user/MyDocs/Root symbolic link does not appear to exist - creating"
ln -s / /home/user/MyDocs/Root
else
echo "/home/user/MyDocs/Root symbolic link appears to exist"
fi
#
if [ ! -h /home/user/MyDocs/MMC ]; then
echo "/home/user/MyDocs/MMC symbolic link does not appear to exist - creating"
ln -s /MMC /home/user/MyDocs/MMC
else
echo "/home/user/MyDocs/MMC symbolic link appears to exist"
fi
#
# Fixing up slocate
#
if [ ! -d /var/lib/slocate ]; then
echo "/var/lib/slocate does not appear to exist - creating"
mkdir /var/lib/slocate
groupadd slocate
usermod -G slocate user
else
echo "/var/lib/slocate appears to exist"
fi
#
# Fixing up dpkg
#
if [ ! -h /var/lib/dpkg ]; then
echo "/var/lib/dpkg symbolic link does not appear to exist - creating"
ln -s /var/lib/install/var/lib/dpkg /var/lib/dpkg
else
echo "/var/lib/dpkg symbolic link appears to exist"
fi
#
# Fixing up OpenSSH application links
#
if [ ! -h /var/lib/install/usr/bin/scp ]; then
echo "/var/lib/install/usr/bin/scp symbolic link does not appear to exist - creating"
ln -s /var/lib/install/bin/scp /var/lib/install/usr/bin/scp
else
echo "/var/lib/install/usr/bin/scp symbolic link appears to exist"
fi
#
if [ ! -h /var/lib/install/usr/bin/ssh ]; then
echo "/var/lib/install/usr/bin/ssh symbolic link does not appear to exist - creating"
ln -s /var/lib/install/bin/ssh /var/lib/install/usr/bin/ssh
else
echo "/var/lib/install/usr/bin/ssh symbolic link appears to exist"
fi
#
if [ ! -h /var/lib/install/usr/bin/skey ]; then
echo "/var/lib/install/usr/bin/skey symbolic link does not appear to exist - creating"
ln -s /var/lib/install/bin/skey /var/lib/install/usr/bin/skey
else
echo "/var/lib/install/usr/bin/skey symbolic link appears to exist"
fi
#
if [ ! -h /var/lib/install/usr/sbin/sshd ]; then
echo "/var/lib/install/usr/sbin/sshd symbolic link does not appear to exist - creating"
ln -s /var/lib/install/sbin/sshd /var/lib/install/usr/sbin/sshd
else
echo "/var/lib/install/usr/sbin/sshd symbolic link appears to exist"
fi
Configure the ssh server
- Open xterm.
- enter ’sudo gainroot’ to change user to root.
- enter ’su -’
- enter ‘cd /var/lib/install/sbin’
- enter ’sh ./setup.sh’
- reboot the 770. open a network connection on the 770, and ssh to the 770 from a PC.
- complete any command line configuration from the ssh session.
Configuration Part 2
- Open an xterm session
- enter ’sudo gainroot’ to change user to root
- enter ’su -’ to get the full environment
- FYI - most applications install everything under /var/lib/install/usr/, and that is not in the path. So we create a symbolic link into a section of the path this is appropriate.
- enter ’slocate -u’ to update the locate database. (takes a long time)
- enter ‘cd ~’
- enter ‘vim .vimrc’
- within vim insert ’set nocompatible’, and then save and exit.
We now have installed a xterm, vim and mapped the directories so these applications are directly invokable.
Of course the fixup script is available at maemo.feelslikeburning.com
ubergEEk
2 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^
Why do you mount the mmc as /MMC?
Comment by gultig — April 21, 2006 #
Purely arbritrary. The Ravenwolf script uses ‘Root’, and it didn’t want to create any possible conflicts there.
ubergEEk
Comment by admin — April 21, 2006 #