Extended root partition on an N800 with OS2008

January 9, 2008 – 11:53 pm

Like many, I wanted to increase the space available to me for my root partition on my n800. There are a lot of sites describing the process of putting the whole of root onto your memory card but I wanted to keep using the internal flash for most of the OS and move only data and some self compiled apps/scripts to the mmc.

The following procedure assumes you have at least a working knowledge of the Linux CLI and have root access to your n800 (note – the procedure should also work for an n810).

Warning: You will be formatting your memory card and modifying boot and system scripts, so, before you do anything backup your data!! You have been warned!

Disclaimer: Follow this procedure at your own risk. If you lose any data or brick your device I take no responsibility (don’t worry though, you can just re-flash it to get back to a pristine state).

Step 1 – Partition and Format the Card

I will describe creating 2 partitions on your card. One will be formatted as ext3 and used as the extension to the root partition and the other will be formatted as FAT and be seen as a normal memory card by the OS, just as it was previously. When planning how to partition your card you should plan to use the first partition for your FAT partition and the second as the extension to root. As such you probably want to have the first partition bigger than the second, for example on my 4Gb card I created a 3Gb FAT and a 1Gb Ext3 partition.

OS2008 doesn’t include mkfs.ext3 (or mkfs.ext2), needed to format your partitions. So, if you want to use ext2 or ext3, the first thing you’ll need to do is install them. They are both included in the e2fsprogs package:

apt-get install e2fsprogs

Before you can partition your memory card you must first umount it:

umount /media/mmc2

In order to partition the card you need to use sfdisk as OS2008 doesn’t include cfdisk. Running:

sfdisk /dev/mmcblk0

will give you an sfdisk prompt as follows:

/dev/mmcblk0p1 :

At the prompt, you need to enter the starting block and size, in cylinders, of the first partition, eg for a 3Gb partition:

/dev/mmcblk0p1 : 0 9660

Hitting Enter will prompt you for the second partition and then the third etc. Just leave them blank if you only need 2 partitions:

/dev/mmcblk0p2 : 9660 3220
/dev/mmcblk0p3 :
/dev/mmcblk0p4 :

Finally you will be asked if you want to write the changes. Hit “y” if you are happy with the partitioning scheme you entered, alternatively you can hit “n” to try again.

Once your new partitions have been written out to the card, you need to format them (you may need a reboot here before you can format the new partitions).

mkfs.mdos /dev/mmcblk0p1
mkfs.ext3 /dev/mmcblk0p2

Step 2 – Enable the extended partition at boot
You’ll now need to edit an init script to load the modules needed to see your ext3 partition and also mount it early in the boot process. Open up /etc/init.d/rcS and after the PATH= line add the following:

insmod /mnt/initfs/lib/modules/2.6.21-omap1/mbcache.ko
insmod /mnt/initfs/lib/modules/2.6.21-omap1/jbd.ko
insmod /mnt/initfs/lib/modules/2.6.21-omap1/ext3.ko

Now, near the end of the file, before the line exit 0, add:

mount -a -t ext3

Save and exit the file.

Next you need to create a mount point for your partition, I chose to use /extfs:

mkdir /extfs

Now add the partition to /etc/fstab:

/dev/mmcblk0p2 /extfs ext3 defaults,rw,noatime 0 0

Now reboot and once your device comes back up you should have a spanking new 1Gb partition under /extfs and a 3Gb memory card (or whatever you configured).

Step 3 – Making sure you can still see your card when connected to your PC via USB
If you now connect your device to a PC via USB, you’ll get a message stating “Memory cards in use: internal memory card” and your memory card won’t be available to your PC. To get round this you need to edit /usr/sbin/oss-mmc-umount.sh, replace the if block after the line grep "$MP " /proc/mounts > /dev/null with:

if [ $? = 0 ]; then
  if [ "$MP" != "/extfs" ] ; then umount $MP 2> /dev/null ; fi
  RC=$?
  if [ $RC != 0 ]; then
    echo "$0: could not unmount $MP"
    exit $RC
  fi
fi

Note – if you called your mount point something other than extfs, remember to edit the test [ "$MP" != "/extfs" ] accordingly. Your FAT partition will now be umount’ed before being made available to your PC. The linux partition also be available but will remain mounted in your device. This should be safe as long as you don’t try to write to the ext3 partition, you probably only need to write to the FAT partition anyway.

Step 4 – Transferring data from Flash to the partition
This is the easy bit. You can transfer any data you want from the flash memory to your new partition. If you then create a symlink to the new location it will be accessible just as it was previously. Good candidates for moving are /usr/share and /home. eg:

cp -a /usr/share /extfs
rm -r /usr/share
ln -s /extfs/share /usr/share

References:

http://www.internettablettalk.com/forums/showthread.php?p=40839#post40839

http://maemo.org/community/wiki/extendedrootfilesystem/

  1. 8 Responses to “Extended root partition on an N800 with OS2008”

  2. I am curious about one thing. You (and others, e.g. Fanoush) say to edit that file above (like it’s a trivial thing). THEN YOU DON’T SAY HOW. Could someone please post a step by step? This file is pretty much a hidden system file, it appears to me. Hard to edit those.

    By heelio on Aug 31, 2008

  3. Interesting facts.I have bookmarked this site. stephanazs

    By stephanazs on Sep 20, 2008

  4. As a novice I heartily agree with heelio. Could someone point me to a step-by-step for editing that file, please?

    By AndyJ on Oct 3, 2008

  5. heelio/AndyJ

    At the beginning of the article, it clearly states:

    “The following procedure assumes you have at least a working knowledge of the Linux CLI and have root access to your n800 (note – the procedure should also work for an n810).”

    If you have working knowledge with Linux and the CLI, then you should know how to edit these files, otherwise, even if you’re given step-by-step instructions, you may screw your device up.

    By develgenius on Dec 1, 2008

  6. I followed the instructions from the tutorial, but didn’t get any result.

    I’m using a sandisk ultra SDHC 8gb card on my N800, which I partitioned to approx. 4gb fat32 and 4gb ext3. The fat32 partition does get recognized as the internal card, but the ext3 partition doesn’t. The folder /extfs is still considered part of the root partition as opposed to the extended root from the internal card.

    By Hitos on Jul 6, 2009

  7. Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.

    By sandrar on Sep 10, 2009

  8. I love your site. :) Love design!!! I just came across your blog and wanted to say that I?ve really enjoyed browsing your blog posts. Sign: ndsam

    By angelina jolie on Sep 10, 2009

  9. Article very interesting, I will necessarily add it in the selected works and I will visit this site

    By nintendost on Nov 17, 2009

Post a Comment