Repartitioning the flash
(→Solution #6: Custom repartitioning from a linux PC) |
(→Using GParted - Resizing made simple) |
||
(19 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
- | There are several reasons why | + | By default the internal eMMC flash card on the [[Nokia N900|N900]] (<code>/dev/mmcblk0</code>) is partitioned as follows: |
- | * | + | # 27 GiB VFAT [[MyDocs folder|MyDocs partition]] on <code>/dev/mmcblk0p1</code>. When Maemo is booted, this is mounted on /home/user/MyDocs, however it is unmounted and exposed when the N900 is connected to a PC in mass storage mode |
+ | # 2 GiB <code>/home</code> partition on <code>/dev/mmcblk0p2</code>. This also contains the /opt folder (mounted on /home/opt) where optified apps are stored | ||
+ | # 768 MiB swap partition <code>/dev/mmcblk0p3</code> | ||
+ | Total 32 GB (not GiB) | ||
+ | |||
+ | There are several reasons why you might want to repartition your eMMC flash: | ||
+ | * if you have a Linux background you may prefer POSIX filesystems like ext3 over the ancient VFAT filesystem. VFAT is used as it can be accessed on most non-Linux computers and is thus useful for data exchange in USB mass storage mode | ||
* 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 in MyDocs are not available during USB mass storage mode. | + | * loopback files for chroots (see [[Easy Debian]]) can be stored in VFAT MyDocs, but access is much slower than on a native partition. Also, loopback files in MyDocs are not available during USB mass storage mode |
+ | * a large /home (ext3) partition allows for many more installed applications. If backing up a linux computer it allows you to keep your filesystem permissions and other extended attributes. It can be used to create native Linux chroot enviroments (e.g., for installing non-optified software or Debian) | ||
- | == | + | ==Before partitioning== |
+ | * '''BACKUP YOUR DATA!''' A mistake during partitioning could brick your device, lead to complete data loss and require reflashing. Use the built-in Backup application to backup all settings etc. Backup this and the contents of MyDocs to your computer. Remove your microSD card to prevent data loss. Following this tutorial should minimize your risk of data loss but as always '''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. | ||
+ | * Partitions on flash memory should be aligned to flash block sizes, which are multiples of 2, for example 32 KB. To be on the safe side use 128 KB or even 1MB. | ||
- | + | ==Using GParted - Resizing made simple== | |
- | + | ||
- | + | ||
- | + | ||
- | This page describes | + | By far the simplest way to resize your partitions is to use a GParted live CD/USB http://sourceforge.net/projects/gparted/files/gparted-live-stable/, or GParted on a Linux system or use the GParted-Live-CD in VirtualBox on Windows or MacOSX. To gain access to the whole eMMC, install BackupMenu or BackupMenu-Multiboot. |
+ | |||
+ | Boot your N900 with the keyboard exposed to load BackupMenu. At this point you should also back up your rootfs and optfs to a microSD. Press w to go into USB Mass Storage mode (read-write), and connect up to your computer. You will now be able to access the whole eMMC. If you boot into Maemo rather than BackupMenu, then only the MyDocs partition will be visible. | ||
+ | |||
+ | ''It is also possible to access the full eMMC by loading the [http://wiki.meego.com/ARM/N900/Using_Rescue_Initrd Rescue Initrd and kernel]. This also gives you an option to enter USB mass storage mode (read-write).'' | ||
+ | |||
+ | ''It is a third option, to use NITdroid for accessing the full eMMC. If you have installed it to the SD Card, it can export the full eMMC as USB mass storage.'' | ||
+ | |||
+ | Because of hardcoding etc. it is easiest to leave your partitions in the same order and filesystem: MyDocs vfat(/dev/mmcblk0p1 mounted on /home/user/MyDocs), /home ext3 (/dev/mmcblk0p2), and swap (/dev/mmcblk0p3). Generally you will want to shrink MyDocs and grow /home. You can also grow the swap space, which is easier than setting up a [[swap on microSD]]. However this may not really result in much benefit (see the linked page for more information). You can then create a 4th partition if you wish. | ||
+ | |||
+ | Align to MiB, not cylinders! When you are done, apply your changes then disconnect and reboot your N900 and everything should load as usual. It would be very unlikely for something to go wrong if you only resized MyDocs and /home. If something does go wrong, you will need to reflash the eMMC. You should try again at this point. If you want to give up then you will need to restore your optfs from the BackupMenu backup as well as copy the MyDocs files back over. | ||
+ | |||
+ | If you want to have more than 4 partitions, create an extended partition. Always keep MyDocs as the first partition, and the first ext3 partition as /home. (Not sure whether an ext3 inside an extended partition would count.) You can edit genfstab.awk (more proper way, resembling how Maemo does it natively) or rcS-late (in this case, system does "double work", as it first proceed genfstab.awk, then overwrite commands by rcS-late ones) to automount any new partitions, or just mount them normally. (Remember to use mount options noatime, and maybe nodiratime,nobh as well) | ||
+ | |||
+ | ==Manual solutions== | ||
+ | The rest of this page describes manual 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. |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
== Some remarks == | == Some remarks == | ||
+ | * Maemo hardcodes the MyDocs partition as <code>/dev/mmcblk0p1</code> in several applications. If you want MyDocs as VFAT, it must be the first partition in the table (but not necessarily the first on the disk). To get around this, you could modify several scripts belonging to ke-recv | ||
+ | ** if you don't want a VFAT MyDocs partition, you need to create MyDocs/DCIM directory with "user" permissions for the camera app to work [https://bugs.maemo.org/show_bug.cgi?id=7160 proper permissions]. | ||
+ | * <code>/home</code> is the first ext3 partition, swap can be any partition number | ||
+ | * 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) | ||
+ | * 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> | ||
+ | * All instructions must be executed [[root access|as root]] (either from [[Terminal]] or via ssh) | ||
+ | * copy & paste is recommended (typos are dangerous). For the table files use "vi" or "cat > table" and Ctrl+D to quit | ||
- | * | + | * 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 (you cn use option -uS in sfdisk for sector (512 byte) alignment) |
- | + | ||
** 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). | ||
- | |||
- | |||
- | |||
- | |||
* 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 shrunk. |
- | * [http://www.gnu.org/software/parted/index.shtml parted] does not work | + | * [http://www.gnu.org/software/parted/index.shtml parted] does not work from inside Maemo (it always crashed due to some mmap problem), works fine when booting from backupmenu and working outside of maemo. |
- | * | + | * If you create a new ext3 filesystem, you might want to do <code>tune2fs -c0 -i0 device</code> on your new newly created ext3 filesystems so the fs is never fsck'd on boot (these are the settings on the default ext3 /home partition). |
- | + | ||
== Solutions == | == Solutions == | ||
Line 76: | Line 92: | ||
mount /home/user/MyDocs # mount it | mount /home/user/MyDocs # mount it | ||
voila! | voila! | ||
+ | |||
+ | NB: To check size of new home partition | ||
+ | du -ch /home | grep total | ||
==== How to revert ==== | ==== How to revert ==== | ||
Line 105: | Line 124: | ||
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 MyDocs (mmcblk0p1) is shrunk to 19GB (39854080*512)/(1024^3), and mmcblk0p2 is an 8GB extended partition containing ext3 partitions mmcblk0p5 and 6 (4.7GB and 3.3GB respectively). Swap is mmcblk0p4 (768MB) and /home is mmcblk0p3 (2GB). |
unit: sectors | unit: sectors | ||
/dev/mmcblk0p1 : start= 64, size= 39854080, Id= 0 | /dev/mmcblk0p1 : start= 64, size= 39854080, Id= 0 | ||
Line 142: | Line 161: | ||
/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.old |
continue with | continue with | ||
sfdisk --no-reread /dev/mmcblk0 < table # change partition table | sfdisk --no-reread /dev/mmcblk0 < table # change partition table | ||
Line 174: | Line 193: | ||
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 = 4096;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 214: | Line 233: | ||
''' 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: Custom repartitioning from a linux PC without R&D mode === | |
+ | Shorter variant of #6, using a boot manager instead of R&D mode (no flasher on host required) | ||
- | === Solution # | + | * Install backupmenu package first (see [http://talk.maemo.org/showthread.php?t=63975 Announce Thread] for details) |
+ | * If you want to change file systems (like ext3 to ext2), do that now | ||
+ | * Shut down N900 | ||
+ | * Start with slider open, USB cable removed | ||
+ | * BackupMenu will show up. | ||
+ | * Insert USB cable. Press '''w''' to enable USB mass storage mode | ||
+ | * The internal memory will now show up as additional device on your computer, like /dev/sdb. Unmount if automounted and do your resizing. | ||
+ | * Remove device, press '''d''' on the N900 to disconnect | ||
+ | * Press '''q''' and close the slider immediately. The N900 will reboot and the job is done | ||
+ | |||
+ | === Solution #8: 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 287: | Line 317: | ||
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 == |
Latest revision as of 21:49, 5 February 2013
By default the internal eMMC flash card on the N900 (/dev/mmcblk0
) is partitioned as follows:
- 27 GiB VFAT MyDocs partition on
/dev/mmcblk0p1
. When Maemo is booted, this is mounted on /home/user/MyDocs, however it is unmounted and exposed when the N900 is connected to a PC in mass storage mode - 2 GiB
/home
partition on/dev/mmcblk0p2
. This also contains the /opt folder (mounted on /home/opt) where optified apps are stored - 768 MiB swap partition
/dev/mmcblk0p3
Total 32 GB (not GiB)
There are several reasons why you might want to repartition your eMMC flash:
- if you have a Linux background you may prefer POSIX filesystems like ext3 over the ancient VFAT filesystem. VFAT is used as it can be accessed on most non-Linux computers and is thus useful for data exchange in USB mass storage mode
- 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. Also, loopback files in MyDocs are not available during USB mass storage mode
- a large /home (ext3) partition allows for many more installed applications. If backing up a linux computer it allows you to keep your filesystem permissions and other extended attributes. It can be used to create native Linux chroot enviroments (e.g., for installing non-optified software or Debian)
[edit] Before partitioning
- BACKUP YOUR DATA! A mistake during partitioning could brick your device, lead to complete data loss and require reflashing. Use the built-in Backup application to backup all settings etc. Backup this and the contents of MyDocs to your computer. Remove your microSD card to prevent data loss. Following this tutorial should minimize your risk of data loss but as always 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.
- Partitions on flash memory should be aligned to flash block sizes, which are multiples of 2, for example 32 KB. To be on the safe side use 128 KB or even 1MB.
[edit] Using GParted - Resizing made simple
By far the simplest way to resize your partitions is to use a GParted live CD/USB http://sourceforge.net/projects/gparted/files/gparted-live-stable/, or GParted on a Linux system or use the GParted-Live-CD in VirtualBox on Windows or MacOSX. To gain access to the whole eMMC, install BackupMenu or BackupMenu-Multiboot.
Boot your N900 with the keyboard exposed to load BackupMenu. At this point you should also back up your rootfs and optfs to a microSD. Press w to go into USB Mass Storage mode (read-write), and connect up to your computer. You will now be able to access the whole eMMC. If you boot into Maemo rather than BackupMenu, then only the MyDocs partition will be visible.
It is also possible to access the full eMMC by loading the Rescue Initrd and kernel. This also gives you an option to enter USB mass storage mode (read-write).
It is a third option, to use NITdroid for accessing the full eMMC. If you have installed it to the SD Card, it can export the full eMMC as USB mass storage.
Because of hardcoding etc. it is easiest to leave your partitions in the same order and filesystem: MyDocs vfat(/dev/mmcblk0p1 mounted on /home/user/MyDocs), /home ext3 (/dev/mmcblk0p2), and swap (/dev/mmcblk0p3). Generally you will want to shrink MyDocs and grow /home. You can also grow the swap space, which is easier than setting up a swap on microSD. However this may not really result in much benefit (see the linked page for more information). You can then create a 4th partition if you wish.
Align to MiB, not cylinders! When you are done, apply your changes then disconnect and reboot your N900 and everything should load as usual. It would be very unlikely for something to go wrong if you only resized MyDocs and /home. If something does go wrong, you will need to reflash the eMMC. You should try again at this point. If you want to give up then you will need to restore your optfs from the BackupMenu backup as well as copy the MyDocs files back over.
If you want to have more than 4 partitions, create an extended partition. Always keep MyDocs as the first partition, and the first ext3 partition as /home. (Not sure whether an ext3 inside an extended partition would count.) You can edit genfstab.awk (more proper way, resembling how Maemo does it natively) or rcS-late (in this case, system does "double work", as it first proceed genfstab.awk, then overwrite commands by rcS-late ones) to automount any new partitions, or just mount them normally. (Remember to use mount options noatime, and maybe nodiratime,nobh as well)
[edit] Manual solutions
The rest of this page describes manual 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.
[edit] Some remarks
- Maemo hardcodes the MyDocs partition as
/dev/mmcblk0p1
in several applications. If you want MyDocs as VFAT, it must be the first partition in the table (but not necessarily the first on the disk). To get around this, you could modify several scripts belonging to ke-recv- if you don't want a VFAT MyDocs partition, you need to create MyDocs/DCIM directory with "user" permissions for the camera app to work proper permissions.
-
/home
is the first ext3 partition, swap can be any partition number - 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) - 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
- All instructions must be executed as root (either from Terminal or via ssh)
- copy & paste is recommended (typos are dangerous). For the table files use "vi" or "cat > table" and Ctrl+D to quit
- 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 (you cn use option -uS in sfdisk for sector (512 byte) alignment)- 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
- 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 shrunk.
- parted does not work from inside Maemo (it always crashed due to some mmap problem), works fine when booting from backupmenu and working outside of maemo.
- If you create a new ext3 filesystem, you might want to do
tune2fs -c0 -i0 device
on your new newly created ext3 filesystems so the fs is never fsck'd on boot (these are the settings on the default ext3 /home partition).
[edit] 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.
[edit] 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!
NB: To check size of new home partition
du -ch /home | grep total
[edit] 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
[edit] 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 MyDocs (mmcblk0p1) is shrunk to 19GB (39854080*512)/(1024^3), and mmcblk0p2 is an 8GB extended partition containing ext3 partitions mmcblk0p5 and 6 (4.7GB and 3.3GB respectively). Swap is mmcblk0p4 (768MB) and /home is mmcblk0p3 (2GB).
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
[edit] 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.old
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
[edit] 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
[edit] Solution #5: Edit eMMC image (works on PR1.2, by globalbus)
Backup MyDocs, we need to flash device. Open eMMC image in hex editor, go to 0xcb, you will see this
partition {size = 4096;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.
If MyDocs have incorrect size or it's not mounting automatically you need to format it and paste files from backup.
umount /dev/mmcblk0p1 mkfs.vfat -F32 -s64 /dev/mmcblk0p1 mount /dev/mmcblk0p1
[edit] Solution #6: Custom repartitioning from a linux PC
Taken from Using Rescue Initrd - MeeGo Wiki.
This way is only intended for users who have partitioned their systems before. Your files will not be affected unless you explicitly ask your partitioner to do so although there's nothing wrong with taking extra care and backing up your files
Install flasher-3.5 on your box.
Get the rescue kernel and initrd rpm and extract them in a directory:
mkdir n900-rescue-initrd cd n900-rescue-initrd wget http://repo.meego.com/MeeGo/releases/1.0/core/repos/armv7l/packages/armv7l/nokia-n900-rescue-initrd-0.1-1.3.armv7l.rpm wget http://repo.meego.com/MeeGo/releases/1.0/core/repos/armv7l/packages/armv7l/kernel-n900-2.6.33.3-11.2.armv7l.rpm rpm2cpio nokia-n900-rescue-initrd-0.1-1.3.armv7l.rpm | cpio -vid rpm2cpio kernel-n900-2.6.33.3-11.2.armv7l.rpm | cpio -vid
Now you're ready to boot the device:
Turn off your N900 by removing the battery.
Start flasher:
sudo flasher-3.5 -k boot/vmlinuz-2.6.33.3-11.2-n900 -n boot/initrd.img-rescue-2.6.33.3-11.2-n900 -l -b"rootdelay=1 root=/dev/ram0" --set-rd-flags=no-omap-wd --set-rd-flags=no-ext-wd --enable-rd-mode
Connect N900 to your PC.
Press U on the keyboard and keep holding it.
Put the battery back in.
Wait for the device to boot and press U to enable USB storage mode. The device is now added to the list of your storage devices as an increment of /dev/sd.
Partition it using your favorite partitioner (GParted recommended)
Don't forget to repeat the "Start flasher" procedure with sudo flasher-3.5 --disable-rd-mode
to disable R&D mode.
[edit] Solution #7: Custom repartitioning from a linux PC without R&D mode
Shorter variant of #6, using a boot manager instead of R&D mode (no flasher on host required)
- Install backupmenu package first (see Announce Thread for details)
- If you want to change file systems (like ext3 to ext2), do that now
- Shut down N900
- Start with slider open, USB cable removed
- BackupMenu will show up.
- Insert USB cable. Press w to enable USB mass storage mode
- The internal memory will now show up as additional device on your computer, like /dev/sdb. Unmount if automounted and do your resizing.
- Remove device, press d on the N900 to disconnect
- Press q and close the slider immediately. The N900 will reboot and the job is done
[edit] Solution #8: 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!
Prerequisites:
- Partition the MicroSD card so that it has a partition big enough to hold all data on /home (which is 2gb at its max).
- Format this partition as ext3. I'll assume you've only made one big partition (which will be /dev/mmcblk1p1 in Maemo).
- Make sure you've read and understood solution #3 completely, as this one is based on it
This method involves moving /home. If you mess up the device names, format incorrectly or copy /home wrongly, Maemo will get into an infinite reboot loop, requiring a reflash to restore!!
-Mount your freshly partitioned and formatted MicroSD card
mount /dev/mmcblk1p1 /mnt
-Unmount MyDocs (after backing it up ;)
umount /home/user/MyDocs
-Copy /home to your MicroSD card (assuming one big ext3 partition)
cp -a /home/* /mnt
-Open /usr/lib/genfstab.awk and comment out the following pieces of code
start == 1 && $6 == 83 && !__home { printf "%s /home ext3 %s 0 0\n", $1, home_opts printf "/home/opt /opt none bind\n" __home++ }
start == 1 && $6 == "c" && !__fat { printf "%s /home/user/MyDocs vfat %s 0 0\n", $1, fat_opts __fat++ }
This will make sure the default /home and MyDocs won't get mounted on reboot.
-Open /etc/event.d/rcS-late, find the line '-f /usr/lib/genfstab.awk > $tmp_fstab' and add this below it
echo "/dev/mmcblk1p1 /home ext3 rw,noatime,errors=continue,commit=1,data=writeback 0 0" >> $tmp_fstab echo "/home/opt /opt none bind" >> $tmp_fstab
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. If it is available, you can unmount it with 'umount /home/user/MyDocs'
-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 /dev/mmcblk0p1 : start= 64, size= 4194304 , Id=c /dev/mmcblk0p2 : start= 4194368, size= 56631296, Id=83 /dev/mmcblk0p3 : start= 60825664, size= 1572864, Id=82 /dev/mmcblk0p4 : start= 0, size= 0, Id= 0
Save the above code as a plain text file (eg. as table)on your N900. Use Id=c for MyDocs (FAT), 83 for EXT partitions and 82 for swap partition.
-Apply the partition table by running the following command in the same directory as the table file:
sfdisk --no-reread /dev/mmcblk0 < table
-Reboot the phone
-Format the newly created large partition as ext3
mkfs.ext3 /dev/mmcblk0p2
-And the fresh smaller one as FAT for MyDocs
mkfs.vfat -F32 -s64 /dev/mmcblk0p1
-Mount the ext3 partition as /mnt
mount /dev/mmcblk0p2 /mnt
-Copy you /home back
cp -a /home/* /mnt
-Open /usr/lib/genfstab.awk again and uncomment the code you've previously commented.
-Remove the lines from /etc/event.d/rcS-late you've added before
Reboot again and you're done!. The great part is with the aid of a MicroSD card, you can truly partition exactly as you like. For example: you can also create a swap partition on the sd card, comment out the swap part of genfstab.awk, add an "echo "/dev/mmcblk1pX none swap sw 0 0" >> $tmp_fstab" to rcS-late (where X is the MicroSD swap partition). This will allow you to repartition the swap partition on the eMMC (or completely remove it, so that only the MicroSD card will be used as swap (for discussion about this see this thread. As long as you edit rcS-late and genfstab.awk correcly, you can partition without restrictions
P.s. Solution #4 applies in the same way to this solution, as to #3
[edit] References
- This page was last modified on 5 February 2013, at 21:49.
- This page has been accessed 109,174 times.