When and how is /data mounted? - General Questions and Answers

I am exploring a bit on my Android device and I can't seem to figure out when `/data` is mounted.
My first guess what it'd be in `/init.rc`, and while that file creates the /data directory, it doesn't seem to actually mount it. I've also taken a look in `/system/etc/init.d`, but going from the files there, `/data` is already mounted at that point.
When is `/data` mounted, and where can I find the related script?

Related

[Q] SD Card will not mount after ext4 part.

Attempting to partition sd card with ext4 -a process I completed multiple times successfully on a Nexus One, the process appeared to complete but now the phone will not mount the sd card. I've tried a wipe/reset, to no avail. I can still access and partition the sd card through adb, but the phone cannot mount it to format/partition, restore from recovery, partition sd-card from within ClockWork Recovery, nothing. I've re-partitioned the sd card through adb, which indicated a successful completion, but the phone still refuses to mount the sd card. If this weren't a Nexus S with it's cursed internal sd-card I would simply swap out the sd card with another or format it externally like all the google topics I pull up on the subject suggest.
Is this fixable or has the fused sd-card scenario become a liability?
Common Error messages:
Can't mount /sdcard
Can't mount /sdcard/.android_secure
Phone: Nexus S (US, T-Mobile, manufactured Dec. '10)
Recovery Img: ClockworkMod Recovery 3.0.2.4
Rom: CM 7.0.3 (now wiped, cannot put back on since sd card won't mount)
fstab:
/dev/block/mtdblock4 /cache yaffs2 rw
/dev/block/platform/s3c-sdhci.0/by-name/userdata /data ext4 rw
/dev/block/platform/s3c-sdhci.0/by-name/system /system ext4 rw
/dev/block/platform/s3c-sdhci.0/by-name/media /sdcard vfat rw
Can mount everything except the last one, /sdcard.
I've tried all the recommended procedures garnered from the first 10 or so pages in google, xda, cyanogem forum, etc:
Restore from nandroid: Not possible, can't mount the SD,
Wipe/Reset: can't wipe /media as sd card won't mount,
partition sd card from within Clockwork: indicates success but does nothing,
format from within clockwork: unable to mount,
repartition using adb: works, parted can see them, I can move files to from, but the phone will not mount,
clearing fstab: no effect,
Fastboot works, but I don't have the proper images. ADB works, as do the installed utilities. Have not tried ODIN as again, I don't have the proper images. Should I attempt to compile my own images from source?
Update: SOLVED, Microsoft Windows. To whom it may concern: I was able to mount the /dev/block/platform/s3c-sdhci.0/by-name/media from two different laptops running OSX and Fedora/Ubuntu then successfully been able to partition them with fat32 as the ClockworkMod (and maybe Cyanogen?) expect with 0 progress. Then I pulled out an old Windows machine, installed the JDK/ADK's +tools and performed the same procedure and that time it worked. I'm uncertain as to what particular quality a 'genuine' Windows formatting provides, but either this phone or the particular software combination I'm running require it. I was able to mount & re-partition the /sdcard in Clockwork, then manually remove rebuild them and upgrade to ext4 using tune2fs as usual. In the interim for work and such, I had to find a surrogate (for the SIM) and could only find and old k750i (which still had a full charge and worked flawlessly all day, btw). Wow phones used to be small.
I think I was missing something about the way ClockworkMod handles fstab, because everytime I would modify it specifically to the specs I passed to parted while creating the partitions with mkpartfs, it would either ignore or overwrite them. So be careful messing with the sd-card, the S's aren't like the One's in the sense that if you screw it (the sd-card) up or it goes bad you can't just take it out and format it in another machine/phone, you have to appeal to ClockworkMod. ODIN $ucks by the way, I found fastboot to be much more effective.
If you format the sd partition ext4, then you should change the fstab too.
from
Code:
/dev/block/platform/s3c-sdhci.0/by-name/media /sdcard vfat rw
to from
Code:
/dev/block/platform/s3c-sdhci.0/by-name/media /sdcard ext4 rw
or from
Code:
/dev/block/platform/s3c-sdhci.0/by-name/media /sdcard auto rw
The 2nd last entry there is the file system type.
Likely, this would have solved your problem.
Of course, I don't know, whether the recovery has the vfat type in fstab. You might have to change it there too. On my linux box auto works very well in fstab.
Of course, if you partition your sd partition ext4, you won't be able to use it as usb memory from windows. (At least I am pretty sure you can't, haven't tried)
Well of course I couldn't let it die, I went back and started tinkering again now that I have a way back. I can't change the fstab it seems, whatever I change it to gets over written everytime either Clockwork or the Rom starts. It's weird, I know I'm missing something and I don't know much about CWMod. (had Amon_Ra on the N1, which had the nifty fsupgrade script)
The 2nd last entry there is the file system type.
Likely, this would have solved your problem.
Click to expand...
Click to collapse
I'm quite familiar with unix style fs and fstab, it's the stubbornness I'm not used to. I'm also spoiled by vi and nano. CW has some nice scripts built in as well though.

Smartphone Architecture compared to PC

I have a few questions related to smartphones. Searched and couldn't find anything like I was looking for.
I am vary familiar with PC's and would like to compare in my mind where things reside on a smartphone.
On a smartphone, where does the operating system reside? Is it in the ROM(I know is Read-only-memory)? Or is the ROM similar to the BIOS on a PC and contains the basic instructions to interact with the between software and hardware?
Just having a little problem comparing what is where.
i think its in ROM memory, but there is additonal memory for system/internal apps too.
In my XPlay I have 512mb+400mb.
There isn't anyth like bios but u can flash recovery
From what I know, everything is stored in NAND flash. There is a boot partition which contains the kernel, and a system partition which contains the OS (firmware) itself. Those essentially double as ROM. Technically it's not read-only memory but its contents won't change unless you root your phone and change them yourself.
Also, I don't think an embedded system such as a smartphone would benefit much from having a full-blown BIOS. Hardware initialization, I believe, is done during the boot sequence, not prior to it. Look up "Board support package".
If someone knows more about this subject, feel free to correct me and provide additional information.
I'm quite interested in embedded systems myself, but only have had the opportunity to work with simple microcontrollers.
So basically everything inside is more like a solid state hard drive? Just partitioned for different tasks? I figured the rom was not really a rom. Usually you have to build an interface and cut traces on the board in order to flash a rom.
Are we able to browse the rom? Like with root explorer? Or is that partition "hidden"?
Also, what are the caches for. I am familiar with caches like in ie. But the davlik seems to be persistent. Thanks for the answers so far guys.
Usually when you load a new os, the cache is usually wiped. But with phones, a step is to wipe the caches. Confusing when trying to grasp with the knowledge I have of older electronics. Lol I just called pc's old.
I wish there was some guide already making the comparison but Google can't find it!
Yes, you can browse those partitions in Root Explorer. It will allow you to mount even the /system partition r/w so you can modify the contents.
As for the caches, I'm not sure what exactly gets stored on the /cache partition, but the reason you have to wipe/format it when you flash a new ROM, is because it's separate from the /system partition. That's probably what you meant by "persistent".
It's actually convenient when you think about it. If you want to flash an update of the ROM you are currently using, you probably don't want the cache to be wiped as well. On the other hand, sometimes you may want to wipe just the cache. Same goes for the /data partition, when you are doing a factory reset, for example.
I would also assume that since /system partition normally isn't written to, and /cache and /data are, keeping them separate helps in case the filesystem gets corrupted.
Now you are confusing me.
/system is a folder. Not a partition. It may be in a folder but it is not a partition afaik. There is a root partition which is basically everything you see when you open file explorer that includes the system folder, then any other partitions are mounted under /mnt. Those include /asec /obb /sdcard and /secure. (using what I see in my kf for this example)
So when we flash the "rom" we are really only flashing one partition of a rom that has several partitions. That would be the basic partition containing the system files? We are not flashing the entire rom. Does that sound correct?
In Linux partitions are mounted under directories. So /cache, /data and /system are really just mount points for those partitions. It's understandable that this would confuse you if you haven't had experience with Linux. Windows handles partitions somewhat differently.
When you flash a ROM, you are actually flashing only the system partition. Kernel is flashed to the boot partition, and others (cache, data, sdcard, etc.) are used by the system itself.
DeVelox said:
In Linux partitions are mounted under directories. So /cache, /data and /system are really just mount points for those partitions. It's understandable that this would confuse you if you haven't had experience with Linux. Windows handles partitions somewhat differently.
When you flash a ROM, you are actually flashing only the system partition. Kernel is flashed to the boot partition, and others (cache, data, sdcard, etc.) are used by the system itself.
Click to expand...
Click to collapse
Yes i have a little knowledge, albeit very little, of Linux. But if it is an actual partition it will also show under /mnt after you mount it, correct? That is how you tell if it is an actual partition. I do realize that the others partitions like /sdcard are being automatically mounted. And you can browse them through the /sdcard folder or /mnt/scard.
/cache is no where under /mnt or any subs of any partitions that are mounted so that tells me the /cache folder that shows under root is actually only a folder. Well there is a cache subdirectory underone of the partitions under /mnt but the contents are different than the contents of the cache folder running off of root.
Sorry bout all of the questions. I have done a lot to my phone and kf. I just like to know what it's being affected when when I do what I am doing. And why I am doing what I am doing.
Like i said before, the term rom confused me as when i was flashing roms on other devices I was having to build a hardware interface and cut traces on the board, sometimes install jumpers across traces. All of that to flash "roms". This was on xboxes and satellite receivers mainly.
No, /mnt is just a directory like any other. In fact, it is rarely used for mounting purposes in modern Linux distributions.
When you open /cache, /data or /system in Root Explorer, please check the "x MB used, y MB free" line at the top. You will notice that it shows different values for each of those directories. That should be enough to convince you that they are indeed partitions, and not ordinary directories.
You will also notice that, for example, /etc shows the same used/free info as /system. That is because /etc is actually a symlink to /system/etc.
You should read up more on Linux, or just take my word for it.
P.S. If you have Terminal Emulator app installed, try the "df -h" command. It will list all the partitions, their mount points, and used/free space info. Mind you, only entries starting with "/dev/block" are actual partitions, tmpfs is something else.
I see said the blind man. I also found this as an example of the partitions on my kf.
Scrolling down I see all of the active partitions.
http://kindlefirenews.org/expand-app-storage-on-the-kindle-fire/
Thanks for the explanations. But I will say that ROM it's a misnomer!
Open a console on your android and type "df".
You will see the partitions.

Idea for creating extra storage space

I have a good 2 GB of space that I am unlikely to use on the /data partition. So I created an 'sdcard' directory in there. What I'm trying to do is trick the system into believing that it's a second SD card. Can android support more than one? It's all good getting the directory to work as a secondary storage place, but the problem is, media scanner will not show pictures/music that are in that directory.
So my question is, is it possible to edit the ramdisk (init.rc) or vold.fstab etc or any other files, so the system is tricked into believing it's an actual storage card? I have tried making symlinks and doing directory bindings from /data/sdcard to /storage/sdcard1, but haven't had any luck.
Edit:
something like this maybe in init.rc??
symlink /storage/sdcard /sdcard
symlink /storage/sdcard1 /data/sdcard
export EXTERNAL_STORAGE /storage/sdcard
export SECONDARY_STORAGE /storage/sdcard1
I'm sure something is possible.
The nicest thing would be to have vold bind-mount a directory or loop-mount a filesystem image, but I'm not sure vold can do that at all and if it can I don't know what the syntax for that would be.
This would probably be a bit different between sense and aosp as it looks like vold is different.
You can easily bind-mount it yourself.
Either way, if you want to mount it on (say) /sdcard2 or anywhere on the root file system, you have to edit the ramdisk in the boot image.
But you can also mount it on top of /sdcard
mkdir /data/extra_sd
mkdir /sdcard/extra_sd
busybox mount --bind /data/extra_sd /sdcard/extra_sd
( ^^^-- I found that /system/bin/mount doesn't do --bind or -o loop and that busybox mount does.)
I tried this and it works. I have not yet experimented with putting it in an init.d script or so to mount it on boot and see if mediascanner scans it.
However, using this method you may corrupt stuff when you USB-mount your sdcard onto your PC. I'm not sure.
-Jobo
I've actually been trying numerous ways of mount bind all day. From init.d to repacking kernels with adjusted init.rc. Nothing worked.
The only way that works is using ScriptManager to run a busybox mount -o bind command at startup. It binds a subfolder in /sdcard/music to /data/media, where I've offloaded 1.5 GB of my music. I've rebooted many times and it seems to mount on time before messing up the media storage, and now I have 1.5 G extra SD space
Well, you could try "partitioning" the phone with LVM.
Which would actually be really interesting. I've got an extra gig of space in each of /system and /data that I'm not using. Being able to span that with /sdcard would be handy.
Actually, with that in place, you could combine /data and /sdcard into a single large partition and then just have both directories on that.
ardax said:
Well, you could try "partitioning" the phone with LVM.
Which would actually be really interesting. I've got an extra gig of space in each of /system and /data that I'm not using. Being able to span that with /sdcard would be handy.
Actually, with that in place, you could combine /data and /sdcard into a single large partition and then just have both directories on that.
Click to expand...
Click to collapse
That would be the ideal solution, which I have been hoping since day 1 becomes available from our phone, but does it not require S-OFF?
djsubtronic said:
That would be the ideal solution, which I have been hoping since day 1 becomes available from our phone, but does it not require S-OFF?
Click to expand...
Click to collapse
I don't think it should, since it's not changing the partition layout of the internal memory itself, just globbing it together and slapping virtual volumes on top with LVM. The biggest things are making sure that the kernel has LVM support and binaries built in and that recovery can get to those LVM binaries.
Perhaps I'm wrong though.
djsubtronic said:
I've actually been trying numerous ways of mount bind all day. From init.d to repacking kernels with adjusted init.rc. Nothing worked.
The only way that works is using ScriptManager to run a busybox mount -o bind command at startup. It binds a subfolder in /sdcard/music to /data/media, where I've offloaded 1.5 GB of my music. I've rebooted many times and it seems to mount on time before messing up the media storage, and now I have 1.5 G extra SD space
Click to expand...
Click to collapse
I really like the idea using data to get some extra space.
I tried "busybox mount --bind" via console and it works. Now i will have a look at ScriptManager.
But what happens if you are installing/updating a new ROM. Do you lose all your things located in /data?
regards
If you format /data then yes, obviously. You are only creating a "shortcut" to /data/folder.
Also, if you run out of space in /data/app/ you can move apps to /system/app instead.
I did that on my blade with a way too big /system/ partition and way too small /data/ partition
djsubtronic said:
I've actually been trying numerous ways of mount bind all day. From init.d to repacking kernels with adjusted init.rc. Nothing worked.
The only way that works is using ScriptManager to run a busybox mount -o bind command at startup. It binds a subfolder in /sdcard/music to /data/media, where I've offloaded 1.5 GB of my music. I've rebooted many times and it seems to mount on time before messing up the media storage, and now I have 1.5 G extra SD space
Click to expand...
Click to collapse
Could I get a hold of that script by chance?
Daiskei said:
Could I get a hold of that script by chance?
Click to expand...
Click to collapse
+1. Yes, please share.
One S | Xparent Blue Tapatalk 2 | Viper 1.2.1 | Bricked Beastmode
So updating a ROM without formating data partition should be no problem.
But for installing a new ROM i have to backup the folder in the data partition.
I tried to use ScriptManager, but this app seems to be bit overloaded.
After this i installed GScriptsLite.
In there i made a new script with something like this:
busybox mount --bind /data/myfolder /sdcard/myfolder
The script is not started automatically after a reboot, but after running the script via GScriptsLite the folder is mounted.
Yeah I suppose it could be difficult if changing ROMs, but I use CM only so I never worry about changing the data partition. But if I do, I just copy the /data/media folder onto my PC using adb pull, then do the wiping/flashing, and finally push the media folder back before booting the ROM.
As for the script, it's essentially just this one line:
Code:
busybox mount -o bind /data/media /storage/sdcard0/Music/Music2
I've kept the script file itself on the /data partition as well. In script manager I've set it to run the script as SU and on boot, and that's it. I've mounted it into a sub folder within Music since I use PlayerPro and it only adds music found within /sdcard/Music.
Yes, ScriptManager is a lot more complicated than GScripts, but it always mounts it automatically on boot so saves the hassle of having to remember to manually run the script if you ever reboot. Plus you only have to sort it out once then never open the app again if you don't want to

fstab.qcom modification

I just got my first Android Device (Moto E) and tried to get around the small internal memory by using the sdcard instead of the internal memory for /data. As the KitKat mounting procedure does not seem to be based on vold.fstab anymore, the usual guides to doing that don't apply.
So my idea was to format the sdcard with ext4 and modify the /fstab.qcom file to mount the sdcard as /data instead of the internal data partition. But here's where I don't know how to proceed, as adb shell don't seem to have access to the proper partition during flashboot (though having mounted the rootfs parition which should contain those files?) and is unable to write to the file once the system is running.
I'd appreciate if anyone can point me in the right direction on how to do that.
lunaticat said:
I just got my first Android Device (Moto E) and tried to get around the small internal memory by using the sdcard instead of the internal memory for /data. As the KitKat mounting procedure does not seem to be based on vold.fstab anymore, the usual guides to doing that don't apply.
So my idea was to format the sdcard with ext4 and modify the /fstab.qcom file to mount the sdcard as /data instead of the internal data partition. But here's where I don't know how to proceed, as adb shell don't seem to have access to the proper partition during flashboot (though having mounted the rootfs parition which should contain those files?) and is unable to write to the file once the system is running.
I'd appreciate if anyone can point me in the right direction on how to do that.
Click to expand...
Click to collapse
A little late in the game (I am trying to do the same), but I come across this:
http://forum.xda-developers.com/showthread.php?t=443994
boot partition populates the rootfs. So hack the boot.img (unpack to analyze), and you may find your answer. Hope this helps.
I will give it a shot in the next week.

method to set 0123-4567 as mount point for removable sdcard

This is a very annoying issue but I have not found any thread about it.
I'm trying to upgrade my external/removable sdcard for an android 6 device.
The new sdcard gets mounted to /mnt/media_rw/XXXX-XXXX (i.e. not 0123-4567), so no app works as files can't be found.
The linux way (ln) wont work. Simply creating /mnt/media/0123-4567 causes bad bootloop on my device. This suggests that FolderMount app or Magisk modules such as fbind are a bad idea. selinux is enforcing.
It appears that Android assigns different mount points are to different sdcards and the first sdcard always gets 0123-4567. It that's right, Android probably stores sdcards' identifiers so as to know which mount point to use at boot time. So, deleting the identifiers database would probably mean that the next card inserted would get 0123-4567 as mount point.
I have looked at the data of com.android.externalstorage, but there is nothing there. I don't see other obvious candidate apps.
Where is this ext sdcard data stored?
I was wrong. Android sets mount points matching sdcard uuid
How to change vfat partition UUID?
How do I change the UUID of a vfat partition? For ext2 / ext3 / ext4, this is done with a simple: tune2fs -U <new-uuid> /dev/<partition> Is there a similar command for vfat partitions?
superuser.com

Categories

Resources