My adoptable SD-card took a crap.
I'd like to think that I can recover the password/key (with a rooted phone), use ddrescue to make an image of the card, use the password/key to decrypt the image of the card, use fsck to fix the file-system (it's ext4, right?) then copy the repaired image back to the card and have a nice day.
Or maybe there's way to fsck the card in the phone? (after making a backup image)
Is this possible? Is there another way to un-screw a corrupted SD-card that's used as adoptable storage?
go vegan said:
My adoptable SD-card took a crap.
I'd like to think that I can recover the password/key (with a rooted phone), use ddrescue to make an image of the card, use the password/key to decrypt the image of the card, use fsck to fix the file-system (it's ext4, right?) then copy the repaired image back to the card and have a nice day.
Or maybe there's way to fsck the card in the phone? (after making a backup image)
Is this possible? Is there another way to un-screw a corrupted SD-card that's used as adoptable storage?
Click to expand...
Click to collapse
If you're trying to fix it so that it works "as-is" again, I wouldn't put too much faith in that.
You can recover the data on the sdcard by various methods, there are many methods and tools, such as these:
http://www.rescuedigitalmedia.com/retrieve-files-from-sd-card-formatted-as-internal-storage
There are more in depth and technical methods/tools also.
Once you have your data safely recovered, format the card and try replacing your data and setting up adoptable storage again the way you did originally.
Sent from my LGL84VL using Tapatalk
Using this as a guide for key recovery and data decryption - https://nelenkov.blogspot.com/2015/06/decrypting-android-m-adopted-storage.html
1- Make a backup of the card
Code:
ddrescue -n /dev/sdc bad-card.img bad-card.log
ddrescue completed in one pass with zero errors. Nice. From here, I'm working with a BACKUP of the card, NOT the card itself.
2- See what's on the card
Code:
fdisk -l bad-card.img
Output:
Code:
Disk bad-card.img: 120.3 GiB, 129116405760 bytes, 252180480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Device Start End Sectors Size Type
bad-card.img1 2048 34815 32768 16M unknown
bad-card.img2 34816 252180446 252145631 120.2G unknown
3- Copy the 2nd partition to a file
Code:
dd bs=512 skip=34816 if=bad-card.img of=bad-card-p2.img
* Your numbers may be different
4- Using the encryption key I found using the link, above, mount (read-only) this (2nd) copy of the card
Code:
losetup -r -f --show bad-card-fs-p2.img
cryptsetup luksOpen /dev/loop0 bad-card-fs-p2.img
dmsetup create crypt1 --table "0 252145631 crypt aes-cbc-essiv:sha256 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0 /dev/loop0 0"
mkdir /tmp/mount1
mount -o ro -t ext4 /dev/dm-4 /tmp/mount1
* Your numbers may be different
nb, the "4" in "/dev/dm-4" can be identified by the minor device-number here:
Code:
dmsetup info crypt1
Name: crypt1
State: ACTIVE
Read Ahead: 256
Tables present: LIVE
Open count: 1
Event number: 0
Major, minor: 252, 4
Number of targets: 1
Boom! My files are there!
From here, I used dd to make an unencrypted copy (as a disk-image file) and ran fsck on it. It fixed a few things, apparently nothing catastrophic.
Yeah, recovering pictures and music and that stuff wasn't too bad (since the device is rooted and I was able to recover the encryption key) but getting back the apps and getting the phone back to the state it was in a few hours earlier is not so straightforward.
Lesson learned: Keep a backup copy of the encryption key (in a safe place) so that data can be recovered from an "adopted" SD-card even if the phone gets smashed by a rock.
Too bad there isn't a way to do a "bare metal" backup of an android.
go vegan said:
Using this as a guide for key recovery and data decryption - https://nelenkov.blogspot.com/2015/06/decrypting-android-m-adopted-storage.html
1- Make a backup of the card
Code:
ddrescue -n /dev/sdc bad-card.img bad-card.log
ddrescue completed in one pass with zero errors. Nice. From here, I'm working with a BACKUP of the card, NOT the card itself.
2- See what's on the card
Code:
fdisk -l bad-card.img
Output:
Code:
Disk bad-card.img: 120.3 GiB, 129116405760 bytes, 252180480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Device Start End Sectors Size Type
bad-card.img1 2048 34815 32768 16M unknown
bad-card.img2 34816 252180446 252145631 120.2G unknown
3- Copy the 2nd partition to a file
Code:
dd bs=512 skip=34816 if=bad-card.img of=bad-card-p2.img
* Your numbers may be different
4- Using the encryption key I found using the link, above, mount (read-only) this (2nd) copy of the card
Code:
losetup -r -f --show bad-card-fs-p2.img
cryptsetup luksOpen /dev/loop0 bad-card-fs-p2.img
dmsetup create crypt1 --table "0 252145631 crypt aes-cbc-essiv:sha256 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0 /dev/loop0 0"
mkdir /tmp/mount1
mount -o ro -t ext4 /dev/dm-4 /tmp/mount1
* Your numbers may be different
nb, the "4" in "/dev/dm-4" can be identified by the minor device-number here:
Code:
dmsetup info crypt1
Name: crypt1
State: ACTIVE
Read Ahead: 256
Tables present: LIVE
Open count: 1
Event number: 0
Major, minor: 252, 4
Number of targets: 1
Boom! My files are there!
From here, I used dd to make an unencrypted copy (as a disk-image file) and ran fsck on it. It fixed a few things, apparently nothing catastrophic.
Yeah, recovering pictures and music and that stuff wasn't too bad (since the device is rooted and I was able to recover the encryption key) but getting back the apps and getting the phone back to the state it was in a few hours earlier is not so straightforward.
Lesson learned: Keep a backup copy of the encryption key (in a safe place) so that data can be recovered from an "adopted" SD-card even if the phone gets smashed by a rock.
Too bad there isn't a way to do a "bare metal" backup of an android.
Click to expand...
Click to collapse
Very nice.
Sent from my LGL84VL using Tapatalk
Same thing happened again. I knew I'd left a how-to here, so using this as a guide I fixed it much quicker, this time.
1- Power-down and remove the "corrupt" SD-card.
2- Use ddrescue to make a backup copy of the card
Code:
ddrescue -n /dev/sdg bad-card.img bad-card.log
That ran with no errors.
3- While that was backing up, I booted into TWRP and copied expand_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.key to a flash drive via OTG. That's "/data/misc/vold/expand_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.key", as per - https://nelenkov.blogspot.com/2015/06/decrypting-android-m-adopted-storage.html
4- After ddrescue was finished, I decrypted the SD-card.
Code:
blockdev --getsize /dev/sdg2
249702367
od -t x1 expand_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.key
0000000 yy yy yy yy yy yy yy yy yy yy yy yy yy yy yy yy
0000020
dmsetup create crypt1 --table "0 249702367 crypt aes-cbc-essiv:sha256 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 0 /dev/sdg2 0"
5- Find out what "crypt1" links to, and what it is.
Code:
file -s /dev/mapper/crypt1
/dev/mapper/crypt1: symbolic link to ../dm-5
file -s /dev/dm-5
/dev/dm-5: Linux rev 1.0 ext2 filesystem data, UUID=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa (extents) (large files)
6- fsck /dev/dm-5.
Code:
fsck /dev/dm-5
fsck from util-linux 2.27.1
e2fsck 1.42.13 (17-May-2015)
/dev/mapper/crypt1: clean, 14314/7806976 files, 21089519/31212795 blocks (check after next mount)
7 - "Remove" the SD-card.
Code:
dmsetup remove crypt1
8- Put the card back in the Android, and it's all good.
nb - Turned out that I didn't need a copy of the card, but it's still good practice to make a backup.
go vegan said:
My adoptable SD-card took a crap.
I'd like to think that I can recover the password/key (with a rooted phone), use ddrescue to make an image of the card, use the password/key to decrypt the image of the card, use fsck to fix the file-system (it's ext4, right?) then copy the repaired image back to the card and have a nice day.
Or maybe there's way to fsck the card in the phone? (after making a backup image)
Is this possible? Is there another way to un-screw a corrupted SD-card that's used as adoptable storage?
Click to expand...
Click to collapse
You are going to big trouble if the card is not recovered.
nyckwilliams said:
You are going to big trouble if the card is not recovered.
Click to expand...
Click to collapse
Did you even read the thread? This member not only posted how they solved the issue but has had to do it twice and posted about it a second time just above the post you made.
Learn to read more than just the first few posts or first few pages of a thread.
Sent from my LGL84VL using Tapatalk
Note to self (and everyone else who finds this) to make it easier to work with image-files from SD-cards. Make use of losetup's "-P" flag to automatically create partitions.
Code:
losetup -r -f --show [B]-P[/B] bad-card.img
/dev/loop0
ls -lh /dev/loop*
brw-rw---- 1 root disk 7, 0 Aug 30 09:31 /dev/loop0
brw-rw---- 1 root disk 259, 0 Aug 30 09:31 /dev/loop0p1
brw-rw---- 1 root disk 259, 1 Aug 30 09:31 /dev/loop0p2
...
Now, the partition of interest is set up as "/dev/loop0p2" with minimum fuss.
Easy, sure and fast solution!
Hello everyone!
I'm going to give you a wonderful news!
You do not need to follow these complicated instructions that are still useful to know in case of need and thanks for this.
The solution is much easy and that's it:
Without turning off the smartphone, remove the micro SD card and reinsert it again.
That's all!
This solves your problem!
Good Android to everyone.
Android 8.1 with Lineage OS on Samsung Galaxy S5 klte and micro SD 128 GB extreme SanDisk A2 U3 V30
Future Technation said:
Without turning off the smartphone, remove the micro SD card and reinsert it again.
Click to expand...
Click to collapse
1- First, make a backup.
2- Good luck.
3- Does that work if the SD card was not unmounted/ejected properly, and the file-system is marked dirty?
go vegan said:
1- First, make a backup.
2- Good luck.
3- Does that work if the SD card was not unmounted/ejected properly, and the file-system is marked dirty?
Click to expand...
Click to collapse
Hello Vegan,
the problem mentioned is created precisely because the system has failed to mount the micro SD and identifies it as corrupt, but it is not really so.
Simply the system has not mounted it and is therefore inaccessible! (Of course, at this stage everyone takes the panic for their data :crying: ).
In my specific case the micro SD is the main memory and obviously also has all the data.
Since it is not yet mounted in the system (due to a reading error), you can not back up your data on the micro SD card.
Furthermore, since it has not yet been mounted (due to a reading error), it can be safely removed and reinserted without restarting the smartphone.
Once this is done, everything is fine.
I hope I was clear in the explanation.
Future Technation said:
Hello everyone!
I'm going to give you a wonderful news!
You do not need to follow these complicated instructions that are still useful to know in case of need and thanks for this.
The solution is much easy and that's it:
Without turning off the smartphone, remove the micro SD card and reinsert it again.
That's all!
This solves your problem!
Good Android to everyone.
Android 8.1 with Lineage OS on Samsung Galaxy S5 klte and micro SD 128 GB extreme SanDisk A2 U3 V30
Click to expand...
Click to collapse
I'm not sure this applies to the specific situation that the OP posted about.
Sent from my LGL84VL using Tapatalk
In my case, the file-system was marked "dirty" and thus could not be mounted by the OS until after it was fsck'd.
Droidriven said:
I'm not sure this applies to the specific situation that the OP posted about.
Sent from my LGL84VL using Tapatalk
Click to expand...
Click to collapse
Hi Droidriven,
it's exactly the same situation, I confirm it.
---------- Post added at 12:02 PM ---------- Previous post was at 11:06 AM ----------
go vegan said:
In my case, the file-system was marked "dirty" and thus could not be mounted by the OS until after it was fsck'd.
Click to expand...
Click to collapse
Hi Vegan,
I had exactly the same problem, the filesystem was corrupt, I explained it well on my post. The micro SD works only after removal and re-insertion. There is no need for check disk. What you did was your option and choice, but in this specific case it is not necessary. You probably did not do as I described but you immediately removed the SD card for a check disk. This post can help many people. Why complicate things when the solution is so easy? Less experienced people can panic. Our job is to help and simplify the work, not to complicate it. However, I'm sure you did your best to solve your problem, but this solution has to admit that it's much easier for everyone.
Have a nice day.
Future Technation said:
Hi Droidriven,
it's exactly the same situation, I confirm it.
---------- Post added at 12:02 PM ---------- Previous post was at 11:06 AM ----------
Hi Vegan,
I had exactly the same problem, the filesystem was corrupt, I explained it well on my post. The micro SD works only after removal and re-insertion. There is no need for check disk. What you did was your option and choice, but in this specific case it is not necessary. You probably did not do as I described but you immediately removed the SD card for a check disk. This post can help many people. Why complicate things when the solution is so easy? Less experienced people can panic. Our job is to help and simplify the work, not to complicate it. However, I'm sure you did your best to solve your problem, but this solution has to admit that it's much easier for everyone.
Have a nice day.
Click to expand...
Click to collapse
Well...
You see...
I'm willing to bet that they tried that first, since it IS the first and simplest troubleshooting step for the scenario, even a noob would know to try that and they seem to be a bit more advanced than a noob. You post as if they did not try that kindergarten level troubleshooting step first, which I'm sure they probably did. But I could be wrong.
Sent from my LGL84VL using Tapatalk
Droidriven said:
Well...
You see...
I'm willing to bet that they tried that first, since it IS the first and simplest troubleshooting step for the scenario, even a noob would know to try that and they seem to be a bit more advanced than a noob. You post as if they did not try that kindergarten level troubleshooting step first, which I'm sure they probably did. But I could be wrong.
Click to expand...
Click to collapse
Hi Droidriven,
This proves that he did not do it.
go vegan said:
In my case, the file-system was marked "dirty" and thus could not be mounted by the OS until after it was fsck'd.
Click to expand...
Click to collapse
The fear factor can always affect one's choices.
Please, review my posts well, I gave a technical and exhaustive explanation of what happened and why I did it that way.
In any case my solution is valid and working. Those who present the same problem can take advantage of this information.
Have a nice day!
Future Technation said:
Hi Droidriven,
This proves that he did not do it.
The fear factor can always affect one's choices.
Please, review my posts well, I gave a technical and exhaustive explanation of what happened and why I did it that way.
In any case my solution is valid and working. Those who present the same problem can take advantage of this information.
Have a nice day!
Click to expand...
Click to collapse
That doesn't prove that they didn't remove and reinsert the sdcard, though. That just proves that their sdcard wasn't working. Nothing in what they posted says that they didn't remove and re-insert the sdcard, you're assuming they didn't because removing and reinserting worked for you. This assumes that their sdcard was "corrupted" for the same reason that yours was and in the same way.
I'm not disagreeing that your method worked for you, I'm just saying that your scenario and their scenario are not necessarily the same.
Sent from my LGL84VL using Tapatalk
Droidriven said:
That doesn't prove that they didn't remove and reinsert the sdcard, though. That just proves that their sdcard wasn't working. Nothing in what they posted says that they didn't remove and re-insert the sdcard, you're assuming they didn't because removing and reinserting worked for you. This assumes that their sdcard was "corrupted" for the same reason that yours was and in the same way.
I'm not disagreeing that your method worked for you, I'm just saying that your scenario and their scenario are not necessarily the same.
Click to expand...
Click to collapse
Excuse me but how old are you? You are a child? This would explain all these controversies. You always want to have the reason anyway. Even if you were an adult, you behave like a child! I have no time to waste with you, but willingly with those who really need to solve the same problem! Those who are truly experts will appreciate this solution. You are spamming here. I will not answer you again. Goodbye!
--------------------------------------------------------------------------------
Hi Go Vegan,
I want to apologize with you for this little discussion, because I started quoting you. My intent is always to share something useful for others. Thank you for your intervention, because obviously if my first approach to this problem does not work for someone, yours becomes indispensable, as obviously it has already been certainly for many others.
This words are for everyone: "We must learn to really listen to others before answering".
Have a nice day!
Might also depend on the phone, the ROM, the version, etc. Might also depend on whether the card is "internal" or "external" storage.
Future Technation said:
Excuse me but how old are you? You are a child? This would explain all these controversies. You always want to have the reason anyway. Even if you were an adult, you behave like a child! I have no time to waste with you, but willingly with those who really need to solve the same problem! Those who are truly experts will appreciate this solution. You are spamming here. I will not answer you again. Goodbye!
--------------------------------------------------------------------------------
Hi Go Vegan,
I want to apologize with you for this little discussion, because I started quoting you. My intent is always to share something useful for others. Thank you for your intervention, because obviously if my first approach to this problem does not work for someone, yours becomes indispensable, as obviously it has already been certainly for many others.
This words are for everyone: "We must learn to really listen to others before answering".
Have a nice day!
Click to expand...
Click to collapse
Actually, with the way you are defending yourself when I'm just telling you the truth, that makes you appear as the child.
You have only 5 posts here and just joined a few days ago. This tells me that you probably haven't dealt with android devices enough to know there can be many different causes for the exact same issue, even on two identical devices that show the same symptoms and that what works in "this" situation on "that" device, doesn't always work the same for another device with the exact same issues.
I was just saying that there are many different details that make all the difference in the world. It's obvious, from everything that you have posted here, that you are unaware of those facts. I was just trying to tell you that you can't be so certain that what you posted is the fix for every user and every device that has this issue. Dont take it so personal.
Sent from my LGL84VL using Tapatalk
Related
!!!OBSOLETE!!! 2009-11-26: This script was very useful in the beginning, but is now obsolete. There are superior methods such as sdparted using better tools, and this script likely no longer works properly on modern builds.
As the title says, this script will repartition your sdcard so that you will have a FAT and an EXT2 partition. This is particularly useful for running apps off of the sdcard.
The app is called sdsplit, it has a strong focus on error prevention and recovery. Use at your own risk and please do let me know if you have any problems. As partitioning your card is inherently risky (especially if you are trying to preserve data from it), this script may help backup your data and any system config scripts which it modifies.
Instead of describing all of the features of the script, I will simply post the help message here since I spent a lot of time trying to make it comprehensive. The design of the script tries to make it easy for you to understand where a failure occurs if one does, and to pick up where you may have left off due to the failure after you work around it.
See the HowTo for Dummies for exact steps, but here is the general idea:
* Download sdsplit to your phone and give it execute permissions.
* Run script as root
* Do not run it from a subdirectory of /sdcard
* Run it with as few applications running as possible (to avoid having files open on the sdcard.)
The script logs its output to /data/sdsplit.log, please post the relevant bits from here if you encounter a problem and want help. But first, check out the FAQ for answers to most questions!!!
Code:
# sdsplit --help
Usage(v1.7): sdsplit [options]
'sdsplit' will by default perform all of its default actions in sequence. Specifying a
specific action will tell sdsplit to only perform that action and skip the others. You
may instead prefix an action with 'no' to prevent that specific action from being
performed while all the others are run. For debugging purposes, all output of sdsplit
will be logged (appended) to /data/sdsplit.log
PREREQUISITES:
* This is desgined to work with the Jesus Freke updates (tested on JF1.43ADP/JF1.5).
Here is why you need a JF update: for busybox, DNS, so the /init.rc invokes /system/init.rc,
and so the ext2.ko module is under /system/modules/2.6.27-00392-g8312baf/kernel/fs/ext2.
* If you are making a FAT partition greater than 2GB and have a pre1.5 android
environment, you will likely need a new 'mkdosfs' executable or internet access
from your phone so that sdsplit can download and install it for you. If a capable
mkdosfs is not found somewhere in your path (or where specified by --pmkdosfs),
sdsplit will attempt to download and install it for you from my repo. This executable
came from a Haykuro 1.5 build.
* Additionally, you will need a 'mke2fs' executable for arm-eabi or internet access
from your phone so that sdsplit can download and install it for you. If mke2fs is
not found somewhere in your path (or where specified by --pmke2fs), sdsplit will
attempt to download and install it for you from my repo. I got this executable from
here: http://sites.google.com/site/juanjosec/android
ACTIONS:
--backup|-b Perform a backup of the /sdcard directory to /data/sdcard
--nobackup|-nb (See --pbackup)
--config|-c Configure the system to handle a new ext2 partition on the
--noconfig|-nc sdcard. This involves adding mount options to /system/init.rc and
to /system/etc/mountd.conf along with creating the /system/sd mount
point for the ext2 partition on (see --pext2). Backups of the
original files will be made (.orig). You should use this for
a JF1.5 build.
--partition|-p Wipe the partition table of the sdcard and create two new
--nopartition|-np partitions, first a 500M FAT32 one (see --fatsize) and then
a Liunx one (for EXT2) on the remainder of the sdcard (see --ext2size).
--mkfs|-mk Make the FAT32 (see --fat[16|32]) and EXT2 filesystems. (partitioning
--nomkfs|-nm only allocates the space for them). This requires the mke2fs
exectuable on the G1/ADP (see --pmke2fs).
--restore|-r Restore the original sdcard backup from /data/sdcard back to /sdcard
--norestore|-nr
Along with the above actions there is one additional action if you do not care to
save your original sdcard data:
--nodata|-nd Equivalent to: --nobackup --norestore
OPTIONS:
-h|--help Usage (short) | Help (this)
--forces|-f Force exectution without prompting up front
--forcemkfs|-fm Force even if the mke2fs executable cannot be found and/or
if the mkdosfs executable is not suitable for large
partitions.
--forceumount|-fu Force even if partition already mounted at /system/sd.
Use with care, if you have an already existing EXT2
partition this will delete everything on it!!
--fatsize|-fs SIZE[KM] Set the size of the FAT partition in bytes, K or M.
(defaults to 500M)
--ext2size|-es SIZE[KM] Set the size of the EXT2 partition in bytes, K or M.
(default to the remainder) If you set this, it will not
set the FAT parition to the remainder, it will remain
500M unless you explicitly set it to something else.
The only reason to use this is if you want to leave space
for another partition.
--fat[16|32] Make the FAT partition of type 16 or 32. The default is
32 since 16 does not seem to work with my ADP.
--pbackup|-pb PATH Set the location of the sdcard backup dir.
--pmke2fs|-pme PATH Set the path to the mke2fs executable (if not already in
your PATH.)
--pmkdosfs|-pmd PATH Set the path to the mkdosfs executable (if not already in
your PATH.)
--pext2|-pe PATH Set the mount point for the new ext2 partition (defaults
to /system/sd)
COPYRIGHT: Martin Fick <[email protected]> GNU GPL2 or above
ChangeLog:
v1.7 2009-05-10 (usability improvements)
* Prompt on startup (confirm requested actions), use -f to override.
* Log invocation string to sdsplit.log
* Removed error when sdcard is empty
* If no ext2.ko is found output a message instead of an error.
more...
WOW i don't need the script since i have my card partitioned, but i didn't even know this was possible. i congratulate your efforts and hope that this works for everyone. would certainly help people that have bad computers or USB lower than 2.0 on their computers. i really don't know what to say, i am looking at the script right now and it's about 10 levels above my coding ability. great job on this
I was reluctant to try partitioning my SD card again after two failures, now I'll have to try this tomorrow. Thank you very much, MartinFick!
i was beginning to wonder why this hasn't been done before...
i applaud you in your efforts sir, ill be sure try this tomorrow.
thank you
Has anyone tried this yet? I already have mine set up but I'm dying to know.
This could make LucidREM's job easier too!
MartinFick said:
Well, here is my paltry contribution to the community. I spent entirely too much time on this! I hope it can help at least one person.
Click to expand...
Click to collapse
ok .. so maybe you DID spend entirely too much time but i would hardly call it paltry .. just skimming thru the code .. looks pretty nice .. i'm sure people will be happy to have the assistance
Great work MartinFick!!! I also have a partitioned card, but this is a great addition to the wonderful mods that already exsist in our community. I do hope it works and I'm sure it will help out many.
I refused an offer of $$$ to mod two phones (from root to apps on sd) because I lost the ability to use paragon (trial over), and "customers" not wanting to give their email address. Now that this may take care of that I might start doing it. I'll wait for reviews. Thanks again MartinFick!!!
Wow, I'm very impressed. Nice work.
So if I read this correctly. Using the following command would give me a 1gig EXT2 partion and the rest goes to FAT32?
sdsplit -es 1000[M]
I'm not ready to try it since I don't have my 8gig card yet, but Id be willing to give it a go.
Another question I notice it sets the default of the FAT to 500meg. Shouldn't that be the other way around? I mean if I dump tons of songs, videos and what not you would think that the majority of the card should be FAT to use it opposed to EXT2.
So if I read this correctly. Using the following command would give me a 1gig EXT2 partion and the rest goes to FAT32?
sdsplit -es 1000[M]
Click to expand...
Click to collapse
No, there is no simple way (that I know of) with fdisk to make the frist partition take a remainder of the disk, so that feature is only available to the second partition. Since the first partition (I believe) will need to be FAT for most hacks to work (and my script currently), that makes EXT2 the second one.
So you must figure out how big you want your FAT partition no matter what (default is 500M). The EXT2 partition can then either be the remainder of the disk or a smaller amount (if you later wanted a third partition.) If you have an 8G disk and you want only 1000M for the EXT2 partition, simply use:
Code:
sdsplit -fs 7000M
which will give you a 7G FAT and a remainder of 1G for the EXT2. Make sense? Since this was confusing, I will try to add a note about this.
Another question I notice it sets the default of the FAT to 500meg. Shouldn't that be the other way around? I mean if I dump tons of songs, videos and what not you would think that the majority of the card should be FAT to use it opposed to EXT2.
Click to expand...
Click to collapse
I guess that is probably a personal decision, I am not sure why we even need the FAT at all (except for interoperability with other devices)?
Due to the limitations that I explained in the first section, I could only hardcode a limit on the FAT partition, not the EXT2. And, since I figured that people with a 1G card would probably want at least 500M EXT2, I opted for the 500M FAT default.
If I figure out a clean way to specify the EXT2 size and let FAT be the remainder, I will consider your suggestion. I was basing the fact that FAT should be first on rules that I read in other threads (this is not an inherent disk partitioning limit). If someone could explain to me why (I assume other components in the android system expect this), perhaps this could be worked around? Another solution if FAT absolutely needs to be P1 and EXT2 P2, is to try and simply put P2 first on the partition (fdisk will usually let you do this.) This way, the EXT2 partition could be set to a fixed size and the FAT one could use the remainder (be second on disk,) but stay numbered P1. Anyone have any thoughts on that suggestion?
Awesome. So basically set the FAT and the EXT2 would set its self to the rest. I by no means was questioning why you did it the way you did it. I just didn't have a clue and it makes complete sense now.
Like I said I can't try this the 7th because the cards I ordered do not arrive until then.
Can somebody
Can somebody post a how to execute this coz i downloaded it and can't understand wat to do next
So if we do select 7GB for the first partition, it'll format it FAT32 correct? As FAT can't use that much space.
Bug Fix Release Update
I update the original post with v1.1 which has some bug fixes in it. The partitioning worked fine in the original script, but my repeated testing seems to have masked some bugs in the automounting of the new partition.
Can somebody post a how to execute this coz i downloaded it and can't understand wat to do next
Click to expand...
Click to collapse
While I am more confident about this version (more personal testing), I would be happier if someone who knew how to recover from potential disasters (someone knows how to use recovery mode) and with a basic linux understanding tried it first.
But, to answer your question, download the new one first (v1.1 which I uploaded after you posted your question), then save this file (perhaps remove the .txt extension) to somewhere in your path (/data/local/bin), and give it execute permissions: chmod 777 /data/local/bin/sdsplit and run it specifying the size of the FAT partition that you want (sample for a 1G FAT partition):
Code:
sdsplit -fs 1000M 2>&1 | tee /data/local/tmp/sdsplit.log
So if we do select 7GB for the first partition, it'll format it FAT32 correct? As FAT can't use that much space.
Click to expand...
Click to collapse
Regardless of size, it will format it as FAT 32 unless you specifically tell it to try FAT 16 (which did not seem to work for me)
MartinFick said:
But, to answer your question, download the new one first (v1.1 which I uploaded after you posted your question), then save this file (perhaps remove the .txt extension) to somewhere in your path (/data/local/bin), and give it execute permissions: chmod 777 /data/local/bin/sdsplit and run it specifying the size of the FAT partition that you want (sample for a 1G FAT partition):
Code:
sdsplit -fs 1000M 2>&1 | tee /data/local/tmp/sdsplit.log
Click to expand...
Click to collapse
Hmm, you need to simplify it further for simpletons like myself.
What we need is a step by step (and I mean step by step, i.e. every single thing you need to do to your phone no matter how obvious) guide on what to to from downloading the app, to ending up with a partitioned SD card.
So, e.g, I have an 8gb SD card, I have some data on that card, I wish to make a partition of 1gb for the EXT2 part, and 7gb for the FAT32. I also dont wish to lose my data.
Should I manually copy my data to my computer, then format the SD card and run the app, or is there a built in thing in the app to backup the SD card (on what though?) and allow you to transfer it back after the partition?
Some questions to clarify (which is why the step by step guide for idiots is needed):
1) do you download the app via the app store, and install it on the phone, or do you download the app onto your computer and transfer to your SD card via USB cable?
2) Do you need to change the file (you say you MAY want to remove the .txt. extension, that a yes or a no?)
3) save the file to somewhere in your path? What does that mean? and where exactly?
4) How do you give it 'execute' permissions? By typing in "chmod 777 /data/local/bin/sdsplit", where do you type this in?
5) are all of these instructions carried out in the command / dos type area of the phone, where you can type in these controls? I am assuming so.
These are just some of the things I do not understand (sorry for my ignorance), which is why we need someone to really clarify the whole process so even a monkey can follow it.
I hope someone has the time and inclination, since I am really pissed of with the android since I ran out of space on my internal memory, makes me want to throw the phone away.
Please be step-by-step specific please.
yeah i have the same questions as him ^^^^^
i have an 8 gig sd card. i want to have my EXT2 to have 800 MB and the rest FAT32. how much do i give the FAT32 portion?
First of all, THANK YOU! This is just what many people need. Great job on making it as simple as possible.
I too would second the request to give us a step by step directions on using this (ie press this button and then....(have to say this in Homer Sipmson's voice))
I could most likely figure it out myself but I don't want to take chances, especially since my card is alrealdy fomatted and works, I wouldn't mind changing the size of my partitions at some point but don't want to take risk of losing 110+ apps..
Once more, BIG THANKS for this piece, I'm sure a lot of people will use it.
Martin I just want to say thank you on behalf of the community.
I reset my phone this evening and tested this out on JF rc33. It's brilliant. You've done a great thing here.
I hope you don't mind but I've posted a how to over on the android section of nokia apps at the request of a few users! Of course i linked to this page and gave full credit!
Ok I finally got a large SDCARD and browsed through all the tutorials on here pertaining to moving apps to sdcard and they all were either windows centric or required that the android build environment be installed.
I don't use windows and I don't have the android build environment loaded. I DO have Linux and a rooted phone. So here goes
Partitioning your sdcard into fat32/linux
What you'll need:
1) linux terminal
2) a micro sd card reader that you can connect to your computer
3) fdisk
From a terminal window as root, plug your sdcard into your computer. You can not do this while the sdcard is mounted, you only want it to be given a device node by linux so we can edit the partitions via fdisk.
So once you have it on connected, check what the device name is. For me 'dmesg' told me the device nodes name was /dev/sdc .
So using good ol FDISK we do the following:
1) fdisk /dev/sdc
2) proceed to delete all the partitions
3) hit 'n' to create a new partition. This will be a primary partition as large as you want it. Be sure and remember to leave some space for the linux partition we'll be creating.
4) Next create the linux partition by once again pressing 'n' and choosing primary partition
5) now we need to fix the system labels for the fat32 partition by pressing 't'
Select partition 1 and change it to HEX code 'c' which is WIN95 FAT32 (LBA)
6) Now that you have both partitions created go ahead and write them by pressing 'w'
Now we need to write a filesystem to the partitions
So you've created the partitions but they are raw with no filesystem. We need to format them to their respective filesystems.
Assuming your device node for the sdcard is /dev/sdc you will have the following partition layout
Device Boot Start End Blocks Id System
/dev/sdc1 1 1816 14586988+ c W95 FAT32 (LBA)
/dev/sdc2 1817 1949 1068322+ 83 Linux
Of course your start/end blocks will be different if you don't have a 16gb microsd card like me.
First we'll format the fat32 partition using the following command
mkfs.vfat /dev/sdc1
Next we'll format the linux partition to ext2. I've noticed a lot of people talk about ext2 as if its a partition type, ITS NOT. It's a filesystem type. It should be worded "Creating a fat32 & linux partition" not "Creating a fat32 & ext2 partition". Anyways, moving along we use the following command to format the linux partition to ext2
mkfs.ext2 /dev/sdc2
You're now ready to proceed to following the other guides for moving apps to the sdcard. If enough people request I can finish this to include actually moving the /data/app to /system/sd . Not really much to it. Anyways enjoy
Nice tutorial, but one thing. You mentioned the difference between a file system and a partition. While that is correct, do you see that knowledge making things easier or harder for the average user? Lots of times we simplify things so we dont have to explain stuff that the user need not know later.
shafty023 said:
Next we'll format the linux partition to ext2. I've noticed a lot of people talk about ext2 as if its a partition type, ITS NOT. It's a filesystem type. It should be worded "Creating a fat32 & linux partition" not "Creating a fat32 & ext2 partition". Anyways, moving along we use the following command to format the linux partition to ext2
mkfs.ext2 /dev/sdc2
Click to expand...
Click to collapse
And fat32 is a file system type and not what you refer to as a partition type either, what is your point? You are creating an ext2 (formatted) partition and a fat32 (formatted) partition. Semantics aside, call one a dos partition and one a linux partition if that would make you happy, either way you are creating two separate partitions and formatting one as fat32 and the other as ext2. What you call them, or how you label the partition type vs. file system, doesn't make you any smarter than anyone else.
The fact that you would take the effort to point out that ext2 is not a partition type, yet neglecting to point out the same about fat32, kind of makes you seem ignorant. I may sound like a prick, but I have had a few drinks tonight, and seriously...... if you took the time to say "fat32 and linux partition", it really seems as if you are trying to make other people look stupid.
I leave you with some "light" reading.
And... file systems.
Darkrift said:
Nice tutorial, but one thing. You mentioned the difference between a file system and a partition. While that is correct, do you see that knowledge making things easier or harder for the average user? Lots of times we simplify things so we dont have to explain stuff that the user need not know later.
Click to expand...
Click to collapse
Oh I completely understand and agree. It's just in my line of work I find that there's still some people that want to know and learn about the gritty details of whats going on. I figured there's plenty of other articles on here explaining things for the simpleminded, I wanted to create one article that actually explained the correct terms. Didn't mean it in any way as a put down to anyone else's tutorials that were in laments terms.
daveid said:
And fat32 is a file system type and not what you refer to as a partition type either, what is your point? You are creating an ext2 (formatted) partition and a fat32 (formatted) partition. Semantics aside, call one a dos partition and one a linux partition if that would make you happy, either way you are creating two separate partitions and formatting one as fat32 and the other as ext2. What you call them, or how you label the partition type vs. file system, doesn't make you any smarter than anyone else.
The fact that you would take the effort to point out that ext2 is not a partition type, yet neglecting to point out the same about fat32, kind of makes you seem ignorant. I may sound like a prick, but I have had a few drinks tonight, and seriously...... if you took the time to say "fat32 and linux partition", it really seems as if you are trying to make other people look stupid.
Click to expand...
Click to collapse
Please take the time to read my previous reply. And the reason I pointed out ext2 was a filesystem type and not for fat32 was no matter where someone in windows tries and creates a partition, either thru disk management or partition magic, it will present them with the option of creating a pre-formatted partition. This means they can create a fat16/fat32/ntfs partition. I doubt anyone can create a 200gb dos partition though I've never tried so won't state that as a fact. I know fat32 within windows limits to 180, then other apps like partition magic are able to utilize more. Only using fdisk are you presented with the option of over 80 different un-formatted partition types. Even in there they list fat32 but do not list ext2 or ext3.
And did you ever stop to think that perhaps some people actually thought ext2 was a partition? That maybe they'd hop into their partitioning tools looking for ext2? Then they'd come back looking all over xda for information why they can't find ext2 as a valid partition? Then they come across my lonely tutorial that explains they need to first format as Linux and then FORMAT as ext2? Did you think about that whilst you were ranting on about me being a prick? No you didn't. I was only trying to help and provide information without bringing anyone else down. Now, let's move past this and do what we're all here to do and that's help those who don't understand these technologies.
daveid said:
And fat32 is a file system type and not what you refer to as a partition type either, what is your point? You are creating an ext2 (formatted) partition and a fat32 (formatted) partition. Semantics aside, call one a dos partition and one a linux partition if that would make you happy, either way you are creating two separate partitions and formatting one as fat32 and the other as ext2. What you call them, or how you label the partition type vs. file system, doesn't make you any smarter than anyone else.
The fact that you would take the effort to point out that ext2 is not a partition type, yet neglecting to point out the same about fat32, kind of makes you seem ignorant. I may sound like a prick, but I have had a few drinks tonight, and seriously...... if you took the time to say "fat32 and linux partition", it really seems as if you are trying to make other people look stupid.
Please take the time to read my previous reply. And the reason I pointed out ext2 was a filesystem type and not for fat32 was no matter where someone in windows tries and creates a partition, either thru disk management or partition magic, it will present them with the option of creating a pre-formatted partition. This means they can create a fat16/fat32/ntfs partition. I doubt anyone can create a 200gb dos partition though I've never tried so won't state that as a fact. I know fat32 within windows limits to 180, then other apps like partition magic are able to utilize more. Only using fdisk are you presented with the option of over 80 different un-formatted partition types. Even in there they list fat32 but do not list ext2 or ext3.
And did you ever stop to think that perhaps some people actually thought ext2 was a partition? That maybe they'd hop into their partitioning tools looking for ext2? Then they'd come back looking all over xda for information why they can't find ext2 as a valid partition? Then they come across my lonely tutorial that explains they need to first partition as Linux and then FORMAT as ext2? Did you think about that whilst you were ranting on about me being a prick? No you didn't. I was only trying to help and provide information without bringing anyone else down. Now, let's move past this and do what we're all here to do and that's help those who don't understand these technologies.
Click to expand...
Click to collapse
shafty023 said:
Please take the time to read my previous reply. And the reason I pointed out ext2 was a filesystem type and not for fat32 was no matter where someone in windows tries and creates a partition, either thru disk management or partition magic, it will present them with the option of creating a pre-formatted partition. This means they can create a fat16/fat32/ntfs partition. I doubt anyone can create a 200gb dos partition though I've never tried so won't state that as a fact. I know fat32 within windows limits to 180, then other apps like partition magic are able to utilize more. Only using fdisk are you presented with the option of over 80 different un-formatted partition types. Even in there they list fat32 but do not list ext2 or ext3.
And did you ever stop to think that perhaps some people actually thought ext2 was a partition? That maybe they'd hop into their partitioning tools looking for ext2? Then they'd come back looking all over xda for information why they can't find ext2 as a valid partition? Then they come across my lonely tutorial that explains they need to first partition as Linux and then FORMAT as ext2? Did you think about that whilst you were ranting on about me being a prick? No you didn't. I was only trying to help and provide information without bringing anyone else down. Now, let's move past this and do what we're all here to do and that's help those who don't understand these technologies.
Click to expand...
Click to collapse
for someone who has never really posted on XDA before you're being a little testy .. not to mention the fact that the guy never called you a prick .. all technicalities aside let's be civil here .. if we need an all out discussion on the differences of linux and dos then feel free to move on to another forum .. because honestly i haven't seen much know-how here on either front
i'm sure the moderators would agree that bickering about OS's wastes effort for everyone
LucidREM said:
for someone who has never really posted on XDA before you're being a little testy .. not to mention the fact that the guy never called you a prick .. all technicalities aside let's be civil here .. if we need an all out discussion on the differences of linux and dos then feel free to move on to another forum .. because honestly i haven't seen much know-how here on either front
i'm sure the moderators would agree that bickering about OS's wastes effort for everyone
Click to expand...
Click to collapse
Agreed. I post heavily on linuxquestions so given that Android's os is linux it made sense to help out on here wherever possible. I was a little stoned when I responded to his message, lol. But anyways if anyone else stumbles on this tutorial feel free to msg me with questions.
shafty..thanks so much.
btw.
i have a few questions.
when setting up my new g1, should i have added the linux partition on the SDcard. if my goal is to use this SDcard for rooting purposes...
which leads to another question (why in tarnation is there a fat32 card on my g1 ?)
btw..
heres some screenshots of the flow...if yall want em.
the write up is perfect and this is the only way i could add to it...
if its too convoluted, i can re-do it with only the terminal screenshots
please disregard the terminals on the right...on the left is the report after typing dmesg, and you can see df -h was not the best choice
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
this highlight reports the found SD cards location for fdisk, and the su command. (yes, i really do have a password)
3rd step (don't laugh..u do it too) i typed the "p" and missed the enter, than tried to fix it with backspace, and i think i missed the delete button too..but enter works regardless as fdisk only sees the 1st entry.
4th i accidentally made the sbc1 a fat 12, and deleted it , remade it w/n and it went dutifully from linux to fat32, and you can see here, that i have more space to fill the rest with linux.
the "p" is for print...i learned long ago to always print before continuing..
5th here it how the end result should be reported after "p" ( in fdisk)
6th, 7th this is the 2 lines to actually formatting commands (and results)
well...
i poked around in the g1, and the card was "unreadable", and asked to "format " it..
so, sure. i hit ok.."format"..it did
then i checked my eterm again.
heres what i got (thinking my pc is right...the formatting is gone.
or
am i just being to much....i shouldn't be poking around the sdcard when i should be rooting it....(think i just answered myself)
is this the 1st step to getting root on my g1 ?? (the vfat32 thing)
and what am i missing ?
or, HOW is fdisk NOT finding ANY type of filesystem AFTER the G1 formats....
does the G1 format an invisible (or new) type of filesytem ?
I think that those drinks went to your head. There are a plethora of different partition "types". In actual fact, a partition is a partition no matter how you look at it, but the different types are an identification byte which can be used to show what type of system/partition type is responsible for or expected to be found within the partition. It helps to keep retards (like mswindoze) on track.
According to the reference YOU provided, fat32 *IS* a partition type. This is true. It is ALSO a filesystem type. I.e., you place a fat32 FILESYSTEM within a fat32 PARTITION.
Here is the list of partition types for your reference:
0 Empty
1 FAT12
2 XENIX root
3 XENIX usr
4 FAT16 <32M
5 Extended
6 FAT16
7 HPFS/NTFS
8 AIX
9 AIX bootable
a OS/2 Boot Manag
b W95 FAT32
c W95 FAT32 (LBA)
e W95 FAT16 (LBA)
f W95 Ext'd (LBA)
10 OPUS
11 Hidden FAT12
12 Compaq diagnost
14 Hidden FAT16 <3
16 Hidden FAT16
17 Hidden HPFS/NTF
18 AST SmartSleep
1b Hidden W95 FAT3
1c Hidden W95 FAT3
1e Hidden W95 FAT1
24 NEC DOS
39 Plan 9
3c PartitionMagic
40 Venix 80286
41 PPC PReP Boot
42 SFS
4d QNX4.x
4e QNX4.x 2nd part
4f QNX4.x 3rd part
50 OnTrack DM
51 OnTrack DM6 Aux
52 CP/M
53 OnTrack DM6 Aux
54 OnTrackDM6
55 EZ-Drive
56 Golden Bow
5c Priam Edisk
61 SpeedStor
63 GNU HURD or Sys
64 Novell Netware
65 Novell Netware
70 DiskSecure Mult
75 PC/IX
80 Old Minix
81 Minix / old Lin
82 Linux swap / So
83 Linux
84 OS/2 hidden C:
85 Linux extended
86 NTFS volume set
87 NTFS volume set
88 Linux plaintext
8e Linux LVM
93 Amoeba
94 Amoeba BBT
9f BSD/OS
a0 IBM Thinkpad hi
a5 FreeBSD
a6 OpenBSD
a7 NeXTSTEP
a8 Darwin UFS
a9 NetBSD
ab Darwin boot
b7 BSDI fs
b8 BSDI swap
bb Boot Wizard hid
be Solaris boot
bf Solaris
c1 DRDOS/sec (FAT-
c4 DRDOS/sec (FAT-
c6 DRDOS/sec (FAT-
c7 Syrinx
da Non-FS data
db CP/M / CTOS / .
de Dell Utility
df BootIt
e1 DOS access
e3 DOS R/O
e4 SpeedStor
eb BeOS fs
ee GPT
ef EFI (FAT-12/16/
f0 Linux/PA-RISC b
f1 SpeedStor
f4 SpeedStor
f2 DOS secondary
fb VMware VMFS
fc VMware VMKCORE
fd Linux raid auto
fe LANstep
ff BBT
Click to expand...
Click to collapse
daveid said:
And fat32 is a file system type and not what you refer to as a partition type either, what is your point? You are creating an ext2 (formatted) partition and a fat32 (formatted) partition. Semantics aside, call one a dos partition and one a linux partition if that would make you happy, either way you are creating two separate partitions and formatting one as fat32 and the other as ext2. What you call them, or how you label the partition type vs. file system, doesn't make you any smarter than anyone else.
The fact that you would take the effort to point out that ext2 is not a partition type, yet neglecting to point out the same about fat32, kind of makes you seem ignorant. I may sound like a prick, but I have had a few drinks tonight, and seriously...... if you took the time to say "fat32 and linux partition", it really seems as if you are trying to make other people look stupid.
I leave you with some "light" reading.
And... file systems.
Click to expand...
Click to collapse
i just made a typo...11 is fat 12..
but thats not the point...
i got through fdish fine (always was fond of fdisk)
everything looks great until this last point.
after i makefilesystem and i return to fdisk, ITS INVISIBLE...
i though fdisk would find it all.
what is happening, or is that normal ?
FAT32 is a partition-type (0x0B/0x0C), and so is Linux (0x83)...
FAT32 is also the filesystem that resides on FAT32 partitions most of the time, while linux-partition usually contains extNfs...
A question to the OP... Why would a "LINUX savvy" need a guide to partition and format a simple block-device?
why do we get the errors (not so savvy am i...but maybe the OP is)
heres the error i don't understand
You can't cd into a block device... You mount the filesystem to a directory, doing something like "mount -t filesystem /dev/sdc1 /mnt/sdc1" (filesystem is the filesystem on the block-device, like "vfat" for fat32, or "ext2" for ext2, and the directory "/mnt/sdc1" have to exist).
You're trying to write a partition-table to a partition... Bad idea!
You're doing it right in the low-res full-screen photo, though... Why are you redoing it wrong?
<Actually i made a weird conclusion here before, as a direct result of too little sleep... But to look less like an idiot, i removed it >
For the not so Unix-savvy, i don't recommend using fdisk/mkfs/parted/CLI stuff like that, but use something like gparted, a gtk frontend to parted. It's easy to use, and does everything for you.
Good luck... Oh yeah, kudos for using Enlightenment as your graphical environment!
Oh yeah, i just had a thought about this thread... How the heck is this related to Android Development? This is a basic Unix-utility tutorial!
People, use the correct forums! >_<
Ok the reason you are getting errors is you are trying to do fdisk on /dev/sdc1 which means you are trying to view the partition table on /dev/sdc partition 1. What you SHOULD be typing is fdisk /dev/sdc so it will show all the partitions you created (/dev/sdc1 /dev/sdc2).
Joushou said:
You can't cd into a block device... You mount the filesystem to a directory, doing something like "mount -t filesystem /dev/sdc1 /mnt/sdc1" (filesystem is the filesystem on the block-device, like "vfat" for fat32, or "ext2" for ext2, and the directory "/mnt/sdc1" have to exist).
It can't get the kernel to reread the partition-table, so you need to force it to do this manually.
You can either reload your kernel (The easiest way would be a reboot...), or just reconnect your device.
After that, you should be able to mount the device.
For the not so Unix-savvy, i don't recommend using fdisk/mkfs/parted/CLI stuff like that, but use something like gparted, a gtk frontend to parted. It's easy to use, and does everything for you.
Good luck... Oh yeah, kudos for using Enlightenment as your graphical environment!
Oh yeah, i just had a thought about this thread... How the heck is this related to Android Development? This is a basic Unix-utility tutorial!
People, use the correct forums! >_<
Click to expand...
Click to collapse
The purpose of placing this here a while back is so many people were trying to partition their cards for use with Android apps2sd and they were posting Windows based tutorials. So I decided to create this one based in the Linux world with Linux tools.
And yes you can not "cd" into a block device. The block device (/dev/sdc1) needs to be mounted first (mount /dev/sdc1 /mnt). If you get errors then you need to make sure you put a filesystem on that partition (mkfs.vfat /dev/sdc1).
Oh, yeah, you're right, he's trying to read the partition-table of sdc1... But, he's doing it right in the picture above! (Which i read, and combined with my tired mind, made the conclusion that it was just the usual "Cannot reread partition-table", which you get if you try to modify the table you're running from, which has absolutely no relation to this problem, but again, i'm tired, sorry )
I said the "Block-device != Directory!" thing because he tries to cd into the device-node afterwards... And of course, he gets an error. I just thought i'd clarify that that's not intended to work that way
laptopdragon: You're doing it right in your full-screen photo, but you're messing it up in your window-shot! Why are you redoing it?
And, shafty023, i don't mind the tutorial, it's always good to have someplace for the newbies to look incase they're stuck with a problem, and i understand why it might have seemed as a good place for the tutorial, but this is "Android Development", afterall, and this definitely isn't a thread related to android development
thanks everyone (esp e16 fans)...
im learning as much as posible...
i learnt today
i never "a" (activated) it too.
and i am now using cli as much as possible...( i want to not live by gui if possible)
i also added
mkfs -t vfat /dev/sdb1
to format it as fat32.
was where i made a mistake, as everytime i loaded the SD card into my g1 it would want to format it. reporting its un-usable or needs to be formatted... now...it at least reads its there and doesn't add any files.... i can mount it, and copy to it...(btw i tried 2 different files of rc29)
i think i am not formatting it thoroughly tho.... (and thank you for posting this linux thread)
to summarize, i am doing this in eterm.
su
root# fdisk /dev/sdc
d
p, print
n
p, for primary
1, for (1-4)
1, for 1st cylinder
1201 for last cylinder (its only a 512mb, and 1201 max, should i make it less)
p, for print
t, for change to
c, for fat32 lba (not b for fat32 ? )
a, for activate bootable
w, for write, (exits fdisK)
root # mkfs -t vfat /dev/sdb1
this is what ive done...
as of now...my g1 only goes to the red/ blue/ white screen and does nothing when i hit the power button...??
but refreshes when i hit the camera, or button left of the on/off power button...(than i cna soft reboot it and it starts normal......
but...is the zipped file corrupt ? or is my sdcard not formatted thoroughly ??
any more help folks...(all is appreciated greatly)
There's one problem... You're fdisk'ing sdc, but throwing fat32 on sdb1... That's 2 different devices! you should fdisk and mkfs on the same device! (So if the device is sdc, it should be "fdisk sdc", and "mkfs -t vfat /dev/sdc1"...)
Incase that's just a typo...
It's throwing you into the bootloader... Did you copy the DREAIMG.NBH into the root, with that name? If so, check the md5sum of the file on the SD, and the downloaded file. Alzo, it's not intended to be zipped, inflate it before you copy it to the SD!
If your pc is capable of r/w to the sd, it should be fine... But try to check syslog for errors after you mounted it...
If the wrong device is just a typo, it should be formatted correctly...
I think parted would probably have been a better choice of utility...
How to use Swap Partition on external sdcard
Q: Why use a swap-partition instead of a swap-file?
A: You are able to mount your first partition on computer, with swapfile you are not.
Attention
mmcblk1 = external_sdcard if you use mmcblk0 you will hardbrick your phone. Some apps like swapper 2 use mmcblk0pX as default value, if you want to use these apps make sure to change this in settings.
Test if Kernel supports swap
Code:
$ free
Find your swappartition
Code:
$ fdisk -l /dev/block/mmcblk[COLOR="Red"]1[/COLOR]
Output:
Code:
Device Boot Start End Blocks Id System
/dev/block/mmcblk1p1 1 3849 30916015+ c Win95 Fat32 (LBA)
/dev/block/mmcblk1[COLOR="red"]p2[/COLOR] 3849 3880 250084 82 [COLOR="Red"]Linux swap[/COLOR]
Activate Swap (Linux swap)
Code:
$ swapon /dev/block/mmcblk1[COLOR="red"]p2[/COLOR]
Optional change swappiness
Code:
$ echo 10 > /proc/sys/vm/swappiness //default value is 60
Test if all works
Code:
$ free //There should be some numbers behind swap
$ cat /proc/sys/vm/swappiness //current swappiness value
init.d script
Code:
#!/system/bin/sh
swapon /dev/block/mmcblk1[COLOR="red"]p2[/COLOR]
echo 10 > /proc/sys/vm/swappiness
Faq:
1. Does my Kernel support swap?
free \\there should be on line
Code:
Swap: 0 0 0
2. What is Swappiness?
Lower values: Old cache is deleted rather than swapped
Higher vales:
Since sdcards are not that fast lower values should be better for performance.
3. Which sdcard class should i use?
the faster the better: class 10, but using class 6 (maybe 4) could speed up your phone, too. Slower sdcard == smaler swappiness.
I created linux swap partition in my extsdcard using minitools.. after using the find swap partition code I got some weird message in terminal like
- "partition 2 does not end on cylinder boundary.. why is this happening?? Any solution for this??
Please check the screenshot attached
AW: [GUIDE] Swap Partition
You can ignore this. It is a warning not an error. Did you try to partition your external SD in recovery? Before doing that save all your data, cause it will be deleted.
buffo1987 said:
You can ignore this. It is a warning not an error. Did you try to partition your external SD in recovery? Before doing that save all your data, cause it will be deleted.
Click to expand...
Click to collapse
I dont know how to partition from recovery mode so I did it from pc using minitool..!!
Im confused about what format I should used to create swap partition- ext3 or linuxSwap or someother format..??
thunderrr0 said:
I dont know how to partition from recovery mode so I did it from pc using minitool..!!
Im confused about what format I should used to create swap partition- ext3 or linuxSwap or someother format..??
Click to expand...
Click to collapse
from recovery you do not have to care about that. swap is right
buffo1987 said:
from recovery you do not have to care about that. swap is right
Click to expand...
Click to collapse
Can u help me with this recovery method??procedure?
I use galaxy s advance I9070..stock JB..custom kernel CoCore 4.4..
I guess the recovery method will be same for most o the galaxy series phones??
thunderrr0 said:
Can u help me with this recovery method??procedure?
I use galaxy s advance I9070..stock JB..custom kernel CoCore 4.4..
I guess the recovery method will be same for most o the galaxy series phones??
Click to expand...
Click to collapse
be good to your phone and dont flash anything that doesnt belong to your phone!
AW: [GUIDE] Swap Partition
Recovery should be same for all phones.
Bricked :/
Hey guys!
I used an other tutorial that I found in google. The author of the article didn't tell us to change anything in Swapper2. Everything worked fine until I tried to reboot my phone. It turned off and then nothing, not even a single sign of life. Question is, what can I do with it? Is there a way to revive it?
vricsi94 said:
Hey guys!
I used an other tutorial that I found in google. The author of the article didn't tell us to change anything in Swapper2. Everything worked fine until I tried to reboot my phone. It turned off and then nothing, not even a single sign of life. Question is, what can I do with it? Is there a way to revive it?
Click to expand...
Click to collapse
If you have a S Plus and you touched any partition bellow mmcblk0p8 such as mmcblk0p2 or 3 your device bootloader got corrupted and you won't be able to boot anything anymore (nor Download Mode, Recovery Mode or System).
vricsi94 said:
Is there a way to revive it?
Click to expand...
Click to collapse
Sorry..... No..... In case you activated swappartion in advanced options without changing the given location You formatted the third partition of Your system...... This isn't reversible.
Gr.
B.
sent from my i9001 using Tapatalk2
Thanks for the replies! However, I remembered a little wrong, I did change some of the settings, I did everything as per this tutorial: http://forum.xda-developers.com/showthread.php?t=1659231
As a last idea, I thought about buying a USB jig. Could that help me in any way?
August 4th 2013 - This script has not been maintained in a while. A big thank you to Captain_Throwback for providing continued support.
This is now minimally supported. Now that CM is adding native NTFS/exfat support, the only thing my script handles is multiple partitions.
July 21 2014 - Thank you n01ce! Please see n01ce's post for a "6.5 Alpha" that may solve some checksum problems with exFAT. I have changed devices, so this thread is for historical purposes/legacy support.
"HELP! I accidentally made my exFat card unreadable!!" -- or-- "I can't see more than 1 partition in windows!!"
Please read the instructions at the bottom of THIS POST HERE. No data will be lost!
"My card was working up until a moment ago but now the phone is showing "card damaged!!"
Re-run the script by typing "fuse-mountsd.sh" as root. The script will attempt to repair and re-mount.
If that fails, run "chkdsk /f" in Windows. Do not reformat until it is the last resort!
TL;DR: (Flash this), put exFat/FAT32/NTFS/EXT4 sdcard in, reboot.To remount, type "fuse-mountsd.sh" in a console (or) run using RomToolbox Lite (in /system/xbin/)
Needs to be run every time card is ejected + reinserted -- including when UMS is used
To unmount, type "fuse-mountsd.sh umount" (or if 1 partition) use Storage Manager
Non-customized multi-partitions mounted in /storage/<their name>
Uses init.d to fix/mount at boot
Scans for/mounts all useable block devices (with safety checks)
User-specifiable dynamic mount points
~~Create a ".mounthere" file in the partition with the first line "/location/to/mount/at"
~~Use the first line "skip" or "SKIP" to bypass that partition
Rescans for media when you re-mount
Repairs typical exFat damage caused by CM10.1 (with safety nets)
FAT32 support
NTFS-3g support (noatime set to reduce wear)
EXT4/3/2 support (*fuse built into JB/CM10.1) <- (MTP+EXT4 permissions need to be set to media_rw:media:rw 775!!))
Cleans up after itself: disables/enables ADB/root-security to what you set
BUGS:
All -- ntfsfix does not work. Binaries need to be recompiled. Not a major issue only dead weight.
exFAT may prevent deep-sleep. (NTFS on GS3 doesn't seem to have this issue.)
If you use EXT4/3/2, you need to run the following commands to allow the card to be accessed by the mobile-user:
Code:
find /storage/sdcard1/ -print0 | xargs -0 chown media_rw:media_rw
chmod -R 775 /storage/sdcard1/
(or)
find /storage/sdcard1/ -print0 | xargs -0 chown root:media_rw
Other phones -- Post a debug.txt if it works for you.
CM10 (4.1.x) -- Support is experimental. Use at your own risk.
CM 10.1 (4.2.x) -- Implemented RSA Key Signing Fix, works with BOOTICE.exe partitioned cards.
EXPERTS:
Everything is softcoded thanks to the $SECONDARY_STORAGE, $ANDROID_DATA, $ANDROID_STORAGE, $ANDROID_CACHE env variables and get/setprop command. Some locations are hardcoded in the script's "analyzePhone" function as fallbacks.
To custom-map mountpoints, create a ".mounthere" file in the root of each partition. "skip" or "SKIP" = ignore partition at mount, "/your/path/here" will use that path (or the default if bad). Defaults to "$ANDROID_STORAGE/device_id" if directory is invalid. Removes any temporary directories (in /storage/ only) at unmount. YOU HAVE TO CREATE ANY CUSTOM DIRECTORIES OUTSIDE "/storage" YOURSELF -- I set it like that as a security precaution.
To disable "Directory Creation Security", edit the line at the top of the script to say "dirSECURITY=0". This script will remount / and /storage as RW if needed.
Here is a quick rundown of typical use-cases:
You want one large (exFat/NTFS/ext4) partition:
No customization needed, just flash and go
You want a small FAT32 partition (p1) at the beginning (for firmware/CWM/TWRP) with another big ext4 partition (p2) for your SD card mount. [ Your ROM's vold will mount (p1:fat32) as /storage/sdcard1 automatically. To get it to swap over: ]
Create a ".mounthere" file on (p2) "big" partition with the text "/storage/sdcard1"
This will override Vold and mount the (p2) as external storage. The FAT32 partition will be mounted in /storage/mmcblk1. If you want to mount it elsewhere (even /data/media/0/extSD ! ) simply add another ".mounthere" on the FAT32 partition. (The directory must already exist -- you must make it beforehand -- or disable Directory Security feature.) Be warned - Vold will mount the first partition as /storage/sdcard1 any chance it gets -- even in the background -- unless there is something mounted there already (by this script).
You have (1) partition for a game app you play (internal storage) that you want to rebind, (2) another part you want to rebind OVER an existing directory, and (3) your main storage.
Create a ".mounthere" on (1) with text "/location/of/your/game/app/data"
".mounthere" on (2) with text "/folder/you/want/substituted"
".mounthere" on (3) with text "/storage/sdcard1"
You are a long-hair-hippie Linux developer with 4 partitions, each in a different filesystem, and want them mounted hidden from apps and listed by block device so you know what partition you are on:
No customization needed, just flash and go
SUPPORT:
I can only provide support if you supply me with logs. Do so by typing "fuse-mountsd.sh > /sdcard/debug.txt 2>&1" and opening the Debug.txt in your phone's storage.
It's all automatic now - so if it mounts your modem as writeable and kicks your dog don't blame me. (It excludes dangerous block devices automatically [mmcblk0, /system, mtdblock, etc], but there is always a 1% chance it will miss something.) If it does, report it here so I can fix it.
If you intend to use this with a other ROMs/phones, IT SHOULD STILL WORK. Post any errors or weird behavior.
Code:
Changelog
[I]7.0 - TBA (Make GUI? Fix ext4 permissions automatically? Get paid?)[/I]
6.4 - No longer uses "mount" output (wasn't acting standard-ly. Using /proc/mounts instead)
- [COLOR="Red"]Got rid of conv=notrunc[/COLOR]. Be careful!
6.3 - Bugfix to scrubMount code
6.2 - No longer Experimental / final unstable
- added rough ext2/3 support
6.1 - mount command bugfix
6.0 - Added a bypass for Directory Security, fixed some bugs.
5.9 - Rewrote NOGO code from scratch -- UUIDs ignored
5.8 - (??)
5.7 - Support for Note2 formatted exFat cards + more (0xf4 bug)
5.6 - bug fixed: no longer detects zram/assumes multimount
5.5 - [COLOR="Red"]Experimental support for weird devices[/COLOR]
5.4 - [b]Major bugfix!![/b] Fix fixmyexfat.sh coding fail
5.3 - Fixed "vffat" support. Undid HARD QUIT on bad Nogo, made it a soft one.
5.2 - Increased logging of tables, HARD QUIT if Nogo not found
5.1 - Quick patch to fix dm-* device blacklist
5.0 - [b]SUPPORTS MULTI-PARTITIONED CARDS! Autoscans for block devs! Complete rewrite![/b]
4.1 - Quick patch to check mmcblk1
4.0 - [B]WORKS 100% ON 4.2.2!![/B] My script is the first to achieve this AFAIK
3.3 - fixed a bug detecting existing mounts (related to "non-persistent mount points" issue)
3.1 - added dynamic exFAT repair code
3.0 - added NTFS/ext4 support
1.0 -> 2.0 <Removed>
Attribution credits:
Original thanks go to originator of the method, smitna in the Galaxy S2 forum. Additional thanks go to shardul_seth (Post 23) for compiling the latest version of the fuse-exfat and ntfs-3g binaries for ARM, and of course Andrew Nayenko for his efforts in creating GPL'd exFat code (fuse-exfat on google code).
[HOWTO][exFAT][WORK IN PROGRESS] Mount exFAT formatted drives and cards - smitna
Full NTFS Read Write support for Android (ARM) - shardul_seth
[HOWTO][exFAT][CM10.1] Working 64GB ext sdcard with fuse-exfat (1.0.1) + FIX broken (my original Dev thread)
I believe the term is I "kanged" their binaries. The rest is mine. This is a "mod"/"hack" until CM adds native support. (If ever: exFat)
DONATIONS:
https://supporters.eff.org/donate , or help a noob by linking to a solution in their thread. :good:
https://plus.google.com/+CyanogenMod/posts/ib5wz8jk1JyOne of the CM Team has flesh eating bacteria! Keep CM alive! (Literally)
I'm a noob, this looks scary to me. Either way, I needs me some exfat cuz my movies are too large for fat32.
My only question is: Even though this is written for CM10.1 on Verizon s3, might this also work on T-mobile s3 with an AOSP (Android 4.2.2) ROM?
Here's what I'm running:
SGH-T999 (d2tmo)
Android 4.2.2
Kernel: 3.0.62-cyanogenmod-g137df31
ROM: Liquid-JB-v2.1-RC1
Build:liquid-d2tmo-userdebug 4.2.2 JDQ39
I've spent the last 2 days searching and testing to no avail. My sdcard is running hot trying to get files larger than 4gb on it. I've tried formatting to exfat, ntfs, ext4, even hfs+, no success. Paragon and ntfssd apps couldn't mount it either.
Any help on this matter would be greatly appreciated!
Even though this might not work on T-mobile, thank you either way, I'm glad there are people like you developing for 64gb cards.
I wouldn't say I'm a developer, just a scripter with a lot of time on her hands.
lordazoroth said:
My only question is: Even though this is written for CM10.1 on Verizon s3, might this also work on T-mobile s3 with an AOSP (Android 4.2.2) ROM?
Click to expand...
Click to collapse
MAKE A NANDROID. This mod should do nothing permanently harmful anyway: it looks for EXFAT before writing anything.
Carrier doesn't matter. It only depends (1) if your kernel has FUSE support, (2) if it has init.d support and (3) what your Block device is.
I think Google added FUSE by default in JB, and anything based off CM10.1 will have it
Type "echo $SECONDARY_STORAGE" in a terminal emulator. If it displays ANYTHING other than blank it should work.
The Block device is trickier. Type "blkid" as root with with your FAT32 card in and out. The one that disappears is your Card's Block device, and should be /dev/block/mmcblk1p1.
If you have any doubts, don't do it.
HMkX2 said:
I wouldn't say I'm a developer, just a scripter with a lot of time on her hands.
MAKE A NANDROID. This mod should do nothing permanently harmful anyway: it looks for EXFAT before writing anything.
Carrier doesn't matter. It only depends (1) if your kernel has FUSE support, (2) if it has init.d support and (3) what your Block device is.
I think Google added FUSE by default in JB, and anything based off CM10.1 will have it
Type "echo $SECONDARY_STORAGE" in a terminal emulator. If it displays ANYTHING other than blank it should work.
The Block device is trickier. Type "blkid" as root with with your FAT32 card in and out. The one that disappears is your Card's Block device, and should be /dev/block/mmcblk1p1.
If you have any doubts, don't do it.
Click to expand...
Click to collapse
Awesome instructions, very much appreciate it. Looks like it's time to get to work. I checked the zip file thoroughly and cross-checked it with my root directories to see if it overwrites anything and it looks like it just adds stuff. From what I've seen, this is the only game in town so I'll post back once I'm done.
If this does work, this is a godlike zip file and it does something nothing else can do right now
Ok still not mounting properly.
Here's what I did:
Typed "echo $SECONDARY_STORAGE" in a terminal emulator, showed "/storage/sdcard1"
Typed "blkid", showed "/dev/block/mmcblk1p1" only when sd card was inserted under fat32 file format
Formatted sd card to exFAT on PC, inserted back into s3
Flashed CM10.1_exFAT-mountsd_2.0_HMkX2.zip
Ran terminal emulator, typed su >> exfat-mountsd.sh got this:
[email protected]:/ $ su
[email protected]:/ # exfat-mountsd.sh
[exfat-mountsd v2.0] exFat autorepair and mount script for CM10.1 (HMkX2 CORE//XDA)
Automated mounting script for exFat on GS3
/storage/sdcard1 is not mounted. (OK)
Calling [fixmyexfat] on /dev/block/mmcblk1p1 (if needed)
Broadcasting: Intent { act=android.intent.action.MEDIA_CHECKING dat=file:///storage/sdcard1 }
Broadcast completed: result=0
[fixmyexfat v2.0] exFat header repair tool (HMkX2 CORE//XDA)
More robust than before!
Usage: /system/xbin/fixmyexfat.sh <block device, eg /dev/block/mmcblk1p1>
[fixmyexfat] Manual target is /dev/block/mmcblk1p1
1+0 records in
1+0 records out
512 bytes transferred in 0.166 secs (3084 bytes/sec)
Segment 1 (0:4) (BAD)
4+0 records in
4+0 records out
4 bytes transferred in 0.012 secs (333 bytes/sec)
Segment 2 (484:4) (BAD)
4+0 records in
4+0 records out
4 bytes transferred in 0.007 secs (571 bytes/sec)
Segment 3 (508:4) (BAD)
4+0 records in
4+0 records out
4 bytes transferred in 0.005 secs (800 bytes/sec)
Check complete!
Check complete, mounting and initializing...
########################## ATTEMPTING COMMAND ##########################
mount.exfat-fuse -o rw,dirsync,umask=0 /dev/block/mmcblk1p1 /storage/sdcard1
Attempting bypass...
* daemon not running. starting it now on port 5038 *
* daemon started successfully *
connected to localhost:5556
List of devices attached
localhost:5556 device
Running ADB commands
FUSE exfat 1.0.1
ERROR: invalid VBR checksum 0xa04b8eb5 (expected 0x804d6ce4).
Broadcasting: Intent { act=android.intent.action.MEDIA_MOUNTED dat=file:///storage/sdcard1 }
Broadcast completed: result=0
Process complete!
[email protected]:/ #
Not sure how to read this...
Afterwards my notification panel says: "Damaged SD card : SD card is damaged. Try reformatting it."
Tried restarting s3, mounting in storage settings, reformatting in PC. Ran script 4 times on a fresh exFAT format with the same notification error (format was unrecognizable by s3 and PC after running terminal command "exfat-mountsd.sh" [don't worry didn't lose any data ]).
After each format to exFAT on my PC I placed a few images on the card to ensure it was functioning properly, /storage/sdcard1 directory is always empty.
Mounting in settings >> storage generates the same notification error: "Damaged SD card : SD card is damaged. Try reformatting it."
Any ideas?... it is detecting an SD there after mount attempts (despite exFAT format) interestingly enough. Though nothing is detected after a reboot unless another script or settings >> storage mount attempt is performed.
I should mention that I ran a "quick" format when formatting the SD card from Fat32 to exFAT, not sure if that might be relevant.
Hm... well, I can tell you what it means. Quick formatting is fine, I actually prefer it since flash memory has a limited life. Second, "chkdsk /f" in windows will repair your card + data -- the card isn't "damaged", it's just that 4 letters at the beginning were changed. (See: Segment1, Segment2, Segment 3 messages.) My scripts change those 4 letters back, in a safe-ish way.
Unfortunately, without having a hex-dump of your working exFat header I can't say what those four letters should be. I got mine using a program called Hex Editor Neo on what I had available, a Sandisk 64gb class-10, and are what I included in the script. When the letters don't line up like it expects, you get a checksum error.
Without that, there is one single thing you can try - but has a high likelyhood of success.
Use RootBox explorer, navigate to /system/xbin/ and DELETE the file called "fixmyfat.sh".
Turn your phone OFF. Eject the SD card
chkdsk /f the card or quick format it to fix it, put a test file on it from Windows
Put the card in your phone, turn on.The card must be in the phone before it is turned on.
If that works for you, and the card works, you can give me a hex dump pretty easily so I can edit the script. IF it works, and I highly suspect it will, get a hex dump by typing EXACTLY:
dd if=/dev/block/mmcblk1p1 bs=1 count=512 of=/sdcard/working_sd.bin <- corrected
That will place a text file in your internal sd card than you can post/send me. Again, thanks for bearing with me, this started out as something for myself then made better in the hopes other people could use it. If you could re-corrupt the card (by unplugging/replugging it while the phone is on) and send me a hex dump of the "Card Damaged" state, even better.
O.O... you are awesome!
I'll get on this right away, and I'd be happy to help any way i can
---------- Post added at 09:19 PM ---------- Previous post was at 08:52 PM ----------
OMG IT WORKS!!! the card mounted
I tried the line of code and it gave me an error:
[email protected]:/ $ su
[email protected]:/ # dd if=/dev/blk/mmcblk1p1 bs=1 count=512 of=/sdcard/working_sd.bin
/dev/blk/mmcblk1p1: cannot open for read: No such file or directory
1|[email protected]:/ #
My /sdcard directory seems to be a redirect to /storage/sdcard0 (i think), i have a lot of these (what appear to be redirects) on my phone now after upgrading from android 4.0.4 to 4.2.2. If I changed the end of that line of code to something like "of=/storage/sdcard0/0//working_sd.bin" (or any similar working directory), might that solve the problem or am I reading that wrong?
Thank you so much, this is... very powerful!
Great work on this!
Double post.
Please check my post for the correct DD command - I typed /blk instead of /block due to habit.
I'm glad it works. As long as you don't re-plug the card while it is on, you will have no problems. If you accidentally DO "corrupt" the card, just "chkdsk /f" in Windows, turn the phone off, put the card in, and turn it on.
And the biggest help you can give would be those headers. (I was looking at the exfat.fsck-fuse code, apparently even THAT can't fix it!) For the time being, I will re-do the scripts to display more information so I can troubleshoot more easily.
HMkX2 said:
Please check my post for the correct DD command - I typed /blk instead of /block due to habit.
I'm glad it works. As long as you don't re-plug the card while it is on, you will have no problems. If you accidentally DO "corrupt" the card, just "chkdsk /f" in Windows, turn the phone off, put the card in, and turn it on.
And the biggest help you can give would be those headers. (I was looking at the exfat.fsck-fuse code, apparently even THAT can't fix it!) For the time being, I will re-do the scripts to display more information so I can troubleshoot more easily.
Click to expand...
Click to collapse
Sounds bad, I don't know why all these companies are sticking with Fat32 after all these years. Fat32 has been obsolete since like 2000, don't we have open source formats like ext4 now? - that's my rant lol. Either way, it works and I got the file. Btw, this file acts strangely on my device, I couldn't see it in windows explorer during plugin and It wouldn't copy to my sd card even though other files seem to be copying fine. Had to email it to myself from my phone. Thank you so much for all your help, let me know if you need anything else
Rename the file and remove .rar extension before use, xda doesn't allow .bin extensions to be uploaded.
Quick question: If I shut the phone down and pull the SD, can I turn the phone back on and use it without the SD while I load the SD up with files, then power off, re-insert the SD and power on again? (like will it automount again?)
Yay!
HMkX2 said:
Please check my post for the correct DD command - I typed /blk instead of /block due to habit.
I'm glad it works. As long as you don't re-plug the card while it is on, you will have no problems. If you accidentally DO "corrupt" the card, just "chkdsk /f" in Windows, turn the phone off, put the card in, and turn it on.
And the biggest help you can give would be those headers. (I was looking at the exfat.fsck-fuse code, apparently even THAT can't fix it!) For the time being, I will re-do the scripts to display more information so I can troubleshoot more easily.
Click to expand...
Click to collapse
Very interesting. I can go on the hunt for headers if you like. I have loads of sd cards.
Oddly enough, I switched to FAT32 even though I'm on a TouchWiz ROM, cause exFAT does not use alternating file allocation tables. When exFAT gets borked, it gets super borked and you have to use chkdsk (or some other brutish method) to retrieve files. When FAT32 gets borked, you can load the last table that was working and elegantly pull your files off the card (no need to muddle through a pile of chkdsk files and find the correct extensions).
Any possibility that this method could be used to mount a more robust file system like ext[2,3,4]? Journaling would be nice. Or some transaction safe file system.
Ta very much,
ALQI
Re: [MOD] Flashable exFAT support for CM10.1 / AOSP roms (external SD)
Great.I'll try it.
Sent from my SCH-I535 using xda premium
lordazoroth said:
Sounds bad, I don't know why all these companies are sticking with Fat32 after all these years. Fat32 has been obsolete since like 2000, don't we have open source formats like ext4 now?
Click to expand...
Click to collapse
Why we have 15 competing standards... "Never attribute to malice that which is adequately explained by stupidity."
Btw, this file acts strangely on my device, I couldn't see it in windows explorer during plugin and It wouldn't copy to my sd card even though other files seem to be copying fine.Any files you create on the device without "Rescanning for media" will not be visible in the MTP (Mass Tranfer Protocol) "MP3 player-like" abstracted FUSE filesystem. (One reason why people want UMS (USB Mass Storage) "hard drive-like" support, you see things immediately/it's faster.) Get a free program called SDrescan from Google Play, or run the command below(?), to update the MTP index and see files you create ON the device.
Code:
am broadcast -a android.intent.action.MEDIA_MOUNTED -d file://$SECONDARY_STORAGE
am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///storage/sdcard0
...let me know if you need anything else Quick question: If I shut the phone down and pull the SD, can I turn the phone back on and use it without the SD while I load the SD up with files, then power off, re-insert the SD and power on again? (like will it automount again?)Yes, the mount script will simply fail and there will be a silent error. (I need to code some error checking if you insert a non-exfat card...)
Like I said, if you could intentionally re-corrupt the header by using Storage Manager to "Unmount SD" then "Mount SD", then the DD command, (and rescanning media to copy the file off!) I'd appreciate it. Although, I have a second idea of how to get around that problem in mind.....
alquimista said:
Very interesting. I can go on the hunt for headers if you like. I have loads of sd cards.
Click to expand...
Click to collapse
Thanks but I think the bottom line is (1) there is no working open source exfat.fsck anyway and (2) headers are unique per-device. The proper fix is re-coding vold to not run fsck.msdos on a fsck.exfat card.
Oddly enough, I switched to FAT32 even though I'm on a TouchWiz ROM, cause exFAT does not use alternating file allocation tables. When exFAT gets borked, it getse that wa super borked and you have to use chkdsk (or some other brutish method) to retrieve files. When FAT32 gets borked, you can load the last tabls working and elegantly pull your files off the card (no need to muddle through a pile of chkdsk files and find the correct extensions).
Any possibility that this method could be used to mount a more robust file system like ext[2,3,4]? Journaling would be nice. Or some transaction safe file system.Yep, that is all 100% true. But I've lost files on fat32 drives as well - and I'd hardly call multiple file tables elegant, especially when they become desynced. NTFS would be a better fix, except for the fact it is a magnetic-media filesystem with journaling/timestamps/excessive writes, and exFAT was designed for flash media in the first place!! Even EXT4 writes too much, EXT2 or EXT4 with journaling disabled is a better solution for integrity, but much worse for flash-life. Nowadays, the value of error-recovery outweighs the limited media life. (This discussion comes up a lot in custom Linux firmwares for routers: DD-WRT NVRAM/Flashdrives)
Shardul_seth, the gentleman that compiled these binaries, has made a package for full NTFS support already using ntfs-fuse3g. (<- link) NTFS-3g is very mature/stable at this point, and installation for our devices is even simpler since we already have FUSE support in the kernel. However, his scripts are to mount USB, not the SD card. Mine does the SD card - all those ADB workarounds - so absolutely could be adapted for mounting NTFS cards. I will work on that when I have some time -- I'd need to figure out how to identify a NTFS card on header alone.
Again, all these methods are HACKS, proper support should be added in the kernel at some point. Someone actually has, and I've been cheering for him. He added EXT4 support to CM10.1, his post and code are here. However, he says it "stalled in code review". For the time being, you have to do all this manually.
Why we have 15 competing standards... "Never attribute to malice that which is adequately explained by stupidity."
Click to expand...
Click to collapse
Nice post lol, I only meant why FAT32 of all choices, these companies must know we're gonna be packing large files at some point, why knee cap us at 4gb when so many formats don't? Universal would be nice but of course it's entirely impractical
Any files you create on the device without "Rescanning for media" will not be visible in the MTP (Mass Tranfer Protocol) "MP3 player-like" abstracted FUSE filesystem. (One reason why people want UMS (USB Mass Storage) "hard drive-like" support, you see things immediately/it's faster.) Get a free program called SDrescan from Google Play, or run the command below(?), to update the MTP index and see files you create ON the device.
Click to expand...
Click to collapse
Thanks for the media scan info, that'll help a lot, I'll try out your suggestions tonight
Yes, the mount script will simply fail and there will be a silent error. (I need to code some error checking if you insert a non-exfat card...)
Like I said, if you could intentionally re-corrupt the header by using Storage Manager to "Unmount SD" then "Mount SD", then the DD command, (and rescanning media to copy the file off!) I'd appreciate it. Although, I have a second idea of how to get around that problem in mind.....
Click to expand...
Click to collapse
Will do, sounds interesting, will there be data loss or just header corruption? second idea in mind?
Also, each time I take the card out of my phone (properly after shutdown of phone) and place it in my computer (vista 64bit ultimate) It asks to check for errors, i'll click continue (confirmation to check), takes 3-5 seconds, finishes with no errors found. If I don't do this the card is write protected. I've made sure only to disconnect from PC after "safely removing hardware" so it appears that usage in the phone is generating the confusion. This doesn't seem to be an issue but I thought it might be worth mentioning
do you enter it correctly?
I get this when running the script:
Code:
BREAK! /dev/block/mmcblk1p1 is not a block-special file/device, do you enter it correctly?
How do I find what block file I need to change to script to?
Thanks for your work
boricua1213 said:
How do I find what block file I need to change to script to?
Click to expand...
Click to collapse
Safest (not easiest) way is to insert your FAT32 card, type "mount|grep vfat". The one you are looking for says "/dev/block/vold___:__" . (Shortcut: "mount|grep vold");
Then type "blkid". The one that's listed twice (UUID or Label) as "vold" is your block device's other name. (/mnt/block/mmc_somethingorother) Both names lead to the same spot.
(or)
Type "blkid" with your card in. Make a list. Remove your card. Type "blkid" again. The one that dissapears is your block device.
Ok got the file, I created 2 files, 1 before and 1 after the force unplug, just in case.
Remember to rename the files without the .rar extension before use
Re: [MOD] 1-Click Flashable exFAT + NTFS + EXT4 support for CM10.1 / AOSP (external S
I am about to embark on this journey and make another attempt at ditching TouchWiz. Does this script make it as if everything is normal as far as apps accessing the SD card go? I assume so, but I'm specifically wondering if I'll still be able to use Directory Bind and if I'll be able to create symbolic links to redirect Google Music to the external SD.
Getting ready to flash and try anyway but figured I'd ask to see if someone knows the answer all ready.
I'll be the first to admit the problem is almost certainly user error on my part but I have been wholly unsuccessful with this mod. I have tried it on Carbon Rom and Paranoid Rom. I guess they both have FUSE support, I couldn't find any confirmation of that on the Rom threads....particularly Carbon.
I flashed the zip in the OP in CWM after installing both Roms clean. I tried installing the zip as soon as I installed the Rom and I tried installing it after doing a full boot up first. Ran the chkdks /f command probably 12 times after each successive failed attempt to get my 64 exFAT card recognized. Said Damaged SD no matter what I tried. I saw the post on Page 1 about deleting the fixmyfat file....tried that too and no go. That tip may no longer be relevant since you've updated the script.
Is there something I am missing? There are lots of posts in this thread about mount commands and adb, but it seems from the OP none of those things are supposed to be necessary.
spearoid said:
Does this script make it as if everything is normal as far as apps accessing the SD card go? I assume so, but I'm specifically wondering if I'll still be able to use Directory Bind and if I'll be able to create symbolic links to redirect Google Music to the external SD.
Click to expand...
Click to collapse
In short, it should. However, exFAT/FAT32 don't support permissions/softlinks like ext4 does. So if you use ext4, just remember to set permissions appropriately! When in doubt, set permissions to 755 root:sdcard_rw or root:media_rw on the external sd.
I have tried it on Carbon Rom and Paranoid Rom. I guess they both have FUSE support, I couldn't find any confirmation of that on the Rom threads....particularly CarbonType "mount | grep fuse" in console. If you see "fuse" listed anywhere in the text, you have it. Google added it to JellyBean.
I flashed the zip in the OP in CWM after installing both Roms clean. I tried installing the zip as soon as I installed the Rom and I tried installing it after doing a full boot up first. Ran the chkdks /f command probably 12 times after each successive failed attempt to get my 64 exFAT card recognized. Said Damaged SD no matter what I tried. I saw the post on Page 1 about deleting the fixmyfat file....tried that too and no go. That tip may no longer be relevant since you've updated the script.
Is there something I am missing? There are lots of posts in this thread about mount commands and adb, but it seems from the OP none of those things are supposed to be necessary.Do me a favor... open a terminal, type "su", then type "fuse-mountsd.sh > /sdcard/debug.txt 2>&1" (no spaces in 2>&1). It will make a "debug.txt" file in the root of your internal storage. Paste the output here. I am 90% certain you have the wrong block device set. 9% certain it is the 4.2.2 ADB thing.
You do not need to delete "fixmyfat.sh" -- those instructions are very old. Was the phone *physically off* when you plugged the SDcard in? Ignore the mount commands/ADB - you should not have to deal with them if you only plug in/unplug the card when the phone is off.
I am nigh certain it has to do with 4.2.2 messing with ADB. Like I said, for now, put in a *working* sd card *before* the phone is turned on and you won't run into that issue.
Hiya! I don't believe my problem is device specific. The background of how I ended up in this crappy situation is, but I believe the resulting issue is general. Should I be wrong, tell me and I'll move this to my device's section.
Short question: how can I (and can I?) restore data in a partition that got deleted, if no new filesystem has been created over it?
Long background: I have a Xiaomi Mi2-S 32GB. It used to have a peculiar layout: a double system partition (/system1 and /system2)¹, a small internal storage (/userdata)², and a big emulated SD card (/storage)³.
Let's explain why:
¹ False dual boot: the active system is installed in the first partition. When installing an update with the official app, the newer system gets installed in the second and that one gets booted. So, should this newer system fail to boot, you have an older one correctly working and ready to boot.
² and ³: so that the whole storage partition containing photos, music, videos, downloads, backups, saved games and such can be accessed with MTP, while the userdata containing apps and complementary system things is kept safe. This last decision, however, brings up a new problem: userdata can't be accessed by user to put his files or by apps without root permissions to store data (like photos), while storage can't be used to install apps, or even to move them using Link2SD or such. Some users might find storage is insufficient for their videos and music, while others might find userdata is too little for their games, and they are both stuck in this situation.
I was in the second group, so I altered my layout using stillka's guide on xiaomi.eu (Sorry, I can't post links). I extended my userdata, so that my storage resulted smaller. Plus, I understood altering a partition would mean deleting all the partitions before that one, and recreating them thereafter.
Until this point, all was OK. I installed Ivan's AOSP Lollipop for unmerged partitions, and found out it would experience random reboots with True Dual Boot. So I stuck with False one and forgot about everything. I kept that version without updating for a long time.
Then, several months later, my phone started rebooting randomly anyway. I figured I would come back to MIUI to get Xiaomi's support for an official ROM.
Little did I know they decided to change layout in the meantime. MIUI got so big the size of the two systems was insufficient. So they decided to merge them into an unique partition big enough. So, while flashing with the official tool MiFlash, it practically altered my system layout, having to delete all that was placed before them (cache, userdata and storage), never telling me what it was going to do, advising me to back my storage up somewhere. All I did was back up my userdata into storage, confident flashing their official ROM with their official tool would just write into system, since nobody told me otherwise.
So this is the result: the old, small size of userdata is back, and everything that comes after is left without any filesystem: these are the last line in parted's print output
20 327MB 336MB 8389kB ext4 persist
21 336MB 1409MB 1074MB ext4 system
22 1409MB 1812MB 403MB ext4 cache
23 1812MB 5570MB 3758MB ext4 userdata
24 5570MB 31.3GB 25.7GB storage
Click to expand...
Click to collapse
I've tried parted's rescue command, but it is unable to find a partition lying there. I don't have my old layout, so I'm not able to precisely know where my old storage began, but I remember it to be around 18 GiB in size. I've tried all ranges possible (from the current end of userdata, 18 G from the end and so on) but no dice.
Can someone tell me if there is any hope, and what can I try?
Now I'm trying to dd the whole eMMC, or even just the last partition, to my computer to work on it using, say, testdisk. There is just one problem.
Obviously, I must issue the commands in my PC's environment, as I've nowhere to dump the biggest partition in my phone to, on it. So it goes something like
Code:
adb shell su -c "cat /dev/block/mmcblk0" | pv > mmcblk0.raw
The problem is, even if my phone was rooted by TWRP and in my options menu, the su binary is not found
/sbin/sh: su: not found
Click to expand...
Click to collapse
What should I do? Should I manually push the su binary in /system/bin? Where should I take su? From my PC?
This link should be helpful to you. Though its for MI3, the guy explains exactly how he recreates all the stock partitions one by one using the parted utility.
However, I think even before you try that, I think you should consider using the shortcut suggested in this link. If you can alter the flash_all.bat slightly and add the gpt_both0.bin, it can re-create the stock partitions (at least this is what the poster has done for Mi3/Mi4, since yours is Mi2, I'm not so sure, you may have to find out).
Finally, here is one more link that you may want to read up.
---------- Post added at 06:34 AM ---------- Previous post was at 06:34 AM ----------
This link should be helpful to you. Though its for MI3, the guy explains exactly how he recreates all the stock partitions one by one using the parted utility.
However, I think even before you try that, I think you should consider using the shortcut suggested in this link. If you can alter the flash_all.bat slightly and add the gpt_both0.bin, it can re-create the stock partitions (at least this is what the poster has done for Mi3/Mi4, since yours is Mi2, I'm not so sure, you may have to find out).
Finally, here is one more link that you may want to read up.
The problem is I don't have to restore stock partitions. That was already done against my knowledge, only that the last partition was left without a filesystem. If anything, I should restore my previous, custom layout, I have no trace left about.
I've managed to use testdisk. It is not able to find any partition in my phone eMMC though...
Testdisk's failure might be because of a wrong geometry setting, even if it sounds strange to me.
This is the ouput of parted's print
parted print said:
Error: Both the primary and backup GPT tables are corrupt. Try making a fresh
table, and using Parted's rescue feature to recover partitions.
Model: (file)
Disk /media/Storage/mmcblk0.raw: 31.4GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
Click to expand...
Click to collapse
This is fdisk's p
fdisk p said:
Disk mmcblk0.raw: 29.2 GiB, 31354139648 bytes, 61238554 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
mmcblk0.raw1 1 4294967295 4294967295 2T ee GPT
Click to expand...
Click to collapse
2T? Seriously?
Given that parted doesn't give those errors when run directly in adb, maybe something has gone wrong in the process of dumping my memory. I've issued this command:
Code:
adb shell dd if=/dev/block/mmcblk0 | pv | dd of=/media/Storage/mmcblk0.raw
Did I do something wrong?
This is what testdisk tells me in the analyse menu:
testdisk analyse said:
Disk mmcblk0.raw - 31 GB / 29 GiB - CHS 3812 255 63
Current partition structure:
Partition Start End Size in sectors
1 P EFI GPT 0 0 2 267349 89 4 4294967295
Warning: Bad ending head (CHS and LBA don't match)
No partition is bootable
Click to expand...
Click to collapse
It also detects an Intel table, which is rather odd. Selecting Intel or GPT gives the same result anyway, a big, round zero.
Rather than messing with partition tables using parted, I think there is a simple thing you can try:
1. Restore stock partition tables as it is (using the linked guide or some other means).
2. Restore the stock partitions themselves, something like this:
dd if=/sdcard/system.img of=/dev/block/mmcblk0
dd if=/sdcard/boot.img of=/dev/block/mmcblk1
These are just examples, you know which partition number corresponds to system.img, boot.img, etc. If you can do the above successfully, you will have restored the handset back to stock settings (both partitions and data) and it should start working in theory.
I'm not sure whether I'm not describing my problem clearly or I'm not understanding your suggestion.
The fact is my phone works correctly, it is not bricked. Right now I'm booting MIUI 8. My system partition is alright. My problem is my storage partition (the emulated SD card with all my personal data in it) got deleted, and I'm trying to get it back.
And the layout I had when my storage partition was available was not the stock one, but was already altered by me, as in storage was smaller in order to make more room for userdata (more apps). So, restoring stock layout would not give me my storage's previous start and end points.
k, now I understand your issue! If you want to recover data from a damaged (in this case non-existent) storage partition, have you tried any linux recovery programs (those may be your only option) though I'm not sure how many of them are designed to work with an eMMC.
Or is it the case that you don't care anything about recovering your personal data and just want to fix the storage partition, so the Mi2 file-manager recognizes it?
>> 2T? Seriously?
Yes, that's normal. I've observed even on MediaTek based devices that the partition tables leave that much extra space on the /storage partition (which is typically the last) though its actual physical size is just 2-3GB. You either got the starting/ending points of /storage partition in your MBR/GPT tables wrong (CHS/LBA numbers) or it is just a case of formatting this partition so that the Mi2 recognizes it. In that case, you can just try formatting it to FAT32 or something (but remember that you will loose all your personal data in that case).
Indeed my whole concern is trying to recover what was on it. For all I know, there's the possibility everything was wiped the instant MiFlash destroyed my storage partition, but since no new filesystem was written on it I'm not abandoning hope.
What I did was dump my eMMC to work on it using Linux restore programs (testdisk, mainly), but something must have gone wrong when dumping it. I will try to save the correct partition table and feeding it to TestDisk, but somehow I get the idea this won't solve my problem.
Is there anyway to get the eMMC's geometry parameters to input them manually in TestDisk?
The card is described by parted as "MMC SEM32G", and the parameters I can change are cylinder geometry (number of cylinders, default 3812), head geometry (number of heads: 1-255, default 255), sector geometry (numbers of sectors per track: 1-63, default 63) and sector size.
> What should I do? Should I manually push the su binary in /system/bin? Where should I take su? From my PC?
If you were still unable to take the dump for want of the su binary, then here is an easier way to disk dump the partitions without requiring the su binary at all, but you'll need the CWM image of your Mi2 device:
1. Start phone in Fastboot mode by long-pressing DnVolume+Start buttons.
2. Connect to USB Cable (ensure adb drivers and fastboot are installed).
3. Run this command: fastboot boot /path/to/CWM.img
4. Once phone boots into CWM, adb commands will work! Just mount the system partition in RW.
5. Using adb shell take the dump (you won't be needing root now since the partitions are in RW mode):
dd if=/dev/block/mmcWhatEver of=/sdcard/whatEver.img
EDIT
And if for some reason this doesn't work and you absolutely MUST copy the su binary, you can get the latest zip from the ChainFire.eu site, unzip the su binary and SuperSu.apk files and push the former in /system/xbin/su and the latter in /system/app folders using adb.
Of course, you'll have to provide correct permissions to the su binary, enable the setuid bit on it and finally symlink it to /bin/su.
I got the su binary by letting CWM recovery root my device. However, issuing commands with su copies just the first few bytes. In particular:
Code:
adb shell /system/xbin/su -c "dd if=/dev/block/mmcblk0" | pv | dd of=/media/Storage/mmcblk0.raw
Get 38B, while
Code:
adb shell su -c "cat /dev/block/mmcblk0" | pv > /media/Storage/mmcblk0.raw
Gets 25B.
Anyway, I can't use your suggestion: I don't have an /sdcard partition on my phone anymore: it's the one I'm trying to recover (the last 25.7GB without any filesystem in the partition table I posted in the OP). I must dump them on my PC.