Moving system directories to a flash card

(Edited this article, not sure if it should stay marked for deletion. Seems totally redundant with "boot from flash card".)
Line 1: Line 1:
-
'''This method is ''not recommended'', as it is more fragile, and less usable than straight flash booting. Please use the steps outlined in the [[booting from a flash card]] article instead!'''
+
'''This method is ''not recommended'', as it is more fragile, and less usable than straight flash booting. Please use the steps for [[booting from a flash card]] instead!'''
-
== What is this page ==
+
== Why move directories to a flash card ==
-
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 might want to read this ==
+
* you regularly run out of space while trying out new programs
* 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 don't want to reflash /home each time you reflash your tablet
Line 10: Line 7:
* you want a LARGE /home partition
* you want a LARGE /home partition
-
== Why you should consider an other method ==
+
== Alternative ==
-
[[booting from a flash card]] describes a possibly better method for solving most of the above points.  in the [[Talk:Ext2_file_system_on_flash_card_partition | talk page]] you will read why you should follow that method and not this one.  as far as I managed to understand, what I describe is totally useless and anybody able to understand the above reasons would be able to figure out all that I've been writing here.  unfortunately, I have a very faulty memory and I need wiki pages to remind me what to do each time I have to do it, so I softly insist on not removing this otherwise useless page.
+
[[Booting from a flash card]] allows you to have your entire system running from a flash card, and thus to have your Home directory limited only by the sizee of the flash card.
-
I strongly advice you not to follow my method and to try [[booting from a flash card]], but if you do and you have comments about it, please correct me where I'm definitely totally wrong.  don't tell me "you're definitely totally wrong", just correct the text.  thanks.  and no, I don't like [http://en.wikipedia.org/wiki/Capital_letter capital letters] after the full stop.
+
The reasons for doing this, rather than following the instructions here, are detailes in [[Talk:Ext2_file_system_on_flash_card_partition | the Talk: page]] of the page describing creating ext2 partitions for your tablet.
-
a much safer approach is not doing any of these experiments and just enjoy your tablet as it is. it's a beautiful tool, isn't it?
+
This page details the steps the author followed to solve a problem, and represents his personal experiences.
 +
 
 +
It is strongly advised that if you have these issues, that you try [[booting from a flash card]].
== Needed ==
== Needed ==
Line 22: Line 21:
* an internal flash card of 2Gigs or more.
* an internal flash card of 2Gigs or more.
* maybe a standalone linux desktop
* maybe a standalone linux desktop
-
* one hour time and some [http://en.wikipedia.org/wiki/Roman_Chamomile chamomile]
+
* one hour and some [http://en.wikipedia.org/wiki/Roman_Chamomile chamomile]
== First time ==
== First time ==
=== Partitioning ===
=== Partitioning ===
-
follow the steps on [[partitioning a flash card]], deciding how much space you want to reserve for /usr and how much for /home.
+
[[Partitioning a flash card | Partition your 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...   
+
Suggested values for partition sizes are 500MB for /usr and 1.5GB for /home, respectively in partitions 2 and 3.  Leave a small FAT16 partition on the card in 1st position to prevent other systems considering that the card is corrupted and trying 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...
+
It is suggested that you leave the card in your N800.
=== Copying your data to the new file systems ===
=== 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
+
After creating the partitions and initializing them, mount them at /mnt/usr and /mnt/home, and copy /usr/* and /home/* there, keeping file attributes:
  cp -a /usr/* /mnt/usr
  cp -a /usr/* /mnt/usr
  cp -a /home/* /mnt/home
  cp -a /home/* /mnt/home
-
this will cost time so don't allow your N800 to die because of a low battery!
+
Ensure your N800 is plugged in, since this operation will take some time.
=== Setting things up ===
=== 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 ==
+
First, reflash your tablet, after carefully backing up any data you will need later, to free up space in internal memory and get back to factory settings.
-
things might work also without a backup, but make one anyway, unless you trust me blindly and you want to test the procedure.
+
Then use the Application manager to remove packages which are safe to remove. Some examples of packages which can safely be removed are the Maemo tutorial and documentation packages.
-
short list of things to do:
+
Boot the system with flash card in place, and ensure that your old data is there. To do this, [[Root access | become root]] and create a custom boot script which will mount partitions from your flash card:
-
=== 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
  #!/bin/sh
   
   
Line 77: Line 63:
  cd /etc/init.d; for i in 2 3 4 5; do ln -s ../init.d/mount_custom /etc/rc$i.d/S15mount_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 check that /mnt/usr and /mnt/home contain your data.
-
now reboot and it's up to you how you want to check that /mnt/usr and /mnt/home contain what you expected
+
You will need to re-copy your system files on top of your back-up of /usr to ensure a consisten system:
-
 
+
-
=== New files to old /usr ===
+
-
copy the new files from /usr to /mnt/usr
+
  cp -a /usr/* /mnt/usr
  cp -a /usr/* /mnt/usr
-
as for the first time, this too will take time so be patient and do not let your N800 suffer electricity hunger.
+
As before, this will take time and plug in your tablet.
-
=== Back to work ===
+
Edit '''/etc/init.d/mount_custom''' again, setting '''MOUNT_ROOT=/''' and reboot if you dare.
-
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 or correct the description yourself.
+
Your flash card partitions will now be mounted at /usr and /home, and will hide the system directories underneath.
=== Restoring without a Backup ===
=== Restoring without a Backup ===
-
in a bare N8x0 after a reflash you would see a totally empty menu and the system would offer you reinstalling all programs.  you can still use this option also on the setup described above.
+
In a bare N8x0 after a reflash you will see an empty menu. You need to re-configure repositories and re-install all the applications you had before.
-
on the other hand, if you follow the above instructions, your application menu would not be empty and in general your palmtop would look a lot like as if you had not just reflashed it.  this is quite obvious, as reflashing the internal memory will not affect your /usr nor /home partitions.
+
After following this procedure, when you re-flash your tablet, you should still see all of your applications and personal data, since /usr and /home will not be affected.
-
unfortunately even if your application menu would offer you just the same options as before the reflash, it is extremely application dependent if a program will work out of the box or not.  as a general rule, assume they won't work and that you need doing a restore from a backup anyway.
+
However, even though applications will show up in the menu, many applications will be missing configuration files or other data required to run, and you will probably need to restore them from a back-up before using them again.
-
on one occasion I preferred not using a backup and I used the application menu as a list of things to reinstall.  this helped me to clean up my repository list, which was quite messed up after that trouble with repostory/repository...
+
The list of applications which appears in the application menu will serve as a list of applications which you should re-install after a re-flash.
=== Power Consumption ===
=== Power Consumption ===
-
the power consumption of the machine does go up this way and, more importantly, it will not be able to work once the charge is too low to read/write the flash cards. so this setup DOES shorten your autonomy...  I did consider stepping back, but a quick check on the usage of my /usr partition convinced me otherwise: even if I removed 30% of the installed programs I would still have zero space for user files.
+
The power consumption of your tablet will be higher when using ext2 partitions on a Flash card, and your system will not work once the charge is too low to read/write the flash cards. This setup shortens your autonomy.

Revision as of 09:21, 20 October 2009

This method is not recommended, as it is more fragile, and less usable than straight flash booting. Please use the steps for booting from a flash card instead!

Contents

Why move directories to a flash card

  • 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

Alternative

Booting from a flash card allows you to have your entire system running from a flash card, and thus to have your Home directory limited only by the sizee of the flash card.

The reasons for doing this, rather than following the instructions here, are detailes in the Talk: page of the page describing creating ext2 partitions for your tablet.

This page details the steps the author followed to solve a problem, and represents his personal experiences.

It is strongly advised that if you have these issues, that you try booting from a flash card.

Needed

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

First time

Partitioning

Partition your flash card, deciding how much space you want to reserve for /usr and how much for /home.

Suggested values for partition sizes are 500MB for /usr and 1.5GB for /home, respectively in partitions 2 and 3. Leave a small FAT16 partition on the card in 1st position to prevent other systems considering that the card is corrupted and trying to "recover" it...

It is suggested that you leave the card in your N800.

Copying your data to the new file systems

After creating the partitions and initializing them, mount them at /mnt/usr and /mnt/home, and copy /usr/* and /home/* there, keeping file attributes:

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

Ensure your N800 is plugged in, since this operation will take some time.

Setting things up

First, reflash your tablet, after carefully backing up any data you will need later, to free up space in internal memory and get back to factory settings.

Then use the Application manager to remove packages which are safe to remove. Some examples of packages which can safely be removed are the Maemo tutorial and documentation packages.

Boot the system with flash card in place, and ensure that your old data is there. To do this, become root and create a custom boot script which will mount partitions from your flash card:

#!/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

Now reboot and check that /mnt/usr and /mnt/home contain your data. You will need to re-copy your system files on top of your back-up of /usr to ensure a consisten system:

cp -a /usr/* /mnt/usr

As before, this will take time and plug in your tablet.

Edit /etc/init.d/mount_custom again, setting MOUNT_ROOT=/ and reboot if you dare.

Your flash card partitions will now be mounted at /usr and /home, and will hide the system directories underneath.

Restoring without a Backup

In a bare N8x0 after a reflash you will see an empty menu. You need to re-configure repositories and re-install all the applications you had before.

After following this procedure, when you re-flash your tablet, you should still see all of your applications and personal data, since /usr and /home will not be affected.

However, even though applications will show up in the menu, many applications will be missing configuration files or other data required to run, and you will probably need to restore them from a back-up before using them again.

The list of applications which appears in the application menu will serve as a list of applications which you should re-install after a re-flash.

Power Consumption

The power consumption of your tablet will be higher when using ext2 partitions on a Flash card, and your system will not work once the charge is too low to read/write the flash cards. This setup shortens your autonomy.