Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Context/Resume:

  • 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
   disabled
   oneshot

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?

share|improve this question

migrated from stackoverflow.com May 31 '11 at 23:58

This question came from our site for professional and enthusiast programmers.

    
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
add comment

1 Answer 1

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

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.

share|improve this answer
    
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
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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