Wednesday, 30 December 2009

Nokia N900 out of space? Repartition it, here's how

This post is an up-to-date version of the repartitioning guide from

The Nokia N900 is the first full GNU mobile phone. However it suffers from a very poor root file system partitioning scheme.
It has root mounted with only 80 Megs free, which means that you quickly run out of space if you install a lot of packages, or a few unofficial packages which are not careful about their space usage. There is no way to repartition the device, as the partitions live on different chips.
To get more root space, and especially more ext3 space, we will change the large FAT partition housing /home/user/MyDocs into an ext3 one, and move it from /home/user/MyDocs to /home. To finish up, we will make most of the things in /usr, that is, most of what applications use to install files, end up on the new large partition in /home. You will need to install the rootsh package for root access. Using ssh to the device is recommended, since then you can easily copy-paste commands from here and can use your better computer keyboard.
This is a command. All commands are executed as root.
Step 1: get rootsh

  • To get rootsh, Enable Maemo extras repository: start Application manager,
    click the top menu - Application catalogs - Maemo Extras. Untick Disabled.
  • Install rootsh from Application manager.
Step 2: back up MyDocs
  • First we will back up MyDocs. This requires a memory card,
    which we assume is mounted at /media/mmc1.
  • cp -r /home/user/MyDocs /media/mmc1
Step 3: change old MyDocs to ext3
  • Get fdisk on your computer from here and transfer it to the N900.
  • extract it on the N900 as root:
  • cd /
  • tar xzvf /path/to/fdisk.tgz
  • Where /path/to/fdisk.tgz is where you put fdisk.tgz. After this, you have fdisk "installed" and in your path. Now unmount old MyDocs:
  • umount /home/user/MyDocs
  • Change the 1st partition (FAT) to Linux:
  • fdisk /dev/mmcblk0
  • Give fdisk the commands t, 1, and 83 (press enter after each). Verify by typing p and pressing enter. The first partition should now also be Linux. Then type w and press enter.
  • Now let's create an ext3 filesystem on it (note the p1 at the end!):
  • mkfs.ext3 /dev/mmcblk0p1
  • This may take some time.
Step 4: Make our home in the new ext3 partition
  • We mount the new ext3 partition at MyDocs, and copy our home stuff there:
  • mount /dev/mmcblk0p1 /home/user/MyDocs
  • cd /home
  • cp -r * /home/user/MyDocs
  • The last command will complain about recursion. Don't worry, you can ignore it.
  • Finally, we need to give our user rights to use the files we just copied as root:
  • chown user /home/user/MyDocs -R
  • After this you should reboot. This is required to have the device auto-detect that mmcblk0p1 has home stuff, and should be mounted as /home.
Step 5: Create a new MyDocs
  • After the reboot, mmcblk0p1 is mounted as home.
    The old smaller home (2G), mmcblk0p2, is not mounted. We will use this for MyDocs.
    fdisk it to FAT mode:
  • fdisk /dev/mmcblk0
  • Give fdisk the commands t, 2, and c (press enter after each).
    Verify by typing p and pressing enter. The second partition should now be FAT. Then type w and press enter.
  • Now we create a FAT32 filesystem on the partition (note the p2 at the end!):
  • mkfs.vfat /dev/mmcblk0p2
  • Mount it to MyDocs:
  • mount -t vfat /dev/mmcblk0p2 /home/user/MyDocs
  • If you backed up MyDocs in the beginning using a memory card, move the backed-up MyDocs to the new one:
  • mv /media/mmc1/MyDocs/* /home/user/MyDocs
  • Remove the backup if desired:
  • rm -r /media/mmc1/MyDocs
  • Finally, we need to change one of the configuration files that regulates the mount of partitions to include the new MyDocs. edit /etc/event.d/rcS-late using vi:
  • vi /etc/event.d/rcS-late
  • Go to around line 24 by typing :24 and pressing enter in vi. You should see:
  • /bin/mount /home || echo "Failed to mount /home partition."
  • Add the following line after this, by typing o and then the line:
  • /bin/mount /home/user/MyDocs
  • Finally, press esc and type :wq to write the file and quit. If you edited the file as user by accident, quit by using :q! and then say sudo gainroot and try again.
Step 6: Move most of /usr under our spacious /home
  • Create the directories we will use:
  • mkdir -p /home/root/usr/share
  • mkdir -p /home/root/var/cache
  • Start by moving some things in /usr:
  • cd /usr/
  • for FILE in games include local src var
    mv $FILE /home/root/usr/
    ln -s /home/root/usr/$FILE /usr/
  • Also move /var/cache/apt, this is used by apt-get for temporary storage:
  • cd /var/cache/
  • for FILE in apt
    mv $FILE /home/root/var/cache/
    ln -s /home/root/var/cache/$FILE /var/cache/
  • Move parts of /usr/share. This contains icons, sounds, games.
  • cd /usr/share/
  • for FILE in fonts icons locale mime nokia-maps pixmaps sounds themes tutorial-applet zoneinfo
    mv $FILE /home/root/usr/share/
    ln -s /home/root/usr/share/$FILE /usr/share/
  • If you have /usr/share/games, do this (If you do not know if you have it, do both. The first one will complain if you don't have it, and the second if you do, but no disasters will happen):
  • mv /usr/share/games /home/root/usr/share/
  • If not, do this:
  • mkdir /home/root/usr/share/games
  • in both cases, do this:
  • ln -s /home/root/usr/share/games .
  • All done. Reboot. You should now have around 100 MB free in /, a /home with 23GB free, and a /home/user/MyDocs with around 2GB of space.


Alex Eden said...

Thank you for excellent and easy to follow instructions!

There was only one minor hiccup.

Output of my "uname -a":
Linux Nokia-N900 2.6.28-omap1 #1 PREEMPT Fri Aug 6 11:50:00 EEST 2010 armv71 unknown

On my n900, in file /etc/event.d/rcS-late there is no line "/bin/mount /home || echo "Failed to mount /home partition.""

Since MyDocs are mounted under /home, /home needs to be mounted first. I was too lazy to analyze the whole file, but if you grep mount rcS-late, you'll see that "mount /home" is mentioned twice. I just inserted "/bin/mount /home/user/MyDocs" after each one. Probably unnecessary, but it works.

I guess one of the recent updates modified this rc script.

Anonymous said...

i dint understand on it please can u do step by step