Editing Repartitioning the flash
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
- | + | 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). | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | There are several reasons why | + | |
- | * | + | |
* booting alternative operating systems (e.g., Mer, Moebian, Fedora) requires independent partitions | * 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 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. |
- | + | ||
- | == | + | ==Default partition setup== |
- | + | ||
- | + | ||
- | + | ||
- | + | By default the eMMC on the N900 (<code>/dev/mmcblk0</code>) is partitioned as follows: | |
+ | # 27 GB VFAT [[MyDocs folder|MyDocs partition]] | ||
+ | # 2 GB <code>/home</code> partition | ||
+ | # 768 MB swap partition | ||
- | + | This page describes several possible solutions: | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
# [[#Solution .231: swap .2Fhome and MyDocs partition|Swap the 2 GB <code>/home</code> and 27GB MyDocs partition]] to get a 2 GB VFAT MyDocs and a 27 GB ext3 <code>/home</code>. 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. | # [[#Solution .231: swap .2Fhome and MyDocs partition|Swap the 2 GB <code>/home</code> and 27GB MyDocs partition]] to get a 2 GB VFAT MyDocs and a 27 GB ext3 <code>/home</code>. 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. | ||
# [[#Solution .232: shrink MyDocs to add additional partitions|shrink MyDocs to add additional partitions]] (e.g., for other OS). | # [[#Solution .232: shrink MyDocs to add additional partitions|shrink MyDocs to add additional partitions]] (e.g., for other OS). | ||
# setup an [[#Solution .233: arbitrary size for .2Fhome and MyDocs|arbitrary <code>/home</code> and MyDocs division of the space]]. this is a little bit more complicated. | # setup an [[#Solution .233: arbitrary size for .2Fhome and MyDocs|arbitrary <code>/home</code> and MyDocs division of the space]]. this is a little bit more complicated. | ||
- | # [[#Solution .234: single large .2Fhome partition.2C loopback for USB|get rid of the MyDocs partition]], setup a single 31 GB 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. | + | # [[#Solution .234: single large .2Fhome partition.2C loopback for USB|get rid of the MyDocs partition]], setup a single 31 GB 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. | ||
+ | * All instructions must be executed [[root access|as root]] (either from [[Terminal]] or via ssh, type "root" as user to become root). | ||
+ | * copy & paste is recommended (typos are dangerous). For the table files use "vi" or "cat > table" and Ctrl+D to quit. | ||
== Some remarks == | == Some remarks == | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | * | + | * partitions on flash should be aligned to flash block sizes (AFAIK this is 32 KB, but some sources claims 64 KB or 128 KB). To be on the safe side use 128 KB. |
+ | * the only <code>fdisk</code> utility on the device is <code>sfdisk</code>. <code>fdisk</code> could be extracted from Debian packages but it aligns partitions based on virtual harddisk cylinders and not on flash blocks. | ||
** to modify the whole partition table use<pre>sfdisk -d /dev/mmcblk0 > table</pre>edit the file table, and overwrite the partition table with<pre>sfdisk --no-reread /dev/mmcblk0 < table</pre> | ** to modify the whole partition table use<pre>sfdisk -d /dev/mmcblk0 > table</pre>edit the file table, and overwrite the partition table with<pre>sfdisk --no-reread /dev/mmcblk0 < table</pre> | ||
** ids of single partitions can be changed with<pre>sfdisk -c /dev/mmcblk0 2 83</pre>(this example changes the 2nd partition to 83=Linux). | ** ids of single partitions can be changed with<pre>sfdisk -c /dev/mmcblk0 2 83</pre>(this example changes the 2nd partition to 83=Linux). | ||
+ | * Maemo hardcodes the MyDocs partition as <code>/dev/mmcblk0p1</code> in several applications. If you keep a VFAT partition, make sure it is the first 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. | ||
+ | * <code>/home</code> is the first ext3 partition, swap can be any partition number. | ||
+ | * the most relevant scripts for partitioning are <code>/etc/event.d/rcS-late</code>, <code>/usr/sbin/osso-usb-mass-storage-enable.sh</code> and <code>/usr/sbin/osso-usb-mass-storage-disable.sh</code> | ||
+ | * it is not a good idea to unmount <code>/home</code> in a running system. umounting <code>/home/user/MyDocs</code> is generally safe (if all applications are closed). | ||
* you can boot without a <code>/home</code> partition (for example, by commenting out the line in rcS-late or by change the partition ids to something other than 83). Maemo will create a default home (about 10 MB) on NAND. Most relevant settings (wifi, desktop) are stored on NAND anyway. Make sure to<pre>rm -rf /home/user</pre> before reboot. This trick is useful if want to change the layout of the eMMC completely. | * you can boot without a <code>/home</code> partition (for example, by commenting out the line in rcS-late or by change the partition ids to something other than 83). Maemo will create a default home (about 10 MB) on NAND. Most relevant settings (wifi, desktop) are stored on NAND anyway. Make sure to<pre>rm -rf /home/user</pre> before reboot. This trick is useful if want to change the layout of the eMMC completely. | ||
- | * ext3 partitions can be grown online, but not be | + | * ext3 partitions can be grown online, but not be shrinked. |
- | * [http://www.gnu.org/software/parted/index.shtml parted] does not work | + | * [http://www.gnu.org/software/parted/index.shtml 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 [https://bugs.maemo.org/show_bug.cgi?id=7160 proper permissions]. |
== Solutions == | == Solutions == | ||
Line 92: | Line 75: | ||
mount /home/user/MyDocs # mount it | mount /home/user/MyDocs # mount it | ||
voila! | voila! | ||
- | |||
- | |||
- | |||
==== How to revert ==== | ==== How to revert ==== | ||
Line 124: | Line 104: | ||
umount /home/user/MyDocs | umount /home/user/MyDocs | ||
- | create a new partition layout in file "table" | + | create a new partition layout in file "table" (here 8 GB MyDocs were used for an extended partition with 3+5 GB partitions): |
unit: sectors | unit: sectors | ||
/dev/mmcblk0p1 : start= 64, size= 39854080, Id= 0 | /dev/mmcblk0p1 : start= 64, size= 39854080, Id= 0 | ||
Line 161: | Line 141: | ||
/dev/mmcblk0p4 : start= 0, size= 0, Id= 0 | /dev/mmcblk0p4 : start= 0, size= 0, Id= 0 | ||
(Optional) Dump your current partition table with the following command | (Optional) Dump your current partition table with the following command | ||
- | sfdisk -d /dev/mmcblk0 > table | + | sfdisk -d /dev/mmcblk0 > table |
continue with | continue with | ||
sfdisk --no-reread /dev/mmcblk0 < table # change partition table | sfdisk --no-reread /dev/mmcblk0 < table # change partition table | ||
Line 193: | Line 173: | ||
Backup MyDocs, we need to flash device. | Backup MyDocs, we need to flash device. | ||
Open eMMC image in hex editor, go to 0xcb, you will see this | Open eMMC image in hex editor, go to 0xcb, you will see this | ||
- | partition {size = | + | partition {size = 2048;fs_type = "ext3";prefix = "home";} |
Edit size parameter (do not change the size of file! The number must be from 1000 to 9999) Flash it now. | Edit size parameter (do not change the size of file! The number must be from 1000 to 9999) Flash it now. | ||
Line 233: | Line 213: | ||
''' Don't forget to repeat the "Start flasher" procedure with '''<code>sudo flasher-3.5 --disable-rd-mode</code> '''to disable R&D mode.''' | ''' Don't forget to repeat the "Start flasher" procedure with '''<code>sudo flasher-3.5 --disable-rd-mode</code> '''to disable R&D mode.''' | ||
- | === Solution #7 | + | === Solution #7: arbitrary size for /home and MyDocs (PR 1.2/3 compatible) === |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
This solution is based off solution #3. The key difference is that this solution uses a MicroSD card as a temporary /home, so Maemo will be able to reboot in the process, thus making this solution PR1.2 and 1.3 compatible. '''MyDocs will be deleted, make a backup of it!''' This solution is tested on a PR 1.3 reflashed device, but it should work on non-clean devices aswell. If done correctly, you won't lose any settings/calendar/etc (just MyDocs), but as repartitioning is a risky proces: '''backup everything!''' | This solution is based off solution #3. The key difference is that this solution uses a MicroSD card as a temporary /home, so Maemo will be able to reboot in the process, thus making this solution PR1.2 and 1.3 compatible. '''MyDocs will be deleted, make a backup of it!''' This solution is tested on a PR 1.3 reflashed device, but it should work on non-clean devices aswell. If done correctly, you won't lose any settings/calendar/etc (just MyDocs), but as repartitioning is a risky proces: '''backup everything!''' | ||
Line 283: | Line 250: | ||
Maemo will then use the MicroSD ext3 partition (containing a copy of your /home) as the new /home after a reboot | Maemo will then use the MicroSD ext3 partition (containing a copy of your /home) as the new /home after a reboot | ||
- | -Reboot your phone now. If all went well, you should notice no difference between now and the situation before you started, except for that MyDocs is unavailable. | + | -Reboot your phone now. If all went well, you should notice no difference between now and the situation before you started, except for that MyDocs is unavailable. |
-Now we can repartition the flash, as it is unused right now (except for the swap partition). An example layout with 2 GB MyDocs and 27 GB /home: | -Now we can repartition the flash, as it is unused right now (except for the swap partition). An example layout with 2 GB MyDocs and 27 GB /home: | ||
unit: sectors | unit: sectors | ||
- | /dev/mmcblk0p1 : start= 64, size= 4194304 , Id=c | + | /dev/mmcblk0p1 : start= 64, size= 4194304 , Id=c #c for FAT |
- | /dev/mmcblk0p2 : start= 4194368, size= 56631296, Id=83 | + | /dev/mmcblk0p2 : start= 4194368, size= 56631296, Id=83 #83 for ext3 |
- | /dev/mmcblk0p3 : start= 60825664, size= 1572864, Id=82 | + | /dev/mmcblk0p3 : start= 60825664, size= 1572864, Id=82 #82 for swap |
/dev/mmcblk0p4 : start= 0, size= 0, Id= 0 | /dev/mmcblk0p4 : start= 0, size= 0, Id= 0 | ||
- | Save the above code as a plain text file (eg. as table)on your N900 | + | Save the above code as a plain text file (eg. as table)on your N900. |
-Apply the partition table by running the following command in the same directory as the table file: | -Apply the partition table by running the following command in the same directory as the table file: | ||
Line 305: | Line 272: | ||
-Mount the ext3 partition as /mnt | -Mount the ext3 partition as /mnt | ||
- | mount /dev/ | + | mount /dev/mmcblk0p1 /mnt |
-Copy you /home back | -Copy you /home back | ||
Line 317: | Line 284: | ||
P.s. Solution #4 applies in the same way to this solution, as to #3 | P.s. Solution #4 applies in the same way to this solution, as to #3 | ||
- | |||
- | |||
== References == | == References == |
Learn more about Contributing to the wiki.