I am trying to mount an sd card that I put into my tablet. The sd card is in ext2 format. I tried using BusyBox with the following command in my terminal app on the tablet:
busybox mkfs.ext2
But it seems I need to add some arguments to the command. What commands would I need to add to it? Or is there an easier way to mount the sd card?
I would like to not format the sd card as there is data on it; but whatever it takes to read it as ext2 format is ok.
you need to mount the ext2 filesystem not create the filesystem.
Depending on your tablet, the device in /dev could be different from my example. but in general you want to run a similar command :
busybox mount -t ext2 /dev/block/vold/179:2 /data/sd-ext
where /dev/block/vold/179:2 is the device that you are trying to mount.
and /data/sd-ext is the path where you want to mount your sd card to.
here's the help page for the mount command
1|shell#android:/ $ busybox mount -t
option requires an argument -- t
BusyBox v1.20.0.git (2012-03-21 01:44:00 GMT) multi-call binary.
Usage: mount [OPTIONS] [-o OPTS] DEVICE NODE
Mount a filesystem. Filesystem autodetection requires /proc.
-a Mount all filesystems in fstab
-f Dry run
-i Don't run mount helper
-r Read-only mount
-w Read-write mount (default)
-t FSTYPE[,...] Filesystem type(s)
-O OPT Mount only filesystems with option OPT (-a only)
-o OPT:
loop Ignored (loop devices are autodetected)
[a]sync Writes are [a]synchronous
[no]atime Disable/enable updates to inode access times
[no]diratime Disable/enable atime updates to directories
[no]relatime Disable/enable atime updates relative to modification time
[no]dev (Dis)allow use of special device files
[no]exec (Dis)allow use of executable files
[no]suid (Dis)allow set-user-id-root programs
[r]shared Convert [recursively] to a shared subtree
[r]slave Convert [recursively] to a slave subtree
[r]private Convert [recursively] to a private subtree
[un]bindable Make mount point [un]able to be bind mounted
[r]bind Bind a file or directory [recursively] to another location
move Relocate an existing mount point
remount Remount a mounted filesystem, changing flags
ro/rw Same as -r/-w
There are filesystem-specific -o flags.
Should be busybox mount /dev/block/something /mountpoint. mkfs creates a filesystem like format in Windows
http://www.busybox.net/downloads/BusyBox.html#mount
Or is there an easier way to mount the sd card?
It usually happens automatically, check busybox mount without arguments if it is already mounted somewhere.
Related
I'm using the below command to mount sd card in adb shell window, which returns an error:
# mount -rw -t vfat /tmp/udev/dev/mmcblk0p1 /tmp/new
mount: Device or resource busy
what might be the issue?
But when I'm mounting it as read only using the below command I could able to read the contents of SD card.
# mount -r -t vfat /tmp/udev/dev/mmcblk0p1 /tmp/new
I'm interesting in make some changes in init.rc file.
As I have read, I must get copy of boot.img, unpack it, add my changes to init.rc file, pack and push back new boot.img to phone, and after reboot my changes will be considered. (I can't just change init.rc file, that is at / directory, due to it will be rewritten at next reboot.)
So I try:
adb shell
su
fdisk -l /dev/block/mmcblk0
fdisk outputs list of all partition (mounted and unmounted) which are on phone.
I'm intersting in boot:
9 147456 163839 8192K 0700 BOOT
where 9 - is partition number, so my partition (device to mount) is /dev/block/mmcblk0p9.
Then I remount rootfs to read/write permissions:
mount -o rw,remount rootfs /
Create directory (mount point) /boot:
mkdir /boot
And then try to mount boot partition to /boot:
mount -t auto /dev/block/mmcblk0p9 /boot
but retrive "mount: No such device".
Are anybody faced with this ?
Thanks in advance for you help.
PS:
List of partitions can be also obtained by:
ls -l /dev/block/platform/dw_mmc.0/by-name
Edited:
I have sources, but I don't want to rebuild their, due to a large amount of time compilation. (I must make many changes in init.rc file and recompile all CyanogenMod it's very expensive).
I have tried to build only module tied, as I think, with init.rc (system/core/rootdir), just type mmp:
ila:~/cm_s4/cm_12_1/system/core/rootdir$ mmp
and obtained next line:
Install: /home/ila/cm_s4/cm_12_1/out/target/product/i9500/root/init.rc
but, no line such as (for example, when I type mmp in external/hello_world):
Pushing: /system/bin/hello_world
I have get the root access on my phone.In adb shell,I type the commands as below:
#create a file about 10M
dd if=/dev/zero of=/mnt/sdcard/AAA.pdf bs=1024 count=10000
#format this file
mkfs.ext2 -F /mnt/sdcard/AAA.pdf
#create a folder which is used to be mounted
mkdir /mnt/sdcard/aaa
#mount
mount -t ext2 -o loop /mnt/sdcard/AAA.pdf /mnt/sdcard/aaa
chmod 777 /mnt/sdcard/aaa
#umount
umount /mnt/sdcard/aaa
It runs properly. But if I want to mount again, it failed. After I type mount -t ext2 -o loop /mnt/sdcard/AAA.pdf /mnt/sdcard/aaa,it says ioctl LOOP_SET_FD failed: Device or resource busy. I dont know how could this happen. Can anybody help?
If it is already mounted, you can't mount it again unless you pass it the 'remount' option. That option may or may not be available in Android's mount command since it is not standard mount.
1- Android toolbox has not good support of loop devices. Try to use busybox's one.
2- Check that you have a remaining free loop device using losetup.
For umount:
umount /mnt/sdcard/aaa
losetup -d /dev/loop0
Although on my device mounted loop fs is not accessible by none root user (dir permission 777). There is seclabel flag and I think it is a reason.
I need to test a scenario where the sdcard (or atleast a particular directory) is read-only. Does anyone know how I can do this on the emulator?
Basically I want to mount the sdcard as read-only. I tried the following command in adb shell, but it doesn't work.
mount -o remount r /sdcar
Here is how I managed to remount sdcard in read-only mode:
Step 1.
Execute mount and see the list of mounted directories. Note the one with /sdcard or /mnt/sdcard in it.
On my Android 1.6 emulator:
/dev/block//vold/179:0 /sdcard vfat rw,dirsync,nosuid,nodev,...
Step 2.
Execute next command:
mount -o remount,ro <block> <sdcard>
Where <block> and <sdcard> are first two items taken from mount output line with sdcard.
In my case the command would be:
mount -o remount,ro /dev/block//vold/179:0 /sdcard
make sure you have set permissions in your manifest file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I have placed an ubuntu.img file in a folder on my SD card as well as the following scripts obtained from - http://blog.coralic.nl/2010/08/17/ubuntu-on-samsung-galaxy-s-android/
/mnt/sdcard/ubuntu/start
#!/bin/bash
#Created by Armin Coralic http://blog.coralic.nl
if [ "$1" == "" ] ;
then
echo "You need to specify the img file!"
exit 9;
fi
if `test -d /data/local/mnt` ; then
echo "/data/local/mnt"
else
mkdir /data/local/mnt
fi
export HOME=/root
export USER=root
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
mount -o loop,noatime -t ext2 $1 /data/local/mnt
sleep 3
mount -t proc proc /data/local/mnt/proc
mount -t devpts devpts /data/local/mnt/dev/pts
chroot /data/local/mnt /bin/bash
/mnt/sdcard/ubuntu/stop
#!/bin/bash
#Created by Armin Coralic http://blog.coralic.nl
umount /data/local/mnt/dev/pts
umount /data/local/mnt/proc
umount /data/local/mnt
After running the start script, I get an ubuntu chrooted shell, but I do not have access to my external storage SD card from within the chroot.
I would like to know the answer for the following two questions:
1) what is the /dev/block/ device file name for the external SD card
which I should mount on a Samsung
Galaxy S I9000?
2) what is the exact syntax that I should use before/after entering
chroot to get read/write/execute
access to the external SD storage?
It would be helpful if the start/stop scripts could be modified with the required changes.
You can check the block devices by running ls in /dev/block/
But actually, there are multiple ways to address the devices, for instance through vold, or sys etc.
you might check a file cald vold.fstab, it should give you an idea of which device is your external SD car