Repartitioning the flash
(add some links to similar solutions) |
(solution1) |
||
Line 38: | Line 38: | ||
== Solution #1: swap /home and MyDocs partition == | == Solution #1: swap /home and MyDocs partition == | ||
TODO, see [http://talk.maemo.org/showpost.php?p=424811&postcount=66 how to swap FAT and ext3 parition] | TODO, see [http://talk.maemo.org/showpost.php?p=424811&postcount=66 how to swap FAT and ext3 parition] | ||
+ | '''The following instructions are untested.''' | ||
+ | |||
+ | We assume you have the standard Nokia partition layout on your device. | ||
+ | |||
+ | '''Warning: the contents of MyDocs will deleted. Perform a backup!''' | ||
+ | |||
+ | All instructions must be executed s root (either from Terminal or via ssh, type "root" as user to become root). | ||
+ | copy & paste is recommened (typos are dangerous). For the table file use "vi" or "cat > table" and Ctrl+D to quit. | ||
+ | umount /home/user/MyDocs | ||
+ | sfdisk -c /dev/mmcblk0 1 83 # optional (safer): change FAT to ext3 id | ||
+ | mkfs.ext3 /dev/mmcblk0p1 # create ext3 on large partition | ||
+ | mount /dev/mmcblk0p1 /mnt # mount new /home | ||
+ | cp -a /home/* /mnt # copy contents of /home to large partition | ||
+ | umount /mnt # unmount it | ||
+ | create the file "table": | ||
+ | /dev/mmcblk0p1 : start= 56631360, size= 4194304, Id= c | ||
+ | /dev/mmcblk0p2 : start= 64, size= 56631296, Id=83 | ||
+ | /dev/mmcblk0p3 : start= 60825664, size= 1572864, Id=82 | ||
+ | /dev/mmcblk0p4 : start= 0, size= 0, Id= 0 | ||
+ | continue with | ||
+ | sfdisk /dev/mmcblk0 < table # change partition table, swap p1 and p2 | ||
+ | reboot; exit # reboot to re-read new table | ||
+ | after reboot | ||
+ | mkfs.vfat -F32 /dev/mmcblk0p1 # create VFAT on 2GB partition | ||
+ | mount /home/user/MyDocs # mount it | ||
+ | voila! | ||
+ | |||
+ | === How to revert === | ||
+ | Warning: /home must have less than 2GB usage! MyDocs will be deleted! | ||
+ | |||
+ | umount /home/user/MyDocs | ||
+ | sfdisk -c /dev/mmcblk0 1 83 # optional (safer): change FAT to ext3 id | ||
+ | mkfs.ext3 /dev/mmcblk0p1 # create ext3 on smaller partition | ||
+ | mount /dev/mmcblk0p1 /mnt # mount new /home | ||
+ | cp -a /home/* /mnt # copy contents of /home to large partition | ||
+ | umount /mnt # unmount it | ||
+ | create the file "table" (this is the original layout): | ||
+ | /dev/mmcblk0p1 : start= 64, size= 56631296, Id=c | ||
+ | /dev/mmcblk0p2 : start= 56631360, size= 4194304, Id= 83 | ||
+ | /dev/mmcblk0p3 : start= 60825664, size= 1572864, Id=82 | ||
+ | /dev/mmcblk0p4 : start= 0, size= 0, Id= 0 | ||
+ | continue with | ||
+ | sfdisk /dev/mmcblk0 < table # change partition table, swap p1 and p2 | ||
+ | reboot; exit # reboot to re-read new table | ||
+ | after reboot | ||
+ | mkfs.vfat -F32 /dev/mmcblk0p1 # create VFAT on 27GB partition | ||
+ | mount /home/user/MyDocs # mount it | ||
== Solution #2: shrink MyDocs to add additional partitions == | == Solution #2: shrink MyDocs to add additional partitions == |
Revision as of 10:38, 28 February 2010
Repartitioning the flash
There are several reasons why users might want to repartition their eMMC flash:
- many Maemo power users have a Linux background. They tend to prefer POSIX filesystems like ext3 over the ancient VFAT filesystem. However, VFAT can be accessed on most non-Linux computers and would be useful to keep a small VFAT partition for data exchange with USB mass storage. With a large ext3 partition you could install much more applications, store symlinks and permissions (e.g., for backup of your desktop PC), or create Linux chroot enviroments (e.g., for installing non-optified software or Debian).
- booting alternative operating systems (e.g., Mer,Moebian, Fedora) requires independent partitions
- loopback files for chroots (see Easy Debian) can be stored in VFAT MyDocs, but access is much slower than on a native partition. loopback files in MyDocs are not available during USB mass storage mode.
By default the eMMC on the N900 (/dev/mmcblk0) is partitioned as follows:
- 27GB VFAT MyDocs partition
- 2GB /home partition
- 768MB swap partition
This page describes several possible solutions:
- Swap the 2GB /home and 27GB MyDocs partition to get a 2GB vfat MyDocs and a 27GB ext3 /home. No partition size need to be changed and only a single reboot is necessary. This is the least invasive solution and can be easily reverted. It leaves a smaller MyDocs partition for VFAT USB mass storage mode.
- shrink MyDocs to add additional partitions (e.g., for other OS).
- setup an arbitrary /home and MyDocs division of the space. this is a little bit more complicated.
- get rid of the MyDocs partition, setup a single 31GB ext3 partition, and replace MyDocs with loopback file(s) that could also be USB exported and have arbitrary size and filesystem. This is useful if you rarely need USB mass storage mode or if you want to export different filesystem images depending on the computer. However, the loopback files may be significantly slower.
What you should know before partitioning
- BACKUP YOUR DATA: a mistake during partitioning could brick your device, lead to complete data loss and could require reflashing. Use the Backup application to backup all settings etc. Backup this and the contents of MyDocs to your computer. Remove your optional SD card to prevent data loss. Following this tutorial should minimize your risk of data loss but repartitioning is at your own risk.
- make sure your battery is not nearly empty (rebooting costs a lot of power) or, even better, plug in your charger.
some remarks
- partitions on flash should be aligned to flash block sizes (AFAIK this is 32K, but some sources claims 64K or 128K). To be on the safe side use 128K.
- the only fdisk utility on the device is sfdisk. fdisk could be extracted from Debian packages but it aligns partitions based virtual harddisk cylinders and not on flash blocks.
- to modify the whole partition table use "sfdisk -d /dev/mmcblk0 > table", edit the file table, and overwrite the partition table with "sfdisk /dev/mmcblk0 < table"
- ids of single partitions can be changed with "sfdisk -c /dev/mmcblk0 2 83" (this example changes the 2nd partition to 83=Linux).
- Maemo hardcodes the MyDocs partition as /dev/mmcblk0p1 in several applications. If you keep a VFAT partition, make sure it is the 1st partition (partitions in the table do not need to have the same order as on the disk). Otherwise you have to modified several scripts belonging to ke-recv.
- the most relevant scripts for partitioning are /etc/event.d/rcS-late, /usr/sbin/osso-usb-mass-storage-enable.sh and /usr/sbin/osso-usb-mass-storage-disable.sh
- is not a good idea to unmount /home in a running system. umounting /home/user/MyDocs is generally safe (if all applications are closed).
- you can boot without a /home partition (for example, by commenting out the line in rcS-late or by change the partition ids to something else than 83). Maemo will create a default home (about 10M) on NAND. Most relevant settings (wifi, desktop) are stored on NAND anyway. make sure to "rm -rf /home/user" before reboot. This trick is useful if want to change the layout of eMMC completely.
- ext3 partitions can be grown online, but not be shrinked.
- parted does not work on Maemo (it always crashed due to some mmap problem).
- if you don't want a VFAT MyDocs partition, you need to create MyDocs/DCIM directory with users permission for the camera app to work proper permissions.
Solution #1: swap /home and MyDocs partition
TODO, see how to swap FAT and ext3 parition The following instructions are untested.
We assume you have the standard Nokia partition layout on your device.
Warning: the contents of MyDocs will deleted. Perform a backup!
All instructions must be executed s root (either from Terminal or via ssh, type "root" as user to become root). copy & paste is recommened (typos are dangerous). For the table file use "vi" or "cat > table" and Ctrl+D to quit.
umount /home/user/MyDocs sfdisk -c /dev/mmcblk0 1 83 # optional (safer): change FAT to ext3 id mkfs.ext3 /dev/mmcblk0p1 # create ext3 on large partition mount /dev/mmcblk0p1 /mnt # mount new /home cp -a /home/* /mnt # copy contents of /home to large partition umount /mnt # unmount it
create the file "table":
/dev/mmcblk0p1 : start= 56631360, size= 4194304, Id= c /dev/mmcblk0p2 : start= 64, size= 56631296, Id=83 /dev/mmcblk0p3 : start= 60825664, size= 1572864, Id=82 /dev/mmcblk0p4 : start= 0, size= 0, Id= 0
continue with
sfdisk /dev/mmcblk0 < table # change partition table, swap p1 and p2 reboot; exit # reboot to re-read new table
after reboot
mkfs.vfat -F32 /dev/mmcblk0p1 # create VFAT on 2GB partition mount /home/user/MyDocs # mount it
voila!
How to revert
Warning: /home must have less than 2GB usage! MyDocs will be deleted!
umount /home/user/MyDocs sfdisk -c /dev/mmcblk0 1 83 # optional (safer): change FAT to ext3 id mkfs.ext3 /dev/mmcblk0p1 # create ext3 on smaller partition mount /dev/mmcblk0p1 /mnt # mount new /home cp -a /home/* /mnt # copy contents of /home to large partition umount /mnt # unmount it
create the file "table" (this is the original layout):
/dev/mmcblk0p1 : start= 64, size= 56631296, Id=c /dev/mmcblk0p2 : start= 56631360, size= 4194304, Id= 83 /dev/mmcblk0p3 : start= 60825664, size= 1572864, Id=82 /dev/mmcblk0p4 : start= 0, size= 0, Id= 0
continue with
sfdisk /dev/mmcblk0 < table # change partition table, swap p1 and p2 reboot; exit # reboot to re-read new table
after reboot
mkfs.vfat -F32 /dev/mmcblk0p1 # create VFAT on 27GB partition mount /home/user/MyDocs # mount it
Solution #2: shrink MyDocs to add additional partitions
TODO, see Repartitioning: create extended partitions
Solution #3: arbitrary size for /home and MyDocs
TODO, see User:Ruskie#Repartitioning
Solution #4: single large /home partition, loopback for USB
TODO, see how to implement USB mass storage with a loopback file