Mount ext4 formatted SD card - Android Q&A, Help & Troubleshooting

Requirements:
Rooted device
SD card formatted to ext4/3/2
Terminal app installed
Optional: A file explorer (I use ES file explorer)
Basic command line knowledge
Step 1: Run as root
Open the terminal app and execute this:
Code:
su
This is necessary for the next commands to be executed with root privilege.
Step 2: Identify SD card partition(s)
Execute:
Code:
blkid
or
Code:
cat /proc/partitions
This will spit out a bunch of partitions but we're looking for a device that reads something like "/dev/block/mmcblk1".
In my case there's two of those, because I have two partitions on my SD card. One reads "mmcblk1p1", which is ExFat and the other reads mmcblk1 and is ext2. We'll be mounting the second one, so my partition is /dev/block/mmcblk1p2. It isn't ext4 but the the process is the same.
Step 3: Create folder to mount to
We will need to create a folder to mount the partition to and I will go along with the "/storage/sdcard0" directory and choose "/storage/sdcard1". You can however choose any name you want.
So run this:
Code:
mkdir /storage/sdcard1
or replace sdcard1 with a different name if desired.
Step 4: Mounting
The command syntax for mounting is as follows:
Code:
mount -t ext4 partition path
My device is "/dev/block/mmcblk1p2" and my path is "/storage/sdcard1" so this is what I'll run:
Code:
mount -t ext4 /dev/block/mmcblk1p2 /storage/sdcard1
(I used ext4 with an ext2 partition but it works regardless.)
If there were no issues the command will run without an output.
Now you can test if it's mounted by going into the folder with
Code:
cd /storage/sdcard1
and making a folder:
Code:
mkdir test
If you list the files:
Code:
ls
you should see "test".
Step 5: Gaining read/write permission
Execute:
Code:
chmod -R 777 /storage/sdcard1
obviously with your own path and now you should be able to open the directory in a file manager and write into it.

Works, but no file managers recognise its mounted.

Spaceboy60 said:
Works, but no file managers recognise its mounted.
Click to expand...
Click to collapse
Check the folder you made with mkdir, it should be there.

Related

[EXPANDSD] Join your external SD with internal SD!

WARN: For developer only.
attachment is the EXPANDSD script.
Why use it?
So many applications use /sdcard for mass data storage(gameloft, navigation...),
but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.
How to use:
1.make expandsd.ownhere dirctory in external_sd root directory.
2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
3.run init_expandsd.sh
Theory:
use 'mount --bind' feature, bind external_sd's dir to internal_sd.
Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.
Hi mate,
Thks for your shares. I have a question. How run init_expandsd.sh?
I tried gscript and init.d, but doesn't seem to be working
woohoo a great dev has come. glad you got here mate! love your work on Desire section.
harrynghiem said:
Hi mate,
Thks for your shares. I have a question. How run init_expandsd.sh?
Click to expand...
Click to collapse
you can try to use terminal emu, just type su then navigate to folder where the script located, then type sh init_expandsd.sh then enter. this might do the trick to execute .sh
dexterdave said:
you can try to use terminal emu, just type su then navigate to folder where the script located, then type sh init_expandsd.sh then enter. this might do the trick to execute .sh
Click to expand...
Click to collapse
Does it work for you?
It's a great idea thanks a lot for your work. I was wondering why ln was not working.
But too bad it does not work for me, i get the following error :
[1] Segmentation fault
Do you have any idea why ?
Thanks again
problems when connecting phone to pc
hi,
tried the "mount --bind" in order to try your script.
works fine. the directory contents is shared between the 2 path's,
but i have a problem when i connect the phone to a pc.
when i try to disconnect, the sdcard and external_sd are not
available anymore until i reboot the phone
note: the commands that i have executed are:
Code:
mkdir /mnt/sdcard/external_sd/foo
echo "test" > /mnt/sdcard/external_sd/foo/test
mkdir /mnt/sdcard/foo
mount --bind /mnt/sdcard/external_sd/foo /mnt/sdcard/foo
Can this script be placed in init.d folder for autorun at boot?
Edit: sorry, already answered above: no, it cannot.
Sent from my GT-P1000 using Tapatalk
Seems abandoned by @ownhere
Sent from my GT-I9100
Idan73 said:
Seems abandoned by @ownhere
Sent from my GT-I9100
Click to expand...
Click to collapse
too bad, it could be very useful..
TheFirstBen said:
It's a great idea thanks a lot for your work. I was wondering why ln was not working.
But too bad it does not work for me, i get the following error :
[1] Segmentation fault
Do you have any idea why ?
Thanks again
Click to expand...
Click to collapse
got the same problem please help
How to use?
ownhere said:
WARN: For developer only.
attachment is the EXPANDSD script.
Why use it?
So many applications use /sdcard for mass data storage(gameloft, navigation...),
but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.
How to use:
1.make expandsd.ownhere dirctory in external_sd root directory.
2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
3.run init_expandsd.sh
Theory:
use 'mount --bind' feature, bind external_sd's dir to internal_sd.
Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.
Click to expand...
Click to collapse
thanks,
this is genius
I'm not using your script (have myself some ux & scripting skills) but did not know about the -bind option on android
Ridiculously simple and efficient
Did it my own way and it works great
Thanks a lot for this
dawabz94 said:
thanks,
this is genius
I'm not using your script (have myself some ux & scripting skills) but did not know about the -bind option on android
Ridiculously simple and efficient
Did it my own way and it works great
Thanks a lot for this
Click to expand...
Click to collapse
Then why not share with us please !
Let us know how you did
Yes I'd like to know another method also.!
Sent from my GT-I9100 using XDA
Chairmansaab said:
Then why not share with us please !
Let us know how you did
Click to expand...
Click to collapse
Hi,
it's very easy indeed, once you got the point.
I do most of my stuff using an "adb shell" session so I'll post here my steps to get it working.
Also I like simple implementation so my script is the strict minimum needed to mount necessary folders
I assume you have a rooted device with working busybox and a kernel that supports /etc/init.d/
I suggest you do the test on a dummy folder before applying on a real folder.
So start by creating a folder called /sdcard/dummy
Do it the way you want , I do it with an "adb shell" session
Code:
cd /sdcard
mkdir dummy
Then copy some files in it (photos for examples)
Code:
cd /sdcard
cd DCIM
cd Camera
cp `ls -1 |tail -5` /sdcard/dummy
From now on, we consider we want to move transparently /sdcard/dummy to the external SD
1. move the folder to the external sd
CAUTION : I'm running a CM9 rom => my external sd is mounted on /mnt/emmc
Standard samsung sdcard mount is /sdcard/external_sd
The path might be different according to your brand and rom
Moving the folder code
Code:
cd /sdcard
mv dummy /mnt/emmc/
2. Create the mount point in the indernal SD
Code:
cd /sdcard
mkdir dummy
3.a Check the mount is successful by manually doing it
Code:
mount --bind /mnt/emmc/dummy /sdcard/dummy
3.b Check you see exactly the same thing on both folders
Both commands should return exactly the same output
Code:
ls -l /sdcard/dummy
Code:
ls -l /mnt/emmc/dummy
If everything is fine, then you're good to go
4. Automate mount at boot time
Create a script in /etc/init.d to automate the mount at boot time
I personally use "vi" but most people prefer graphical UIs, I can't recommend any here, do it your own way
So basically you would go root,remount /system in read/write mode and create the file
Code:
su
mount -o remount,rw /dev/block/mmcblk0p9 /system
cd /etc/init.d
vi 90binds
Insert following lines, save and exit
Note that the "sleep 60" is to let the system boot up before mounting partitions (thanks to the initial script shared here)
Code:
#!/system/bin/sh
sleep 60
mount --bind /mnt/emmc/dummy /sdcard/dummy
Change owner and permissions, flush disk cache and remount /system in read only
Code:
su
mount -o remount,rw /dev/block/mmcblk0p9 /system
cd /etc/init.d
chown root:shell
chmod 6755 90binds
sync
mount -o remount,ro /dev/block/mmcblk0p9 /system
To check, run
Code:
su
cd /etc/init.d
ls -l 90binds
The output should look like this :
Code:
-rwsr-sr-x 1 root shell [I]0 MMM D HH:MM[/I] 90binds
5. Now you can reboot and check - after reboot - that the mount is done
Both commands should return exactly the same output (always ran in an "adb shell" session)
Code:
ls -l /sdcard/dummy
Code:
ls -l /mnt/emmc/dummy
6. Now you're good to move other folders
Basically, you move the folder to external SD
Create the mount point on the internal SD
Append the mount command in the 90binds script
And that's it
Hope this helps
---------- Post added at 11:09 AM ---------- Previous post was at 11:04 AM ----------
benc88 said:
Yes I'd like to know another method also.!
Sent from my GT-I9100 using XDA
Click to expand...
Click to collapse
Just posted
Take time to read and understand the idea

[Q] Configure a permanent mount -o bind in init.d

I want to set the cache folder of Google Music to the external sdcard using mount -o bind command
I created a file (without extension) that contains the following
Code:
#!/system/bin/sh
mount -o bind /emmc/Android/data/com.google.android.music/ /sdcard/Android/data/com.google.android.music/
I made sure the target folder exists and saved the file to /system/etc/init.d, but in fact it looks like the script isn't executed.
P.S. the script file's properties are: -rwxr-xr-x, Owner: 00000 root, Group: 02000 shell.
Storing permanent data
How?

How to auto mount cleanly a partiton on boot

I have a second partition on my SDCARD at /dev/block/mmcblk1p2, all I want to do is ensure that it is always mounted as /storage/sdcard0/mount seems simple I can do it in 5 second on Linux, on Android, it seems impossible I can try to add a hack, but that is lost every-time I update the ROM. There has to be some simple way to do it, that I'm missing. The best I have is to load up a terminal emulated su to root and run: mount -t ext4 /dev/block/mmcblk1p2 /storage/sdcard0/mount
Now in theory, the following would work but for 2 things:
mkdir /storage/sdcard0/mount
su - root -c 'mount -t ext4 /dev/block/mmcblk1p2 /storage/sdcard0/mount'
But for the fact the Android's su does not understand -c so that is out. as well as the fact that non-root users (u0_a216 in my case) can not access /storage/sdcard0.
All I want is a simple way to ensure that this is always mounted where I want it when I need it, yet this simple task is nearly impossible it appears on Android, so why is that?
The issue here is that the fat32 partition does not support large files so I need a separate partition that does such as ext4, in reality if the external sdcard could just be ext4 there would be no issues, and it would be faster, but that is Android for you.
Any suggestions?
Thanks,
ERIC
Insert mount script to init.d folder...
via XDA Premium
Ok, I have this mostly working with juicessh and tasker now for now
I have 2 shell scripts:
mountDev.sh:
Code:
mkdir /storage/sdcard2
chmod 777 /storage/sdcard2
mount -t ext4 /dev/block/mmcblk1p2 /storage/sdcard2
umountDev.sh
Code:
umount /storage/sdcard2
rmdir /storage/sdcard2
In Tasker I have 2 tasks defined:
I'm using the JuiceSSH plugin to open a terminal to localhost I then execute:
To Mount:
Code:
su -l --shell=/system/bin/sh --command='cd /storage/sdcard0 ; sh ./mountDSev.sh ; exit' ; exit
To umount:
Code:
su -l --shell=/system/bin/sh --command='cd /storage/sdcard0 ; sh ./mountDSev.sh ; exit' ; exit
I then created 2 icons, 1 for each operation on the home screen. I also created a Device Boot event to automatically execute and mount the task.
This works, mostly, however even though it is root, sometimes I get errors such as /storage/ is readonly, which makes no sense since it could create the directory at boot, but can not remove the directory later on, since it is readonly. Its a minor thing currently, but annoying.
The benefit of this is it is easy to transfer between ROM images and devices without worrying about it being wiped out every-time I update. In theory it also works without init.d support being enabled. Down side is it you need Tasker and the JuiceSSH plug-in so it costs money.
Hope this helps others.
ERIC

[GUIDE] EXT4 microSD card on Dell Venue 8 7840

The tablet supports up to 512gb microSD cards but only the FAT32 filesystem by default - not much use if you're dumping large files (>4gb) onto them.
Notes:
I've only tried this with a pre-formatted ext4 card. The stock Dell rom does not ship with mkfs.ext4 binary so I highly doubt you'll be able to format the sdcard as ext4 on the device itself. I also have no idea what happens if you subsequently try to use a FAT32 formatted microSD card. I also haven't tested hotplugging - again, I assume it would work but it's untested.
I stress, be very careful when performing these steps. The bootloaders on these devices currently cannot be unlocked and we only have a tethered CWM at the moment.
I'm not responsible if you brick your device trying to follow the steps.
Requirements:
Root access
Busybox
Terminal emulator/adb shell/ssh access
Pre-formatted ext4 sdcard
Steps:
Download https://dl.dropboxusercontent.com/u/134520/.nemaz_ma/vold.ext4support.tar.gz on the tablet (replace hxxp with http, I can't post links)(found here: hxxp://forum.xda-developers.com/showthread.php?t=2580142)
Open terminal emulator
Code:
cd /sdcard/Download
tar -xvf ./vold.ext4support.tar.gz
su
mount -o remount,rw /system /system
mv /system/bin/vold /system/bin/vold.bak
cp ./vold /system/bin/vold
chmod 0755 /system/bin/vold
Reboot the device
If you're lucky and open Settings->Storage, you should now see the sdcard showing up.
If not:
Open terminal emulator
Code:
cd /etc
vi vold.fstab
Most lines in the vold.fstab file are comments, there should be two lines at the bottom:
Code:
dev_mount sdcard_ext /storage/sdcard_ext auto /devices/pci0000:00/0000:00:01.2/mmc_host/mmc1 /devices/pci0000:00/0000:00:11.0/dwc3-device.1/gadget/lun0
dev_mount usbcard /storage/usbcard auto */block/sd
you need to change
Code:
dev_mount sdcard_ext /storage/sdcard_ext auto /devices/pci0000:00/0000:00:01.2/mmc_host/mmc1 /devices/pci0000:00/0000:00:11.0/dwc3-device.1/gadget/lun0
to
Code:
dev_mount sdcard_ext /storage/sdcard1 auto /devices/pci0000:00/0000:00:01.2/mmc_host/mmc1 /devices/pci0000:00/0000:00:11.0/dwc3-device.1/gadget/lun0
(you're changing the third parameter from /storage/sdcard_ext to /storage/sdcard1)
Give the device a reboot and it should now work.
To undo the patch:
Open terminal emulator
Code:
su
mount -o remount,rw /system /system/
mv /system/bin/vold /system/bin/vold_ext4
mv /system/bin/vold.bak /system/bin/vold
Reboot
Good luck.
@anggusss - Thanks for that! Very cool. I just got a 64GB card, but I'd like a larger card to hold entire ROM sets.
Incidentally, for anyone that wants, you can get a Moga Power Pro at Best Buy for $39.99 (MSRP $ 79.99). Just search for the controller via Target's website, and show them the lower price. They will match it.
anggusss said:
The tablet supports up to 512gb microSD cards but only the FAT32 filesystem by default - not much use if you're dumping large files (>4gb) onto them.
Notes:
I've only tried this with a pre-formatted ext4 card. The stock Dell rom does not ship with mkfs.ext4 binary so I highly doubt you'll be able to format the sdcard as ext4 on the device itself. I also have no idea what happens if you subsequently try to use a FAT32 formatted microSD card. I also haven't tested hotplugging - again, I assume it would work but it's untested.
I stress, be very careful when performing these steps. The bootloaders on these devices currently cannot be unlocked and we only have a tethered CWM at the moment.
I'm not responsible if you brick your device trying to follow the steps.
Requirements:
Root access
Busybox
Terminal emulator/adb shell/ssh access
Pre-formatted ext4 sdcard
Steps:
Download hxxps://dl.dropboxusercontent.com/u/134520/.nemaz_ma/vold.ext4support.tar.gz on the tablet (replace hxxp with http, I can't post links)(found here: hxxp://forum.xda-developers.com/showthread.php?t=2580142)
Open terminal emulator
Code:
cd /sdcard/Download
tar -xvf ./vold.ext4support.tar.gz
su
mount -o remount,rw /system /system
mv /system/bin/vold /system/bin/vold.bak
cp ./vold /system/bin/vold
chmod 0755 /system/bin/vold
Reboot the device
If you're lucky and open Settings->Storage, you should now see the sdcard showing up.
If not:
Open terminal emulator
Code:
cd /etc
vi vold.fstab
Most lines in the vold.fstab file are comments, there should be two lines at the bottom:
Code:
dev_mount sdcard_ext /storage/sdcard_ext auto /devices/pci0000:00/0000:00:01.2/mmc_host/mmc1 /devices/pci0000:00/0000:00:11.0/dwc3-device.1/gadget/lun0
dev_mount usbcard /storage/usbcard auto */block/sd
you need to change
Code:
dev_mount sdcard_ext /storage/sdcard_ext auto /devices/pci0000:00/0000:00:01.2/mmc_host/mmc1 /devices/pci0000:00/0000:00:11.0/dwc3-device.1/gadget/lun0
to
Code:
dev_mount sdcard_ext /storage/sdcard1 auto /devices/pci0000:00/0000:00:01.2/mmc_host/mmc1 /devices/pci0000:00/0000:00:11.0/dwc3-device.1/gadget/lun0
(you're changing the third parameter from /storage/sdcard_ext to /storage/sdcard1)
Give the device a reboot and it should now work.
To undo the patch:
Open terminal emulator
Code:
su
mount -o remount,rw /system /system/
mv /system/bin/vold /system/bin/vold_ext4
mv /system/bin/vold.bak /system/bin/vold
Reboot
Good luck.
Click to expand...
Click to collapse
I have to say having the removable storage was a nice perk. It wasn't 100% confirmed when I ordered my 7840. I do have a suspicion that on the LTE version that is supposedly due out later this year that the removable storage will become that sim tray. Either way I've got a 64gig card that contains a lot of movies for on the go watching. I forgot how nice it is (coming from a Nexus 10) not to have to stream everything. I also recently have purchased a WD MyCloud 6TB NAS that I am finding all sorts of apps for and am really loving that connectivity with my 7840.
I've just installed this script on 7840 with Android 5.1 (last version) and the device does not boot any more. It hangs on "intel inside" logo.
I've tried to do factory reset using recovery mode - it does not help
Is there any possibility to replace the modified "vold" file with the backup "vold.bak" using default recovery or adb sideload?

[GUIDE] Mounting the fat32 partition on MacOS

So it's known that the fat32 partition of the android SD doesn't mount automatically on MacOS, presumably because of the funky partition table. I just managed to mount it manually from terminal, it has some quirks but it works.
First, find the partition:
Code:
diskutil list
shows you the disks on your system, the android one has disk<n> as FDisk_partition_scheme, then two partitions as type 0xEE. The first of those, the 2.1gb partition, is the fat32 one, so make a note of its identifier (disk<n>s<m>). If you've made your own partition layout you should know which is the right one.
Then, make a mount point (empty directory) for it.
I did:
Code:
sudo mkdir /Volumes/msdos
("msdos" is the name of the partition type, as we'll see in a sec)
to put it where disks are usually mounted, but you can make a directory anywhere you want, if it's somewhere in your user directory you don't need sudo - ie:
Code:
mkdir <path>/msdos
or
Code:
mkdir msdos
to put it in the current directory. You can name it whatever you want, it doesn't have to be "msdos".
(You only need to run one of these mount commands, not all 3)
Now to mount it:
Code:
sudo mount -t msdos /dev/disk<n>s<m> <path>
(replace <n> and <m> with the numbers you found in step 1 - don't type the < >)
(replace <path> with the path you used for mkdir - in my case, /Volumes/msdos)
This one does need sudo to have permission to access the disk device. If you don't get any error messages, then your disk should be mounted. Annoyingly, it doesn't show up in the normal way as a disk in Finder, if anyone knows how to change this please let me know. For now, next step...
Point Finder to the disk:
In Finder click the Go menu, and choose Go to folder...
Type or paste the full path to your mount point (in my case, /Volumes/msdos).
<'90s hacker voice> Youre in.
Unmounting:
Make sure your finder window isn't pointing to anything on the disk, and you don't have a terminal using any of its directories, and no other apps have files open on the disk. Then do:
Code:
sudo umount <path>
so for my example that's:
Code:
sudo umount /Volumes/msdos
If you get no errors then it's unmounted, and you're safe to remove the SD card.
If you want, you can delete the directory you were using as a mount point (or you can just leave it for next time). If it's in /Volumes, do eg:
Code:
sudo rmdir /Volumes/msdos
otherwise just do:
Code:
rmdir <path>

Categories

Resources