Related
I created a zeroed file with dd and attempted to mount it with:
mount -o loop /sdcard/test.img /data/test
and
losetup /dev/block/loop0 /sdcard/test.img
However, no loopback devices are displayed when I invoke mount. Can anyone clue me in? Feel like i'm missing something basic. By the way, I am running these commands from Saurik's busybox with the losetup /dev/block/loop fix.
p.s. I'd ask on the G1 hackers mailing list, but it's gone a bit bonkers in the past few days.
I'm not sure, but doesn't the image file you're trying to mount have to contain an actual file system?
Yea, I subsequently created a filesystem for it with mke2fs (which is mysteriously missing from busybox for android?). Still no go. Same when I tried to mount other partition-in-a-files like the module.cramfs or recovery.img
If I try to losetup the loop device then mount that, it returns error:
mount: mounting /dev/block/loop0 on /data/test failed: No such device
If I try to mount directly with -o loop, it returns:
mount: cannot setup loop device: No such file or directory
And yet Saurik seems to have been able to loop mount fine. Perhaps it is because I am testing on the qemu instead of hardware?
That might be it. You might try busybox's mount also.
But yeah, It definitely does work on the phone at least.
I've been trying to figure out how to load debian on the emulator, but I can't get the ext2 image mounted. I had to recompile the kernel first so support loadable modules, but even after that, it would not work (can't remember the specific error). Has anyone gotten an ext2 file system mounted on the emulator successfully?
The reason I'm doing this is so I can do native compiles, without actually having to do it on the phone. It has advantages in that I can crank up the clock speed and the RAM.
So I was able to mount loopback just fine on the actual hardware, but i'm having trouble getting it to run from the init.rc file. This is what i'm typing at the shell (it works):
(after insmod ext2.ko)
mount -o loop,noatime,nodiratime,nosuid,nodev -t ext2 /sdcard/loopy/app.img /data/app
It works fine and i'm able to install and run apks from the sdcard (/dev/block/loop2 on /data/app type ext2). Of course this is no good unless it can be mounted before the launcher starts (or it won't see any of our apks). The syntax for init mounting is different from sh, so I tried this (this is in /data/init.rc btw):
on userdata
#mount loopback file from sdcard
insmod /system/modules/2.6.25-01843-gfea26b0/kernel/fs/ext2/ext2.ko
mount ext2 /sdcard/loopy/app.img /data/app noatime nodiratime nosuid nodev loop
I know the script is being run since the ext2.ko module is getting installed. But the mount command isn't being executed. Can anyone shine a light on this? I'm not very familiar with the init daemon.
jashsu said:
So I was able to mount loopback just fine on the actual hardware, but i'm having trouble getting it to run from the init.rc file. This is what i'm typing at the shell (it works):
(after insmod ext2.ko)
mount -o loop,noatime,nodiratime,nosuid,nodev -t ext2 /sdcard/loopy/app.img /data/app
It works fine and i'm able to install and run apks from the sdcard (/dev/block/loop2 on /data/app type ext2). Of course this is no good unless it can be mounted before the launcher starts (or it won't see any of our apks). The syntax for init mounting is different from sh, so I tried this (this is in /data/init.rc btw):
on userdata
#mount loopback file from sdcard
insmod /system/modules/2.6.25-01843-gfea26b0/kernel/fs/ext2/ext2.ko
mount ext2 /sdcard/loopy/app.img /data/app noatime nodiratime nosuid nodev loop
I know the script is being run since the ext2.ko module is getting installed. But the mount command isn't being executed. Can anyone shine a light on this? I'm not very familiar with the init daemon.
Click to expand...
Click to collapse
Try
mount ext2 [email protected]/sdcard/loop/app.img /data/app noatime nodiratime nosuid nodev
JesusFreke said:
Try
mount ext2 [email protected]/sdcard/loop/app.img /data/app noatime nodiratime nosuid nodev
Click to expand...
Click to collapse
Tried that one earlier too. No love.
jashsu said:
Tried that one earlier too. No love.
Click to expand...
Click to collapse
I betcha the sdcard hasn't been mounted yet.
Is there anything in dmesg that looks relevant? Or maybe logcat?
Try temporarily moving the image file to /data, and see if you can get it to mount. That should verify that it has something to do with it being on the sdcard
JesusFreke said:
I betcha the sdcard hasn't been mounted yet.
Is there anything in dmesg that looks relevant? Or maybe logcat?
Click to expand...
Click to collapse
Agh! You're right. The mount daemon runs at line 192, in the services section. Long after the /data/init.rc is parsed.
service mountd /system/bin/mountd
socket mountd stream 0660 root mount
Any way around this short of manually mounting the sdcard in the /data/init.rc?
Edit: dmesg bingo:
<3>[ 1.920368] init: unable to mount [email protected]/sdcard/loopy/app.img to /data/app
as ext2
<6>[ 1.921498] yaffs: dev is 32505860 name is "mtdblock4"
<6>[ 1.922016] yaffs: passed flags ""
<4>[ 1.922322] yaffs: Attempting MTD mount on 31.4, "mtdblock4"
<4>[ 1.927204] yaffs: restored from checkpoint
<4>[ 1.927845] yaffs_read_super: isCheckpointed 1
<3>[ 1.960002] init: unable to mount /system/xbin.cramfs to /system/xbin as c
ramfs
<3>[ 1.965221] init: service 'console' requires console
<4>[ 2.161895] mmc_sd_init_card: Delay 250 ms
<4>[ 2.522535] mmc1: host does not support reading read-only switch. assuming
write-enable.
<6>[ 2.523359] mmc1: new SDHC card at address cd4e
On a side note, it looks like the mount action for xbin.cramfs in the main init.rc is failing because it's redundant with an earlier mount in /system/init.rc. I'm guessing this is a vestige of development on cramfs loopback mounting (mentioned here by Saurik).
6) at Jesus Freke's suggestion, setup /system/xbin (and later /system/modules) to mount from a compressed image
Click to expand...
Click to collapse
Yeah, I had left in an extra mount for xbin.cramfs in the base init.rc. I believe that's fixed in v1.3. I'll check again and make sure
So I gather the reason for wanting to mount a loopback device is to be able to create an ext2 fs as a file on the sdcard fat fs instead of creating 2 separate parittions on the sdcard , one for fat and one for ext2?
If this can be done, this would be a much better solution for getting apps to run on the sdcard than the previous hack which requires creating an ext2 partition on the sdcard.
Yeah that was what I was looking into. However as noted above, the I couldn't mount the image on the sdcard because the point at which /data/init.rc gets parsed occurs before the sdcard service starts up. The partition method doesn't have this problem because it creates a node for paritition #2 in the init.rc
jashsu said:
Yeah that was what I was looking into. However as noted above, the I couldn't mount the image on the sdcard because the point at which /data/init.rc gets parsed occurs before the sdcard service starts up. The partition method doesn't have this problem because it creates a node for paritition #2 in the init.rc
Click to expand...
Click to collapse
so u can't mount the sdcard in /data/init.rc?
dwang said:
so u can't mount the sdcard in /data/init.rc?
Click to expand...
Click to collapse
Not sure, I didn't try mounting partition #1. You could give it a shot by using mknod in /data/init.rc like the parted sdcard method. The sdcard service might not like that the card has already been mounted though.
There are two major reasons I abandoned this concept. The first is I didn't want to figure out how to get permission to mount /sdcard (since / is ro). The second is that making the sdcard available as a usb mass storage device makes it exclusively unaccessible from Android. I suppose that might not be so bad if you are only offloading /data/app, as long as you don't try to execute any new apps while your mass storage connection is going. It's non-ideal.
jashsu said:
Not sure, I didn't try mounting partition #1. You could give it a shot by using mknod in /data/init.rc like the parted sdcard method. The sdcard service might not like that the card has already been mounted though.
There are two major reasons I abandoned this concept. The first is I didn't want to figure out how to get permission to mount /sdcard (since / is ro). The second is that making the sdcard available as a usb mass storage device makes it exclusively unaccessible from Android. I suppose that might not be so bad if you are only offloading /data/app, as long as you don't try to execute any new apps while your mass storage connection is going. It's non-ideal.
Click to expand...
Click to collapse
I don't think the 2nd reason is that big of a deal. If google is planning on implementing the file based method for apps on the sdcard, they could just block access to apps when the sdcard is mounted to a pc. Its a lot better than the alternative of having to create a 2nd ext2 partition on the sdcard. Of course google should have really solved this issue before the g1 came out.
Anyways, I don't see /data/init.rc on my jf rc 1.2 g1. I only see /init.rc and /system/init.rc. Is /data/init.rc something that you created just for the purpose of mounting the file.
dwang said:
I don't think the 2nd reason is that big of a deal. If google is planning on implementing the file based method for apps on the sdcard, they could just block access to apps when the sdcard is mounted to a pc. Its a lot better than the alternative of having to create a 2nd ext2 partition on the sdcard. Of course google should have really solved this issue before the g1 came out.
Anyways, I don't see /data/init.rc on my jf rc 1.2 g1. I only see /init.rc and /system/init.rc. Is /data/init.rc something that you created just for the purpose of mounting the file.
Click to expand...
Click to collapse
Yeah it's referenced in /init.rc Easier to use since unlike /system/init.rc, it's not in a ro folder. You could use /system/init.rc too. Either way really.
jashsu said:
Yeah it's referenced in /init.rc Easier to use since unlike /system/init.rc, it's not in a ro folder. You could use /system/init.rc too. Either way really.
Click to expand...
Click to collapse
Ok.. I'll probably just stick with partitioning the sdcard into fat and ext2. Its working well for me and there really isn't a whole lot of advantages having the ext2 as a file on the fat partition.
I have 41 apps installed on the sdcard now (including some huge games like bonzai blast and brain genius deluxe) and I still have 59 megs of free internal storage. I think everybody that has a rooted g1 should put apps to the sdcard.
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.
I have a Galaxy GIO, which is a fairly old low-end phone. On factory reset, I have about 100MB memory free for apps, and the phone seems to start complaining as soon as I hit the 50MB mark; that's about one or 2 installed applications.
Because I would like to actually be able to, well, use my phone for anything else than calling, I want to move the /data partition to my SD card. I know this'll be slow, but slow still is better than not working at all.
I have done a bit of research, and came around plenty of scripts which claim to mount the second partition of the sd card as /data; none of these scripts work. I have tried 'INT2EXT', 'D2EXT', and I've heard about something called 'A2SD' but I have yet to find a copy of it . To install these scripts I've extracted them, and copied the scripts to '/system/etc/init.d/', after mounting '/system', using ADB.
I for an instant thought maybe my second partition isn't formatted properly, but using adb I am able to successfully mount the ext2 partition as /sd-ext, so I don't see why mounting them as /data should be a problem.
I have also tried to symbollicly link /data to /sd-ext/data and automatically mount my /sd-ext on boot. Obviously this didn't work, because the symbolic link isn't actually saved to disk.
How would I go about moving my data partition to my sd card? I am not affraid of doing some dirty work manually. I am running Cyanogenmod 11.
Binero said:
I have a Galaxy GIO, which is a fairly old low-end phone. On factory reset, I have about 100MB memory free for apps, and the phone seems to start complaining as soon as I hit the 50MB mark; that's about one or 2 installed applications.
Because I would like to actually be able to, well, use my phone for anything else than calling, I want to move the /data partition to my SD card. I know this'll be slow, but slow still is better than not working at all.
I have done a bit of research, and came around plenty of scripts which claim to mount the second partition of the sd card as /data; none of these scripts work. I have tried 'INT2EXT', 'D2EXT', and I've heard about something called 'A2SD' but I have yet to find a copy of it . To install these scripts I've extracted them, and copied the scripts to '/system/etc/init.d/', after mounting '/system', using ADB.
I for an instant thought maybe my second partition isn't formatted properly, but using adb I am able to successfully mount the ext2 partition as /sd-ext, so I don't see why mounting them as /data should be a problem.
I have also tried to symbollicly link /data to /sd-ext/data and automatically mount my /sd-ext on boot. Obviously this didn't work, because the symbolic link isn't actually saved to disk.
How would I go about moving my data partition to my sd card? I am not affraid of doing some dirty work manually. I am running Cyanogenmod 11.
Click to expand...
Click to collapse
I will introduce how to COPY(NOT MOVING) /data partition to /sdcard.
1. You should ROOT First.
2. Use Rootexplorer to Copy /data to /sdcard (WARNING:If your sdcard emulated with /data, Data WON'T copy to SDCARD --You need external Sdcard!)
2-1. if you don't want to use RootExplorer, you can use Android Debugging Bridge(adb)
(Youshould download Android sdks from developer.android.com)
--Command : adb shell su -C cp /data /sdcard/data
3. That's all.
Jason Hyunwoo said:
I will introduce how to COPY(NOT MOVING) /data partition to /sdcard.
1. You should ROOT First.
2. Use Rootexplorer to Copy /data to /sdcard (WARNING:If your sdcard emulated with /data, Data WON'T copy to SDCARD --You need external Sdcard!)
2-1. if you don't want to use RootExplorer, you can use Android Debugging Bridge(adb)
(Youshould download Android sdks from developer.android.com)
--Command : adb shell su -C cp /data /sdcard/data
3. That's all.
Click to expand...
Click to collapse
Thanks, but that's not entirely what I meant. I can manage to move my data to the SD card no problem, but I want my phone to actually use my second partition on my sd card, as the /data partition.
Binero said:
Thanks, but that's not entirely what I meant. I can manage to move my data to the SD card no problem, but I want my phone to actually use my second partition on my sd card, as the /data partition.
Click to expand...
Click to collapse
Oops.. Sorry about that!
First, I am not sure that will work or not, maybe you should try to edit init.*.rc. Which is from boot.mg. I think, maybe mounting sdcard as data is impossible, but you may try editing init.rc(or init.*.rc, * is manufacture). You could unpack your boot img, and you could edit mounting point which is from init.rc!
I hope this thing will help you..
Jason Hyunwoo said:
Oops.. Sorry about that!
First, I am not sure that will work or not, maybe you should try to edit init.*.rc. Which is from boot.mg. I think, maybe mounting sdcard as data is impossible, but you may try editing init.rc(or init.*.rc, * is manufacture). You could unpack your boot img, and you could edit mounting point which is from init.rc!
I hope this thing will help you..
Click to expand...
Click to collapse
I have looked into init.rc, but that only seemed to create the /data mountpoint, but not actually mount to it. I've no idea how to edit the boot image, or what that even is. Is that the filesystem that is built into the kernel?
Binero said:
I have looked into init.rc, but that only seemed to create the /data mountpoint, but not actually mount to it. I've no idea how to edit the boot image, or what that even is. Is that the filesystem that is built into the kernel?
Click to expand...
Click to collapse
Umm.. You should download unpackbootimg or dsixda's Android Kitchen to edit boot.mg. You cannot edit init.rc on Root explore. Use unpack boot.img menu which is from Android Kitchen!
Jason Hyunwoo said:
Umm.. You should download unpackbootimg or dsixda's Android Kitchen to edit boot.mg. You cannot edit init.rc on Root explore. Use unpack boot.img menu which is from Android Kitchen!
Click to expand...
Click to collapse
I'll try that out. Still not sure where to look though. As I said, init.rc does not contain any commands mounting /data.
Binero said:
I'll try that out. Still not sure where to look though. As I said, init.rc does not contain any commands mounting /data.
Click to expand...
Click to collapse
or you could edit look at other *.rc files!
Isn't this what you're looking for?
http://forum.xda-developers.com/galaxy-s2/themes-apps/tool-directorybind-data-to-externalsd-t1410262
sndsnd said:
Isn't this what you're looking for?
http://forum.xda-developers.com/galaxy-s2/themes-apps/tool-directorybind-data-to-externalsd-t1410262
Click to expand...
Click to collapse
I want to mount my sd card to my /data. That simply creates a symbolic link.
Jason Hyunwoo said:
or you could edit look at other *.rc files!
Click to expand...
Click to collapse
There is only 2 rc files, and one of them is specific to my recovery image.
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
I've been trying to partition my SD card, but all steps I take to try and diagnose why I am unable to partition the card is getting me nowhere.
Initially, I used gparted on my laptop to partition the SD card with a v-fat partition and a f2fs partition, both primary partitiond. This was when I found out that no matter what I do the second partition on the SD card, it doesn't seem like the format actually takes. Whatever tool I use complete the partitioning and formatting steps successfully by all appearances but it doesn't seem like the partition is ever actually formatted. What I mean by that is that no matter what the second partition is it never mounts. I get an invalid argument error or bad super blocks and so forth. I can make the first partition anything I want: fat, v-fat, f2fs, ext4 and so forth and that will mount in my terminal without issue, but no matter what I do the 2nd partition always fails to mount. I've also noticed that blkid never has any fs info for the second partition. It gives me the partition UUID and that's all, while the first partition has both part UUID & fs UUID.
I've even gone so far as to just recently get a brand new SD card thinking that perhaps the first SD card was corrupted but I'm still getting the exact same behavior. Also of note is that in gparted when I try to create a secondary partition, I'm unable to mount the second partition so I don't think it has anything to do with my device. I've tried using fdisk, gdisk, parted in the terminal and I've tried using extended partitions and logical partitions and only primary partitions. I've done this before in the past so I know that it is possible.
It almost seems like the SD cards that I have are simply not capable of being partitioned in any way but it's strange that I now have two 512 GB SD cards and they're both giving the exact same behavior so I'm thinking that I'm missing something obvious. Any help anyone could provide as far as trying to figure this out or debug what's going on what I'm doing wrong would be greatly appreciated.
Thanks,
Ryan
only the first partition is mounted from vold. that is normal behaviour on every device. if you want have all partitions mounted automatically install LineageOS.
furthermore, although sdcardfs supports ext4, f2fs, for file transfer via USB MTP afaik fat32, exfat or ntfs is required.
what do you need f2fs partition for? maybe I can point you to workaround.
aIecxs said:
only the first partition is mounted from vold. that is normal behaviour on every device. if you want have all partitions mounted automatically install LineageOS.
furthermore, although sdcardfs supports ext4, f2fs, for file transfer via USB MTP afaik fat32, exfat or ntfs is required.
what do you need f2fs partition for? maybe I can point you to workaround.
Click to expand...
Click to collapse
I don't need anything to mount automatically. I'm saying I can't manually mount these partitions. I also don't need f2fs, that was just an example. I've tried multiple partitions that are just fat, ext4 and many other combinations. Under no partition scheme can I get anything other than the first partition to mount--using the mount command as root.
can you please try gdisk binary from here
https://forum.xda-developers.com/t/...-on-qmobile-z8-with-bricked-dead-emmc.3712171
please post the result of partitioning and formatting.
if you're interested in alternative solution, you can actually format the whole MicroSD card as exfat, and create ext4 partition image on top as regular file. I have done that for my mothers Huawei for Link2SD because it doesn't support adoptable storage.
aIecxs said:
can you please try gdisk binary from here
https://forum.xda-developers.com/t/...-on-qmobile-z8-with-bricked-dead-emmc.3712171
please post the result of partitioning and formatting.
if you're interested in alternative solution, you can actually format the whole MicroSD card as exfat, and create ext4 partition image on top as regular file. I have done that for my mothers Huawei for Link2SD because it doesn't support adoptable storage.
Click to expand...
Click to collapse
I have tried with gdisk but I can try with that specific version and report back. I understand we can create imaged file systems, but one of the main reasons I do this is that I find fat partitions are fickle and can easily be corrupted where the whole partition requires wiped. By having a non fat partition I use that as a better backup option where I find it's easier to recover data in case of corruption or other issues. For such use, being tied to the fat FS would still incur the possibility of data loss so that doesn't work for my purpose.
Thanks and I'll report back,
Ryan
oh I wouldn't rely on f2fs for backups it still has bugs and there are no recovery tools for f2fs
https://forum.xda-developers.com/t/4550931
https://android.stackexchange.com/q/250389
alecxs said:
oh I wouldn't rely on f2fs for backups it still has bugs and there are no recovery tools for f2fs
https://forum.xda-developers.com/t/4550931
https://android.stackexchange.com/q/250389
Click to expand...
Click to collapse
Thanks for the suggestion to use gdisk. I downloaded the version you linked, but I still get the same behavior. I believe it is related to the fact that only the first partition gets a filesystem UUID in blkid. I'm not sure what this means, but it seems clear that the second filesystem isn't being properly created no matter what I do.
that's strange, especially the fact you tried on PC too. on the phone, can you create partitions inside a blank disk image just for double check to rule out kernel issue?
I'll give that a try and report back
alecxs said:
that's strange, especially the fact you tried on PC too. on the phone, can you create partitions inside a blank disk image just for double check to rule out kernel issue?
Click to expand...
Click to collapse
Yeah I'm able to create an image, partition it into a vfat & ext4, then mount both of those partitions.
can you dd the file into mmcblk1 for testing purposes?
alecxs said:
can you dd the file into mmcblk1 for testing purposes?
Click to expand...
Click to collapse
Sorry this isn't clear to me. What am I using to dd into the partition, and do you mean mmcblk1p1/2? As mmcblk1 is the whole disk.
Thanks,
Ryan
yes, I meant the whole disk you created a test file that contains MBR or GPT and two partitions including UUIDs and file systems? If you dd it into the mmcblk1 it should create 1:1 copy of that disk image with two partitions including partition table.
Well I'll be:
Code:
/dev/block/mmcblk1p2 on /data/data/com.termux/files/home/i2 type ext4 (rw,relatime,seclabel) /dev/block/mmcblk1p1 on /data/data/com.termux/files/home/i2 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
Code:
/dev/block/mmcblk1p2 23M 46K 23M 1% /data/data/com.termux/files/home/i2 /dev/block/mmcblk1p1 4.9M 0 4.9M 0% /data/data/com.termux/files/home/i1
I can possibly use gparted to just resize those! Any thoughts on what was going on, why this method worked? Hrmm looks like resizing fat could be a challenge, but this certainly gets me closer!
there is also parted binary you can use on phone
I have it and I'm playing around with it, thanks for all your help