View Single Post
Posts: 210 | Thanked: 841 times | Joined on Feb 2013
#1
Hi,

i kind of hated that on the nokia N9 there are 3 partitions:
Code:
/dev/mmcblkp1 as MyDocs
/dev/mmcblkp2 as /
/dev/mmcblkp3 as /home
and MyDocs is a huge vfat partition which sucks in my opinion.

So i figured out you could use sfdisk to reformat the partitions while running in harmattan (openmode, don't know if that matters, but i think it doesn't) and even use ext3 or something else as partition type for the new partitions you might add. If you dont want to add a partition you can just set the partition type of partition 1 to Linux, will work just as good but i liked to have a small FAT partition for swapping files between operating systems at home, university and so on...

my partition table looks like this now:
Code:
# /sbin/sfdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 1957120 cylinders, 4 heads, 16 sectors/track
Units = cylinders of 32768 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/mmcblk0p1         16  100015  100000    3200000    c  W95 FAT32 (LBA)
/dev/mmcblk0p2     1760512  1891583  131072    4194304   83  Linux
/dev/mmcblk0p3     1891584  1957119   65536    2097152   83  Linux
/dev/mmcblk0p4     100016  1760511  1660496   53135872   83  Linux
NOTE that the partition table is out of order, but for me everything works perfectly and i didn't want to touch the rootfs and /home partitions so i'd be safe and don't mess my installation up.

But only the first partition gets registered to a host if connected via usb so i changed /etc/usb-moded/usb-moded.ini to this:
Code:
# cat /etc/usb-moded/usb-moded.ini 
[mountpoints]
mount = /dev/mmcblk0p1,/dev/mmcblk0p4

#you can add more filesystems to the mount option, by making it a comma-seperated list.

[sync]
nofua = 1

[altmount]
mount = /home/user/MyDocs,/mnt

[cdrom]
path = /usr/share/aceso/aceso.iso
timeout = 1
Now i can see both partitions on my desktop if connected via usb. I hope this helps.

to use sfdisk to change the first partition use this command (after devel-su):
Code:
/sbin/sfdisk --no-reread /dev/mmcblk0 -N1
(-N1 makes sure you only edit the first partition)
and to modify the 4 partition use (obviously):
Code:
/sbin/sfdisk --no-reread /dev/mmcblk0 -N4
you have to specify start, size and type after you've executed the command. When editing the first partition start should be 16, size should be something you like (i think the program warns you if you choose a too big size) and the type should be c for W95 FAT32 (LBA).
for the fourth partition for start use the end of the first partition +1 and size again something you like (probably everything that is left) and type can be anything you like, i choose L which automatically uses a Linux type for the partition.

step by step execution should look something like this:
(i created this log after i did the setup on my device so the settings where already there, the sfdisk output should be different for you, partition 4 most likely won't exist yet).
Code:
# /sbin/sfdisk --no-reread /dev/mmcblk0 -N1

Disk /dev/mmcblk0: 1957120 cylinders, 4 heads, 16 sectors/track
Old situation:
Units = cylinders of 32768 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/mmcblk0p1         16  100015  100000    3200000    c  W95 FAT32 (LBA)
/dev/mmcblk0p2     1760512  1891583  131072    4194304   83  Linux
/dev/mmcblk0p3     1891584  1957119   65536    2097152   83  Linux
/dev/mmcblk0p4     100016  1760511  1660496   53135872   83  Linux
Input in the following format; absent fields get a default value.
<start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s>
Usually you only need to specify <start> and <size> (and perhaps <type>).

/dev/mmcblk0p1 :16 100000 c
/dev/mmcblk0p1         16  100015  100000    3200000    c  W95 FAT32 (LBA)
New situation:
Units = cylinders of 32768 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/mmcblk0p1         16  100015  100000    3200000    c  W95 FAT32 (LBA)
/dev/mmcblk0p2     1760512  1891583  131072    4194304   83  Linux
/dev/mmcblk0p3     1891584  1957119   65536    2097152   83  Linux
/dev/mmcblk0p4     100016  1760511  1660496   53135872   83  Linux
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Do you want to write this to disk? [ynq] y
Successfully wrote the new partition table

Re-reading the partition table ...
BLKRRPART: Device or resource busy
The command to re-read the partition table failed
Reboot your system now, before using mkfs

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
~ # /sbin/sfdisk --no-reread /dev/mmcblk0 -N4

Disk /dev/mmcblk0: 1957120 cylinders, 4 heads, 16 sectors/track
Old situation:
Units = cylinders of 32768 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/mmcblk0p1         16  100015  100000    3200000    c  W95 FAT32 (LBA)
/dev/mmcblk0p2     1760512  1891583  131072    4194304   83  Linux
/dev/mmcblk0p3     1891584  1957119   65536    2097152   83  Linux
/dev/mmcblk0p4     100016  1760511  1660496   53135872   83  Linux
Input in the following format; absent fields get a default value.
<start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s>
Usually you only need to specify <start> and <size> (and perhaps <type>).
/dev/mmcblk0p4 :100016 99999999 L
Warning: given size (32891135) exceeds max allowable size (1660496)
/dev/mmcblk0p4 :100016 1660496 L
/dev/mmcblk0p4     100016  1760511  1660496   53135872   83  Linux
New situation:
Units = cylinders of 32768 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/mmcblk0p1         16  100015  100000    3200000    c  W95 FAT32 (LBA)
/dev/mmcblk0p2     1760512  1891583  131072    4194304   83  Linux
/dev/mmcblk0p3     1891584  1957119   65536    2097152   83  Linux
/dev/mmcblk0p4     100016  1760511  1660496   53135872   83  Linux
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Do you want to write this to disk? [ynq] y
Successfully wrote the new partition table

Re-reading the partition table ...
BLKRRPART: Device or resource busy
The command to re-read the partition table failed
Reboot your system now, before using mkfs

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
Then edit /etc/usb-moded/usb-moded.ini according to your needs. Then reboot the device and hope for the best.

After rebooting you can format the partitions using the mkfs commands, like (after devel-su):
Code:
/sbin/mkfs.vfat /dev/mmcblk0p1
/sbin/mkfs.ext3 /dev/mmcblk0p4
if you want to have it mount your fourth partition if you boot or disconnect the device from usb you need to change your /etc/fstab, i used this:
Code:
# cat /etc/fstab 
rootfs / rootfs defaults,errors=remount-ro,noatime 0 0
/dev/mmcblk0p3 /home ext4 rw,noatime,errors=remount-ro,barrier=1 0 0
/dev/mmcblk0p1 /home/user/MyDocs vfat noauto,nodev,noexec,nosuid,noatime,nodiratime,utf8,uid=29999,shortname=mixed,dmask=000,fmask=0133,rodir 0 0
/dev/mmcblk0p4 /mnt ext4 rw,noatime,errors=remount-ro,barrier=1 0 0
ubi0:var /var ubifs noauto,no_chk_data_crc,bulk_read

Last edited by liar; 2013-12-02 at 15:24.
 

The Following 5 Users Say Thank You to liar For This Useful Post: