Mounting the second partition of SDCARD as internal memory

PhantomPhreek

Member
Jan 7, 2010
35
2
0
Alright so here's the deal, my internal SDCARD is corrupted and the /data partition is unusable.

My device is i9003 and it's running on MIUI at the moment. By default MIUI didn't detect my external SD or my internal SD but after editing "vold.fstab" I was able to mount the first partition of my external SDCARD as external memory and everything was good, I could finally use the camera and pretty much do everything else.

But I was still unable to mount the second partition of my external SDCARD as my internal memory which meant none of my messages could be saved and the phone would pretty much go back to factory settings after a reboot, this apparently is because the /data partition (present on the internal memory) stores all the user data such as the time, the theme I'm using, etc and not having a /data partition meant none of these settings were really saved.

Having no internal memory also means I cannot install any apps such as Link2SD.

Moving on, after many hours of googling I found out that it might not be possible to mount the internal memory using "vold.fstab" and the only way to do it could be by mounting the memory manually during init.

So here's what I want again, I want to use the second partition of my external SDCARD as internal memory, this is likely to solve all my problems and make my phone usable again.

Thanks for all the help, appreciate it.
 
Last edited:

kuisma

Senior Member
Jun 30, 2009
361
214
0
Sweden
whiteboard.ping.se
You need to edit /init.rc (or init.vendor.rc). To make the edits here stay, you'll need to create a new boot.img to flash your device with.

Have a look at an extract of mine init.<vendor>.rc:

Code:
on fs
# mount mtd partitions
    # Mount /system rw first to give the filesystem a chance to save a checkpoint
    #mount yaffs2 [email protected] /system
    #mount yaffs2 [email protected] /system ro remount
    # Use below two lines instead of above to run /system from SDcard instead of internal flash
    mount ext3 /dev/block/mmcblk0p3 /system
    mount ext3 /dev/block/mmcblk0p3 /system ro remount
    #mount yaffs2 [email protected] /data nosuid nodev
    mount ext3 /dev/block/mmcblk0p4 /data nosuid nodev
    mount yaffs2 [email protected] /cache nosuid nodev
Compare the lines I've commented out with the others. Here both /data and /system resides on the SDcard, you only need to care about /data. Also remember your device nodes may not be named "mmcblk0p3" etc.

But you'll need to make those changes in the initramfs in your flashed boot.img to make them stay.
 

PhantomPhreek

Member
Jan 7, 2010
35
2
0
You need to edit /init.rc (or init.vendor.rc). To make the edits here stay, you'll need to create a new boot.img to flash your device with.

Have a look at an extract of mine init.<vendor>.rc:

Code:
on fs
# mount mtd partitions
    # Mount /system rw first to give the filesystem a chance to save a checkpoint
    #mount yaffs2 [email protected] /system
    #mount yaffs2 [email protected] /system ro remount
    # Use below two lines instead of above to run /system from SDcard instead of internal flash
    mount ext3 /dev/block/mmcblk0p3 /system
    mount ext3 /dev/block/mmcblk0p3 /system ro remount
    #mount yaffs2 [email protected] /data nosuid nodev
    mount ext3 /dev/block/mmcblk0p4 /data nosuid nodev
    mount yaffs2 [email protected] /cache nosuid nodev
Compare the lines I've commented out with the others. Here both /data and /system resides on the SDcard, you only need to care about /data. Also remember your device nodes may not be named "mmcblk0p3" etc.

But you'll need to make those changes in the initramfs in your flashed boot.img to make them stay.
Thanks for the reply man, mind telling me the how I can go about doing this?, I've got the ROM I flashed via CWM here with me, I could send it over to you if that would make things easier for you.
EDIT: would pulling init.rc via ADB, making the changes and pushing it back do the trick? or do I have to go for the boot.img? In case it's the latter, I'm going to need help doing it.
 
Last edited:

kuisma

Senior Member
Jun 30, 2009
361
214
0
Sweden
whiteboard.ping.se

PhantomPhreek

Member
Jan 7, 2010
35
2
0

kuisma

Senior Member
Jun 30, 2009
361
214
0
Sweden
whiteboard.ping.se
I'm not sure I've got FASTBOOT but I've definitely got ADB and I've also got the ROM. Would pulling init.rc via ADB, making the changes and pushing it back do the trick? or do I have to go for the boot.img?.
No. You need to reboot the phone for the init.rc script to execute, and once you reboot the phone, the root file system is overwritten by the flashed image ... Catch 22.

You'll NEED to create a new boot.img with a new initramfs containing your changes.
 

PhantomPhreek

Member
Jan 7, 2010
35
2
0
No. You need to reboot the phone for the init.rc script to execute, and once you reboot the phone, the root file system is overwritten by the flashed image ... Catch 22.

You'll NEED to create a new boot.img with a new initramfs containing your changes.
Shucks, this explains why it didn't work. Alright, so I extract boot.img from the rom, follow the tutorial.What is it that I have to edit again? "/init.rc" or "init.<vendor>.rc"?.

Thanks for the help man, appreciate it.

EDIT: Looks like the tutorial is meant for Linux, I'm currently on Windows. I might be asking for a lot here but is there any chance I could get you to do it for me?
 
Last edited:

kuisma

Senior Member
Jun 30, 2009
361
214
0
Sweden
whiteboard.ping.se
Shucks, this explains why it didn't work. Alright, so I extract boot.img from the rom, follow the tutorial.What is it that I have to edit again? "/init.rc" or "init.<vendor>.rc"?.

Thanks for the help man, appreciate it.
Of course, MIUI may have some boot hooks you could use to re-mount /data after boot. I know nothing about that ROM. Also keep in mind that each time you update the ROM, you have to remake this edit.

Also, no idea what MIUI calls its init.rc, you'll just have to see for yourself. If you've got the mount commands in init.rc, fine. Else look elsewhere.

A good first step would to make sure you really are able to flash a new boot.img. Download fastboot and verify your device understands it. Else you have to use some proprietary flash program, and I'm not familiar with Samsungs bootloaders at all. Ask in the Samsung forum if so.
 

PhantomPhreek

Member
Jan 7, 2010
35
2
0
Of course, MIUI may have some boot hooks you could use to re-mount /data after boot. I know nothing about that ROM. Also keep in mind that each time you update the ROM, you have to remake this edit.

Also, no idea what MIUI calls its init.rc, you'll just have to see for yourself. If you've got the mount commands in init.rc, fine. Else look elsewhere.

A good first step would to make sure you really are able to flash a new boot.img. Download fastboot and verify your device understands it. Else you have to use some proprietary flash program, and I'm not familiar with Samsungs bootloaders at all. Ask in the Samsung forum if so.
Looks like the tutorial is meant for Linux, I'm currently on Windows. I might be asking for a lot here but is there any chance I could get you to do it for me?. ADB and I do see the file init.rc and I also see the mount commands as well. I used adb shell to run the command you sent over with a few edits for second partition and it does mount but as you said, it all goes away after reboot.
 

kuisma

Senior Member
Jun 30, 2009
361
214
0
Sweden
whiteboard.ping.se
Looks like the tutorial is meant for Linux, I'm currently on Windows. I might be asking for a lot here but is there any chance I could get you to do it for me?. ADB and I do see the file init.rc and I also see the mount commands as well. I used adb shell to run the command you sent over with a few edits for second partition and it does mount but as you said, it all goes away after reboot.
Hmm... are you even able to create a second ext3 partition on the SDcard using Windos..?
 

kuisma

Senior Member
Jun 30, 2009
361
214
0
Sweden
whiteboard.ping.se
Alright so here's the deal, my internal SDCARD is corrupted and the /data partition is unusable.
The ROM you are using requires an ext4 partition as partition #3 of the SDcard. This is mounted as /data. Repartition your SDcard #1 as FAT, #2 whatever, and #3 as ext4, and everything will work as intended. :victory:

I guess you've missed this in the ROM documentation ... ;)
 

PhantomPhreek

Member
Jan 7, 2010
35
2
0
The ROM you are using requires an ext4 partition as partition #3 of the SDcard. This is mounted as /data. Repartition your SDcard #1 as FAT, #2 whatever, and #3 as ext4, and everything will work as intended. :victory:

I guess you've missed this in the ROM documentation ... ;)
Wah~ really?, I'll try that and get back here with the results. Thanks a lot!.

EDIT: Is it FAT or FAT32?
 
Last edited:

PhantomPhreek

Member
Jan 7, 2010
35
2
0
Tried but didn't work out. I made three partitions, all primary - #1 FAT32, #2 FAT32, #3 EXT4. Plugged the SDCARD in and the external memory was detected as usual, but not the internal memory.
I tried changing the time, it was reset back after reboot.
After that I left the SDCARD as is and flashed the ROM again and now, neither the internal nor the external memory are detected. This is probably because the "vold.fstab" which was edited by me, was overwritten on re flashing.
I'm at a dead end, any ideas?
 

kuisma

Senior Member
Jun 30, 2009
361
214
0
Sweden
whiteboard.ping.se
Tried but didn't work out. I made three partitions, all primary - #1 FAT32, #2 FAT32, #3 EXT4. Plugged the SDCARD in and the external memory was detected as usual, but not the internal memory.
I tried changing the time, it was reset back after reboot.
After that I left the SDCARD as is and flashed the ROM again and now, neither the internal nor the external memory are detected. This is probably because the "vold.fstab" which was edited by me, was overwritten on re flashing.
I'm at a dead end, any ideas?
Attach an output of "df", "mount", the file "/init.latona.rc" and "/etc/vold.fstab" here, and I'll have a look at it. Hmm... include the output of "dmesg" as well, to be on the safe side.
 

PhantomPhreek

Member
Jan 7, 2010
35
2
0
Attach an output of "df", "mount", the file "/init.latona.rc" and "/etc/vold.fstab" here, and I'll have a look at it. Hmm... include the output of "dmesg" as well, to be on the safe side.
What bugs me is the fact that the external SD is not detected, from what little knowledge I have, external SD is unrelated to the internal SD which I currently have problems with, meaning it should be detected without a problem.

Also I have to add, CWM doesn't detect my external SD right away, when I go to recovery and go over to "Choose zip from sdcard" it says "E:Can't mount /sdcard/". The solution I've found coincidentally is to go to "mounts & storage", mount "/emmc", pull the SDCARD out plug it in again and then "mount /sdcard" this works perfectly and I'm able to flash roms from the sdcard.
 
Last edited:

kuisma

Senior Member
Jun 30, 2009
361
214
0
Sweden
whiteboard.ping.se
One problem at a time, please. Attach the files I requsted, so we can determine why /data failes to mount. Looking at your ROM:

Code:
$ grep " /data$" init.latona.rc 
    mount ext4 /dev/block/mmcblk0p3 /data
I want to know why this fails, and I guess the answer is in the dmesg output. And please before I'll get another whiskey. ;)
 

PhantomPhreek

Member
Jan 7, 2010
35
2
0
One problem at a time, please. Attach the files I requsted, so we can determine why /data failes to mount. Looking at your ROM:

Code:
$ grep " /data$" init.latona.rc 
    mount ext4 /dev/block/mmcblk0p3 /data
I want to know why this fails, and I guess the answer is in the dmesg output. And please before I'll get another whiskey. ;)
I can't seem to find "/init.latona.rc" everything else you requested I've mailed them over already :)

EDIT: the dmesg output is AFTER I mounted "/sdcard" manually as explained in my previous post.
 
Last edited:

kuisma

Senior Member
Jun 30, 2009
361
214
0
Sweden
whiteboard.ping.se
I can't seem to find "/init.latona.rc" everything else you requested I've mailed them over already :)

EDIT: the dmesg output is AFTER I mounted "/sdcard" manually as explained in my previous post.
The files you mailed me does not correspond to the ROM you refereed.

The /etc/fstab show that /data is mounted as an rfs file system, not ext4. So either format partition #3 on the sdcard as rfs (Samsung proprietary), or edit /etc/fstab and change "rfs" to "ext4". I'd prefer the later, assuming your kernel supports ext4. Else use ext3.

Code:
/dev/block/mmcblk0p3 /data rfs rw
But you can't have flashed the ROM you told me you did. It excepted an ext4 file system ...