Repartitioning the flash
helldragon (Talk | contribs) m (→What you should know before partitioning) |
(wikify slightly, categorize) |
||
Line 1: | Line 1: | ||
- | |||
- | |||
There are several reasons why users might want to repartition their eMMC 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: | + | ==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: | This page describes several possible solutions: | ||
- | # Swap the | + | # [[#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. |
- | # 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 arbitrary /home 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. |
- | # get rid of the MyDocs partition, setup a single | + | # [[#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 == | == 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). | |
- | All instructions must be executed 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. |
- | copy & paste is | + | |
- | + | ||
- | + | ||
- | + | == 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> | ||
+ | ** 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. | ||
+ | * ext3 partitions can be grown online, but not be shrinked. | ||
+ | * [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 == |
'''WARNING: The following instructions have not been tested thoroughly yet!''' | '''WARNING: The following instructions have not been tested thoroughly yet!''' | ||
Line 47: | Line 45: | ||
'''WARNING: Please have a look at [http://talk.maemo.org/showpost.php?p=709886&postcount=191 Titan's comments] Before Proceeding!''' | '''WARNING: Please have a look at [http://talk.maemo.org/showpost.php?p=709886&postcount=191 Titan's comments] Before Proceeding!''' | ||
- | It | + | It seems that with [[Maemo 5/PR1.2|PR1.2]] release below methods do not work as it is impossible to boot without <code>/home</code>. Just so that someone who missed the post doesn't have to reflash 5-6 times after tries & retries only to find it will not work. |
- | Solution #1 Seems to be working fine as /home is preserved. | + | Solution #1 Seems to be working fine as <code>/home</code> is preserved. |
- | == 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] | ||
Line 78: | Line 76: | ||
voila! | voila! | ||
- | === How to revert === | + | ==== How to revert ==== |
- | '''Warning: /home must have less than | + | '''Warning: /home must have less than 2 GB usage! MyDocs will be deleted!''' |
umount /home/user/MyDocs | umount /home/user/MyDocs | ||
Line 100: | Line 98: | ||
mount /home/user/MyDocs # mount it | mount /home/user/MyDocs # mount it | ||
- | == Solution #2: shrink MyDocs to add additional partitions == | + | === Solution #2: shrink MyDocs to add additional partitions === |
TODO, see [https://garage.maemo.org/plugins/wiki/index.php?RepartitionInstructions&id=1382&type=g Repartitioning: create extended partitions] | TODO, see [https://garage.maemo.org/plugins/wiki/index.php?RepartitionInstructions&id=1382&type=g Repartitioning: create extended partitions] | ||
Line 106: | Line 104: | ||
umount /home/user/MyDocs | umount /home/user/MyDocs | ||
- | create a new partition layout in file "table" (here | + | 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 124: | Line 122: | ||
reboot and restore MyDocs | reboot and restore MyDocs | ||
- | == Solution #3: arbitrary size for /home and MyDocs == | + | === Solution #3: arbitrary size for /home and MyDocs === |
TODO, see also [[User:Ruskie#Repartitioning]] | TODO, see also [[User:Ruskie#Repartitioning]] | ||
Line 131: | Line 129: | ||
create your new partition table layout in the file "table". | create your new partition table layout in the file "table". | ||
- | Make sure all partitions are aligned to | + | Make sure all partitions are aligned to 32 KB and sizes are multiples of 32 KB. |
- | The sectors are | + | The sectors are 512 bytes, so the block counts must multiplied by 2. |
For example, 2GB= 4194304 blocks. Each partition should start at start+size of the previous partition. | For example, 2GB= 4194304 blocks. Each partition should start at start+size of the previous partition. | ||
The first partition must start at 64. Make sure to keep the swap partition (the number may be changed). | The first partition must start at 64. Make sure to keep the swap partition (the number may be changed). | ||
Initially set the id of your partition to 0 so that they are not mounted at reboot. | Initially set the id of your partition to 0 so that they are not mounted at reboot. | ||
- | An example layout with | + | An example layout with 2 GB part1 and 27 GB part2: |
unit: sectors | unit: sectors | ||
/dev/mmcblk0p1 : start= 64, size= 4194304 , Id=0 | /dev/mmcblk0p1 : start= 64, size= 4194304 , Id=0 | ||
Line 160: | Line 158: | ||
finally restore all your backups | finally restore all your backups | ||
- | == Solution #4: single large /home partition, loopback for USB == | + | === Solution #4: single large /home partition, loopback for USB === |
TODO, see [http://talk.maemo.org/showpost.php?p=425359&postcount=68 how to implement USB mass storage with a loopback file] | TODO, see [http://talk.maemo.org/showpost.php?p=425359&postcount=68 how to implement USB mass storage with a loopback file] | ||
Line 174: | Line 172: | ||
== References == | == References == | ||
- | + | * [https://maemo.org/community/brainstorm/view/more_efficient_and_flexible_use_of_internal_flash brainstorm] and [http://talk.maemo.org/showthread.php?t=37869 discussion] | |
- | + | * [http://talk.maemo.org/showthread.php?t=35122 Repartitioning the flash] | |
[[Category:Power users]] | [[Category:Power users]] | ||
+ | [[Category:N900]] |
Revision as of 08:14, 19 July 2010
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.
Contents |
Default partition setup
By default the eMMC on the N900 (/dev/mmcblk0
) is partitioned as follows:
- 27 GB VFAT MyDocs partition
- 2 GB
/home
partition - 768 MB swap partition
This page describes several possible solutions:
- Swap the 2 GB
/home
and 27GB MyDocs partition to get a 2 GB VFAT MyDocs and a 27 GB 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 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 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
- 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
fdisk
utility on the device issfdisk
.fdisk
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
sfdisk -d /dev/mmcblk0 > table
edit the file table, and overwrite the partition table withsfdisk --no-reread /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).
- to modify the whole partition table use
- Maemo hardcodes the MyDocs partition as
/dev/mmcblk0p1
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. -
/home
is the first ext3 partition, swap can be any partition number. - 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
- it 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 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 torm -rf /home/user
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 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.
Solutions
WARNING: The following instructions have not been tested thoroughly yet! Please report problems, positive and negative feedback to this address.
WARNING: Please have a look at Titan's comments Before Proceeding!
It seems that with PR1.2 release below methods do not work as it is impossible to boot without /home
. Just so that someone who missed the post doesn't have to reflash 5-6 times after tries & retries only to find it will not work.
Solution #1 Seems to be working fine as /home
is preserved.
Solution #1: swap /home and MyDocs partition
TODO, see how to swap FAT and ext3 parition
We assume you have the standard Nokia partition layout on your device.
Warning: the contents of MyDocs will deleted. Perform a backup!
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":
unit: sectors /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 --no-reread /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 2 GB 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):
unit: sectors /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 --no-reread /dev/mmcblk0 < table # change partition table, swap p1 and p2 reboot; exit # reboot to re-read new table
after reboot
mkfs.vfat -F32 -s64 /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
Warning: the contents of MyDocs will deleted. Perform a backup!
umount /home/user/MyDocs
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 /dev/mmcblk0p1 : start= 64, size= 39854080, Id= 0 /dev/mmcblk0p2 : start= 39854144, size= 16777216, Id= 5 /dev/mmcblk0p3: start= 56631360, size= 4194304, Id=83 /dev/mmcblk0p4 : start= 60825664, size= 1572864, Id=82 /dev/mmcblk0p5 : start= 39854160, size= 9765680, Id=83 /dev/mmcblk0p6 : start= 49619856, size= 7011504, Id=83
continue with
sfdisk --no-reread /dev/mmcblk0 < table # change partition table reboot; exit # reboot to re-read new table
after reboot
sfdisk -c /dev/mmcblk0 1 c # optional (safer): change FAT to ext3 id mkfs.vfat -F32 /dev/mmcblk0p1 # recreate VFAT on MyDocs mkfs.ext3 /dev/mmcblk0p5 mkfs.ext3 /dev/mmcblk0p6
reboot and restore MyDocs
Solution #3: arbitrary size for /home and MyDocs
TODO, see also User:Ruskie#Repartitioning
Warning: /home and MyDocs will be deleted. Backup everything. Backup all settings (to your computer or SD), reflash, restore the settings and install rootsh (no other applications!).
create your new partition table layout in the file "table". Make sure all partitions are aligned to 32 KB and sizes are multiples of 32 KB. The sectors are 512 bytes, so the block counts must multiplied by 2. For example, 2GB= 4194304 blocks. Each partition should start at start+size of the previous partition. The first partition must start at 64. Make sure to keep the swap partition (the number may be changed). Initially set the id of your partition to 0 so that they are not mounted at reboot. An example layout with 2 GB part1 and 27 GB part2:
unit: sectors /dev/mmcblk0p1 : start= 64, size= 4194304 , Id=0 /dev/mmcblk0p2 : start= 4194368, size= 56631296, Id=0 /dev/mmcblk0p3 : start= 60825664, size= 1572864, Id=82 /dev/mmcblk0p4 : start= 0, size= 0, Id= 0
(Optional) Dump your current partition table with the following command
sfdisk -d /dev/mmcblk0 > table
continue with
sfdisk --no-reread /dev/mmcblk0 < table # change partition table reboot; exit
The device creates a default /home in NAND. Now change the parition ids and create the file systems
sfdisk -c /dev/mmcblk0 1 c mkfs.vfat -F32 -s64 /dev/mmcblk0p1 sfdisk -c /dev/mmcblk0 2 83 mkfs.ext3 /dev/mmcblk0p2
if you have change to location or size of swap run
mkswap <swap-partition>
finish with
rm -rf /home/user reboot; exit
finally restore all your backups
Solution #4: single large /home partition, loopback for USB
TODO, see how to implement USB mass storage with a loopback file
like solution #3, but don't create a MyDocs partition.
how to create a sparse 1GB loopback file:
dd if=/dev/zero of=FAT1GB bs=1M seek=1024 count=0 # small 256MB image losetup /dev/loop0 FAT1GB mkfs.vfat -F32 /dev/loop0 vi /etc/fstab # replace /dev/mmcblk0p2 with /dev/loop0 mount MyDocs