You are not logged in.

#1 2009-10-12 15:31:32

Rad3k
Member
From: Poland
Registered: 2009-05-09
Posts: 36

Mkinitcpio hook for early access to MMC/SD cards

Hello everyone smile

Here's a tiny hook for mkinitcpio, useful when you want to do something with MMC/SD card reader (internal, not usb-based) at boot time.
Personally, I use it together with "encrypt" hook to read the disk encryption key from SD card (easier to carry around and not as visible as usb stick).
It's on AUR: http://aur.archlinux.org/packages.php?ID=31150

I hope someone will find it useful.

Offline

#2 2009-10-12 18:07:30

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: Mkinitcpio hook for early access to MMC/SD cards

cool idea!I have an old 16MB stick somewhere. sounds perfect for such a project. do you mind telling me how you do it exactly?

cheers
Barde

Offline

#3 2009-10-12 18:10:10

fijam
Member
Registered: 2009-02-03
Posts: 244
Website

Re: Mkinitcpio hook for early access to MMC/SD cards

Also, perhaps this could be merged upstream? You might want to post to arch-general instead of maintaining this in aur.

Offline

#4 2009-10-12 21:14:14

Babets
Member
Registered: 2008-02-07
Posts: 47

Re: Mkinitcpio hook for early access to MMC/SD cards

Rad3k, you could change the url in your pkgbuild to point on this thread, so if someone have troubles can post here smile

fijam wrote:

Also, perhaps this could be merged upstream? You might want to post to arch-general instead of maintaining this in aur.

I absolutely agree!

Offline

#5 2009-10-12 21:28:38

Rad3k
Member
From: Poland
Registered: 2009-05-09
Posts: 36

Re: Mkinitcpio hook for early access to MMC/SD cards

Heller_Barde
Do you mean, how I've made this hook, or the whole encryption setup?
If the former, then it's no big deal:
First I looked at the existing usb hook, and used it as a base for this one. Then, I wrote simple udev rule to load all modules needed for card reader to work. Just look at the files - there are two of them, both only few lines long. The most difficult part was understanding first how the hooks work, and all the udev stuff, to know what I actually need to make my own.

fijam
I considered this, but I didn't know what exactly should I do, and posting it in AUR and this forum seemed the best thing to do first.

Babets
Good idea, I'll change the url.

Offline

#6 2009-10-12 21:36:27

flamelab
Member
From: Athens, Hellas (Greece)
Registered: 2007-12-26
Posts: 2,160

Re: Mkinitcpio hook for early access to MMC/SD cards

Inform the devs, it's a good idea.

Offline

#7 2009-10-12 22:09:51

Rad3k
Member
From: Poland
Registered: 2009-05-09
Posts: 36

Re: Mkinitcpio hook for early access to MMC/SD cards

Ok, I've updated the PKGBUILD (and also made it somewhat conformant to Arch Packaging Guidelines wink )

The most important thing is now: Does this work for someone else than me?
I just want to know if I didn't forget to include something in the package. So, if someone tested it, any feedback would be appreciated.

Offline

#8 2009-10-12 22:54:52

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Mkinitcpio hook for early access to MMC/SD cards

If you want it considered for merging into the mkinitcpio package, post a feature request in the bugtracker with all the details.

Offline

#9 2009-10-13 18:56:38

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: Mkinitcpio hook for early access to MMC/SD cards

Rad3k wrote:

Heller_Barde
Do you mean, how I've made this hook, or the whole encryption setup?

I was referring to your whole setup. Like what file belongs on that card and stuff. E-Mail or PM me, this thread is probably not the right place.

cheers Barde

Last edited by Heller_Barde (2009-10-13 18:57:02)

Offline

#10 2009-10-13 19:40:20

fijam
Member
Registered: 2009-02-03
Posts: 244
Website

Re: Mkinitcpio hook for early access to MMC/SD cards

Heller_Barde wrote:
Rad3k wrote:

Heller_Barde
Do you mean, how I've made this hook, or the whole encryption setup?

I was referring to your whole setup. Like what file belongs on that card and stuff. E-Mail or PM me, this thread is probably not the right place.

cheers Barde

Why not? It's relevant, and I am curious as well.

Offline

#11 2009-10-13 20:42:09

Rad3k
Member
From: Poland
Registered: 2009-05-09
Posts: 36

Re: Mkinitcpio hook for early access to MMC/SD cards

As for encryption setup, this was my primary source of information:
http://wiki.archlinux.org/index.php/Sys … r_dm-crypt

The setup is basically as follows:
All partitions (except one) are encrypted using LUKS, but each separately (no LVM or anything like that, they're plain partitions).
One small partition is left unencrypted and used as /boot .
"encrypt" hook in mkinitcpio is enabled in order to boot from encrypted root.
Encryption keys for partitions other that root are stored in /etc/crypttab .
Boot command line has "cryptdevice=/dev/encrypted root partition:root" and "root=/dev/mapper/root" set.

This is sufficient for booting with passphrase.
I've decided not to store a key on SD card in a file, but to hide it between MBR and first partition, like explained in wiki: http://wiki.archlinux.org/index.php/Sys … _partition
To properly do this, you have to be careful - for example, depending on the length of your key, there may be not enough space for it. Sometimes this can be "fixed" by playing with geometry settings of your card in cfdisk. Generally, you'll rather want to know well what you're doing. It took me some time to figure where exactly I can put the key, and it involved using hex editors, calculating size and offset (converting values between bytes and blocks), but telling you the numbers is pointless, because they vary between different setups.

So, once I put the key on a card, I've added "cryptkey=/dev/mmcblk0:offset:size", and of course enabled mmc hook in mkinitcpio. Now I only have to plug the card for a few seconds at the boot time, no typing passwords. I have to admit that it's pretty convenient that way, and in most circumstances much more secure than typing passwords all the time.

Offline

#12 2010-02-24 20:27:04

buq2
Member
Registered: 2010-02-24
Posts: 1

Re: Mkinitcpio hook for early access to MMC/SD cards

Rad3k wrote:

The most important thing is now: Does this work for someone else than me?

I just installed arch on my netbook (HP Mini 5101) and your contribution works perfectly. Thank you smile
I would like to add that I had to use /dev/disk/by-uuid/xx instead of /dev/sdb1 to get it working reliably.

Offline

#13 2010-02-24 20:55:32

Rad3k
Member
From: Poland
Registered: 2009-05-09
Posts: 36

Re: Mkinitcpio hook for early access to MMC/SD cards

I'm glad that you find it useful smile

Now that I know it works (not only for me, that is), maybe I'll consider poking devs to include it in base mkinitcpio package. But as I'm either busy or lazy person most of the time, I really don't know when it might happen wink If someone else felt like doing this, I have nothing against. Just Share & Enjoy smile

Offline

#14 2010-03-19 00:23:52

pielgrzym
Member
Registered: 2010-02-18
Posts: 49

Re: Mkinitcpio hook for early access to MMC/SD cards

Thanks for the hook! Works flawlessly smile

I'd like to mention a thing that might be not so obvious to anyone: you have to include proper modules in MODULE array in mkinitcpio.conf. In my case it was sd_mod.

Great work, thanks again smile

Offline

#15 2010-03-19 07:46:39

Rad3k
Member
From: Poland
Registered: 2009-05-09
Posts: 36

Re: Mkinitcpio hook for early access to MMC/SD cards

You're welcome smile
There's a couple of things that bug me though. I assume you tried and it didn't work without the hook. It seems a bit strange that you had to add sd_mod to mkinitcpio.conf - the modules for card reader are supposed to be taken care of in the hook itself. So, if you're using integrated reader you shouldn't need sd_mod (I may be wrong though, it's based only on my experience, not on an in-depth knowledge of kernel drivers). If your card reader is usb based (some internal card readers are) then you shouldn't need this hook to make it work. There's a usb hook for mkinitcpio. It includes sd_mod, so maybe you could try using this one instead of mine and see if it works.

Offline

Board footer

Powered by FluxBB