Moving system directories to a flash card

Image:Ambox_speedy_deletion.png
This article has been marked for potential deletion.
Please see the talk page for discussion.

Contents

what is this page

this page describes the setup on my own N800, I hope it can be useful to others, it surely helps me each time I update the system and I must remember what I had done.

why should you be reading this

  • you regularly run out of space while trying out new programs
  • you don't want to reflash /home each time you reflash your tablet
  • you would like the 'rwx' permissions logic also on the flash card
  • you want a LARGE /home partition

needed

  • a working N800
  • an internal flash card of 2Gigs or more.
  • maybe a standalone linux desktop
  • one hour time and some chamomile

first time

partitioning

follow the steps on partitioning a flash card, deciding how much space you want to reserve for /usr and how much for /home.

on my system, I have slightly less that 0.5G for /usr and 1.5G for /home, respectively in partitions 2 and 3. I have left a small 1st partition on the card because some hardware might otherwise think the flash card is corrupt and might want to "recover" it...

in general, it will not be a good idea to remove the card from the machine at any time and it will not be a good thing to put the card into anything else than your N800...

copying your data to the new file systems

after you have created the partitions and have initialized them, mount them somewhere (for example /mnt/usr and /mnt/home) and copy /usr/* and /home/* there, keeping attributes

cp -a /usr/* /mnt/usr
cp -a /home/* /mnt/home

this will cost time so don't allow your N800 to die because of a low battery!

setting things up

after you have done this, I think the best way to go is reflashing your machine (apart from the above cp instructions, you also made a backup, didn't you?) and follow the steps in the next section. this will clean up a lot of space on your internal memory.

after a reflash

things might work also without a backup, but make one anyway, unless you trust me blindly and you want to test the procedure.

short list of things to do:

reflash the machine

remove useless packages

things like the tutorial and I can't remember what else... I used the Application manager to remove everything which was removable.

boot with flash card in place

test your old partitions

this needs a few more words

after you have become root, do this:

#!/bin/sh

# create the mount points for testing
mkdir /mnt/usr
mkdir /mnt/home

# create the startup script
cat > /etc/init.d/mount_custom << EOF
insmod /mnt/initfs/lib/modules/2.6.21-omap1/mbcache.ko
insmod /mnt/initfs/lib/modules/2.6.21-omap1/ext2.ko
MOUNT_ROOT=/mnt/
mount /dev/mmcblk0p2 ${MOUNT_ROOT}usr
mount /dev/mmcblk0p3 ${MOUNT_ROOT}home
EOF

# register it for early execution
chmod +x /etc/init.d/mount_custom
cd /etc/init.d; for i in 2 3 4 5; do ln -s ../init.d/mount_custom /etc/rc$i.d/S15mount_custom

reboot and check

now reboot and it's up to you how you want to check that /mnt/usr and /mnt/home contain what you expected

new files to old /usr

copy the new files from /usr to /mnt/usr

cp -a /usr/* /mnt/usr

this will take time so be patient and do not let your N800 suffer electricity hunger.

back to work

edit the /etc/init.d/mount_custom script setting MOUNT_ROOT=/ and reboot if you dare.

things should "just work" and if they don't then there's a mistake in the procedure so please let me know about it so we can correct it.

more thoughts

most programs will not work out of the box and you should reinstall them (they are not marked as installed even if you will find them in your application menu). I first started trying to use them and since some didn't work, I used the application menu as a list of things to reinstall. it is more work than doing a backup so maybe doing a backup anyway would not be such a bad idea. but this way I have cleaned up my repository list, which was quite messed up after that trouble with repostory/repository...