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>
Related
Hi all,
im working on making a ROM for the Asus Transformer and im struggling a bit. im totall new to Linux, using mint and just getting used to it.
Basically im just trying to take a stock ROM and add root but adding superuser.apk and SU binary but im running into problems.
Asus Roms are a bit unusual, packed into blob files, ive unpacked that no problem, the system image is called blob.APP but its just the same as system.img just the name as i understand it.
ok so what ive done:
Code:
mkdir system
sudo mount -t ext4 -o loop blob.APP system/
so this mounts the ext4 fs as a loop device and allows me to copy the contents out
Code:
sudo cp -ar system new_system
then ive copied superuser.apk to /app and SU binary to /dev with drop and drag.
then make the filesystem image
Code:
sudo ./make_ext4fs -l 512m -a system blob.APP new_system/system
then just pack it up and flash it, flashing works fine, no errors but when i go to reboot it warns that theres no OS so somethings not worked. ive tried everything i can find googeling!
i just started learning linux on weds so go easy on me
any advice or help would be really great. thanks!
mkdir system here you will mount the old system
mkdir system_new here you will mount the new system
we now create the actual image
dd if=/dev/zero of=system_new.img bs=4k count=60000
bs=4k is the block size
count=60000 the number of blocks of 4kb size
so is something like 60000*4= 240000 which is actually 240 Mb
so it depends to you how big you want the image.
now we format the system.img in ext4
mkfs.ext4 system_new.img
Proceed anyway? (y,n) y
now we override the filesystem check
tune2fs -c0 -i0 system_new.img
Now we mount the the 2 directories that we created in the first step
mount -o loop system_new.img system_new/
mount -o loop system_new.img system/
Now we copy the contet of the old image to the new one with all the perimissions
cp -v -r -p system/* system_new/
We sinc the files
sync
We unmount the partitions
umount system_new/
umount system/
And voila, the system.img in ext4 is created.
Tips: you will need superuser acces.
if you will copy new files besides the ones from the old system you will have to set by hand all the permissions.
If you are using ubuntu just type
sudo su
and you will be root and no more sudo at each command.
Thank u so much for your guide this is exactly what I'm looking for so massive thanks!
So to add root I.can drop and drag superuser.apk and the binary into the new image?
Also do I need to worry about the android mountpoint?
Sent from my HTC Sensation Z710e using xda premium
yes you can do that, as long as you set the permissions right. (you can google for them)
and from what i remeber you will have to set also the ownership of the su, and superusers files
you need to do tests first, and then try
the mountpoint should be ok as it is now.
globula_neagra said:
mkdir system here you will mount the old system
mkdir system_new here you will mount the new system
we now create the actual image
dd if=/dev/zero of=system_new.img bs=4k count=60000
bs=4k is the block size
count=60000 the number of blocks of 4kb size
so is something like 60000*4= 240000 which is actually 240 Mb
so it depends to you how big you want the image.
now we format the system.img in ext4
mkfs.ext4 system_new.img
Proceed anyway? (y,n) y
now we override the filesystem check
tune2fs -c0 -i0 system_new.img
Now we mount the the 2 directories that we created in the first step
mount -o loop system_new.img system_new/
mount -o loop system_new.img system/
Now we copy the contet of the old image to the new one with all the perimissions
cp -v -r -p system/* system_new/
We sinc the files
sync
We unmount the partitions
umount system_new/
umount system/
And voila, the system.img in ext4 is created.
Tips: you will need superuser acces.
if you will copy new files besides the ones from the old system you will have to set by hand all the permissions.
If you are using ubuntu just type
sudo su
and you will be root and no more sudo at each command.
Click to expand...
Click to collapse
U said, we have to set permissions by ourselves. So what are the permissions that needs to be set when I add a new folder with an APK in it?
Sudo chmod 777 filepath/filename.apk
Sudo chmod a-rwx filepatch/filename.apk.
This is what I remember from top of my head. Google it a bit if it does not work from the first try as I have not used this like in 5 years.
If you allready have root you can you a file manager and just copy the file/folder where you want and set the permissions via thw file manager or using terminal commanda or via adb.
From what remember you can t make a folder in the apk folder as you won t be able to run the apk.
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?
This guide is intended for those who own 16G MI3W which, sadly, often doesn't have enough space to make nandroid backup. This tutorial will show you how you can make nandroid backup directly to your PC and restore it later. Entire procedure will not store any single byte to your phone's internal memory.
Great part of this tutorial (and the whole idea) is taken from scandiun's thread, so some credits go to him.
WAS IT NECESSARY?
As we know, this operation (backup and restore) can, sort of, be done using adb backup command. But this command leaves out sms messages, call logs and some other information. So, backup made with adb backup may not be full, and does not reflect phone's current state.
REQUIREMENTS
This tutorial requires you to have:
ClockworkMod custom recovery installed on your phone
BusyBox installed into /system/xbin directory (your device probably already has it there). But you can check it or install it using this application (requires root).
Linux machine or MS Windows. I recommend linux, but if you're using Windows, please install Cygwin with netcat (nc), pv and util-linux (you can select those binaries in Cygwin setup).
Adb installed into some PATH directory. For windows, adb executable could be put into Windows directory (eg. C:\Windows). For linux, you can use command shown here to install adb, which will automatically put adb into your PATH directory.
Let's get down to business!
Whole philosophy lies behind opening some port on your device, over which will /data, /system or /cache partition be transfered from MI3 to PC's hard drive. Data is also being compressed/decompressed on the fly, so backup size is reduced. You can also see transfer speeds and total amount of data transfered.
Process is tested and it works!
BACKUP
To initiate a backup, we first have to run ADB. Connect USB cable to your phone. Then boot your device into recovery and select system 1. After that, go into Storage and mounts and mount /data, /cache and /system.
Finally, open Cygwin/linux shell and type the following:
Code:
adb kill-server
sudo adb start-server
adb forward tcp:1234 tcp:1234
adb shell
Then open another Cygwin/linux shell and create and enter directory which will hold MI3 backup. I called my directory mibackup.
Code:
mkdir ~/mibackup
cd ~/mibackup
You can see that we are working here with two consoles. First console will always represent phone's memory, and second will always represent our PC.
We will backup total of three partitions: /data, /cache and /system. That is essentially everything you need.
/system holds android system, and /data partition holds internal storage, applications, dalvik-cache and every other data including SMS messages, etc. But be prepared, because backup of this data partition can take up to 12,5GB of PC's hard drive space. It is usually lower because of compression, but just so you know. /system partition can take up to around 600MB, and is also usually lower than that.
/data partition (without internal storage)
Whole backup procedure of /data partition relies on few simple commands. Type this command in your first console, where adb shell is run:
Code:
cd /system/xbin
./busybox tar -pcf - /data --exclude='data/media/0' | ./busybox nc -l -p 1234
And then type command below into another shell:
Code:
nc localhost 1234 | pv -i 0.5 | gzip -c > data.gz
This will start backup process. As you may have noticed, this will backup our /data partition, but without internal storage (internal SD card).
Internal storage backup
After backup is complete, we can also backup our phone's storage (a.k.a. internal SD card), using following commands.
Type these commands in first console:
Code:
cd /system/xbin
./busybox tar -pcf - /data/media/0 | ./busybox nc -l -p 1234
and this command into second console:
Code:
nc localhost 1234 | pv -i 0.5 | gzip -c > sdcard.gz
/cache partition
Cache partition does not hold any important data. But I've noticed that when I wiped it, my current theme reset! This partition can be backed up in a matter of seconds, so why wouldn't we give it a try?
Type these commands in first console:
Code:
cd /system/xbin
./busybox tar -pcf - /cache | ./busybox nc -l -p 1234
and this command into second console:
Code:
nc localhost 1234 | pv -i 0.5 | gzip -c > cache.gz
/system partition
Finally, we can backup our /system partition. But, because BusyBox is located in /system, and we do not want to use this partition while it's in backup/restore phase, we have to copy xbin directory (busybox) to internal SD card.
Type these commands in your first console:
Code:
cp -R /system/xbin /data/media/0
cd /data/media/0/xbin
./busybox tar -pcf - /system | ./busybox nc -l -p 1234
and this command into second console:
Code:
nc localhost 1234 | pv -i 0.5 | gzip -c > system.gz
After the process is done, type following commands in first console to clean up xbin directory from internal storage, and to close adb.
Code:
cd /
rm -rf /data/media/0/xbin
exit
adb kill-server
And you have just created backup of your phone, into chosen directory. Congratulations!
Backup is in this case made of four files: data.gz, sdcard.gz, cache.gz and system.gz.
RESTORE
Before each restore procedure, we should wipe partition we are going to restore. So be careful! It is also important to check if /data, /cache and /system are mounted after each wipe/format.
To prepare things for restoration, open console and type in:
Code:
adb kill-server
sudo adb usb
adb forward tcp:1234 tcp:1234
adb shell
Then open another terminal, and go into directory where backups are stored. When I showed you how to create backup, I used mibackup directory. So, let's go into that directory once again, so we can pull our backups from there.
Code:
cd ~/mibackup
/data partition (doesn't contain internal storage)
If you are going to restore /data and /sdcard, then go to mounts and storage, and choose the last option - format /data and /data/media.
If you are going to restore only phone's data (and not /sdcard), select wipe data/factory reset from CWM menu. Don't skip this step! After that, make sure that /system and /data partitions are mounted.
To restore data partition then, type this commands into first console:
Code:
cd /
/system/xbin/busybox nc -l -p 1234 | tar -px
and this command into second:
Code:
gunzip -ck data.gz | pv -i 0.5 | nc localhost 1234
Internal storage
Make sure that /system and /data are mounted.
If you just restored /data partition, you don't have to wipe/format anything. Otherwise, if you just want to restore your internal SD card, you can type following command into first console, to wipe it first:
Code:
cd /
rm -rf /data/media/0/*
Type these commands into first console to restore your internal SD card (if you've backed it up):
Code:
cd /
/system/xbin/busybox nc -l -p 1234 | tar -px
and this command into second one:
Code:
gunzip -ck sdcard.gz | pv -i 0.5 | nc localhost 1234
/cache partition
Make sure that /system and /cache are mounted, and then format /cache from CWM.
/cache partition will be restored just as fast as it was backed up.
Type these commands into first console:
Code:
cd /
/system/xbin/busybox nc -l -p 1234 | tar -px
and this command into second console:
Code:
gunzip -ck cache.gz | pv -i 0.5 | nc localhost 1234
/system partition
After process is finished, we can restore system partition in a similar fashion we did when we backed it up. Just make sure that /system and /data are mounted, and then format /system from CWM.
Type this commands into first console:
Code:
cp -R /system/xbin /data/media/0
cd /
/data/media/0/xbin/busybox nc -l -p 1234 | tar -px
And this command into second one:
Code:
gunzip -ck system.gz | pv -i 0.5 | nc localhost 1234
After that, we just have to do some housekeeping jobs:
Code:
cd /
rm -rf /data/media/0/xbin
exit
adb kill-server
And last, but not least, if you haven't restored /cache partition, you should format it from CWM recovery.
That's it!
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
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.