• I'm changing the android platform to create two partitions in a SD Card. I need to do this as early as possible. I'm currently trying in init.rc

  • It would be nice to obfuscate the access to one of the partitions. If I could keep it hidden would be better

And...the long story:

I'm trying to create new partitions on an SD card in a device, and I need to be done as early as possible. I thought that the init.rc should be the best location for this, so I tried to add a script call to perform the task, but I'm unable to create these partitions (or get the reason it fails). First of all, is this premise valid? Should I be able to do this?

I call the script by:

service myscript /system/bin/logwrapper /system/bin/myscript.sh

at init-time. And the content´s of the .sh file is

fdisk /dev/sdcard < mykeys.input

where "mykeys.input" is the sequence of commands used to perform the task of creating the partitions.

Is this the recommended way of doing this?

  • Why not format the SD card using a computer? – Matthew Read Jun 1 '11 at 0:05
  • Hy. The hardware i have have a little twist. This card is hardwired in the device< i know i know...it sucks but i must work with what i got > ps: It´s actually soldered in the board. – Void Jun 1 '11 at 0:09
  • Oh, I see. Is it a Galaxy or Nexus S? My Vibrant has "internal SD" that isn't actually an SD card, but often referred to as such. It's treated as if it were a card, though; downloads go there, for example. Anyways, just curious: Why are you trying to format it? – Matthew Read Jun 1 '11 at 0:13
  • I need to create two partitions: -One of them will be available to the user -Another one will be used to store downloaded data from a custom store. It will have some specific permission, and may contain some restricted information ( the app will handle this ) – Void Jun 1 '11 at 0:18
service myscript /system/bin/logwrapper /system/bin/myscript.sh

If you declare the service as disabled, it wont run unless you later explicitly start it.

But do you really want to repartition the card every time you boot the system? I would think you would want to partition it once, and then perhaps mount the partitions in the init script.

  • Hy Chris. Thanks for the tip. Lame mistake, but still i could not execute the commands in the script. ( At least they had no effect at all ). And, yes, i will make some logic to prevent the re-partitioning. If you have an advice to do this ( once ) in any other way i would appreciate. Thanks! – Void Jun 1 '11 at 12:00
  • Is /dev/sdcard the correct device name? What happens if you run the script commands manually, after boot - do they work then? Also don't forget to format (make a filesystem) – Chris Stratton Jun 1 '11 at 15:20
  • Chris ,i´ll try this. But do you know if a should be able to access the fdisk in the script? – Void Jun 1 '11 at 15:56
  • Hmm, maybe you need to specify the full path for the fdisk binary? You seem to be doing so for everything else. Another thing - some of the stuff that runs in init like adbd is statically linked; I haven't looked into if that is a requirement, or just a precaution to make debugging still work if the dynamic libraries aren't available in a broken install. – Chris Stratton Jun 1 '11 at 16:04
  • Answering our question: I have no permission to execute the script. The device is not rooted. I suppose that it will not be a problem when running it through init.rc. – Void Jun 1 '11 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.