[solved]How to unlock LUKS using keyfile on usbdrive during boot?

Hi all,
I would like some advise for booting encrypted partitions using kefiles on a flashdrive. I'm setting up a Intel Atom based homeserver, and and want my data to be encrypted in case the server gets stolen. To save some encryption overhead I prefer to leave root unencrypted and only encrypt /home, and if this works, later on /var, /tmp and swap as well. My plan is to have a keyfile on a flash thumbdrive, and only have the thumbdrive plugged in while booting.
I have read the dm-crypt wiki page, but it assumes an encrypted root, and this approach won't work in my situation, where only non-root mountpoints are encrypted. If i put 'ASK' in /etc/crypttab I get prompted for the passphrase and the LUKS container unlocks and mounts fine. I can also unlock the LUKS container manually using the keyfile that I created. However when I put the path to the keyfile in /etc/crypttab instead of 'ASK', and let the usbdrive automount using an udev rule the unlock at boot fails. It seems that my udev rule is only executed when I plug in a drive after booting, not when it is already plugged in during boot. How would I accomplish this? Mount it with fstab and automatically unmount it after booting, or some entirely different way?
my /etc/fstab:
none /dev/pts devpts defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/sda1 / ext4 defaults 0 1
/dev/sda2 swap swap defaults 0 0
/dev/mapper/home /home ext4 defaults 0 1
/etc/crypttab:
home /dev/sda3 /media/usbhd-sdc1/keyfiles/arch_server_-_home.key
/etc/udev/rules.d/01.usbdrive_automount.rules (sdb is a second, currently unused harddisk):
KERNEL=="sd[b-z]", NAME:="%k", SYMLINK+="usbhd-%k", GROUP:="users", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[c-z][0-9]", SYMLINK+="usbhd-%k", GROUP:="users", NAME:="%k"
ACTION=="add", KERNEL=="sd[c-z][0-9]", RUN+="/bin/mkdir -p /media/usbhd-%k"
ACTION=="add", KERNEL=="sd[c-z][0-9]", PROGRAM=="/sbin/blkid -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,flush,dirsync,noexec,nodev,noatime,dmask=000,fmask=111 /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[c-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,async,dirsync,noexec,nodev,noatime /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sd[c-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k"
ACTION=="remove", KERNEL=="sd[c-z][0-9]", RUN+="/bin/rmdir /media/usbhd-%k", OPTIONS="last_rule"
<edit>
Okay I have found a solution. The trick was to make sure the usbstick gets mounted first, so the keyfile is available for the unlocking/mounting during boot. To do so I have added 'usb' to the hooks line in /etc/mkinitcpio.conf and recompiled the initramfs as described in the wiki link above.
Next I changed my /etc/udev/rules.d/01.usbdrive_automount.rules a little so that the mountpoint of the usbdrive stays after unplugging it:
KERNEL=="sd[b-z]", NAME:="%k", SYMLINK+="usbhd-%k", GROUP:="users", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[c-z][0-9]", SYMLINK+="usbhd-%k", GROUP:="users", NAME:="%k"
ACTION=="add", KERNEL=="sd[c-z][0-9]", RUN+="/bin/mkdir -p /media/usbhd-%k"
ACTION=="add", KERNEL=="sd[c-z][0-9]", PROGRAM=="/sbin/blkid -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,flush,dirsync,noexec,nodev,noatime,dmask=000,fmask=111 /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[c-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,async,dirsync,noexec,nodev,noatime /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sd[c-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k", OPTIONS="last_rule"
#ACTION=="remove", KERNEL=="sd[c-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k"
#ACTION=="remove", KERNEL=="sd[c-z][0-9]", RUN+="/bin/rmdir /media/usbhd-%k", OPTIONS="last_rule"
/etc/fstab:
The usbdrive is put above the encrypted partition to make it get mounted first:
none /dev/pts devpts defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/sdc1 /media/usbhd-sdc1 ext2 defaults 0 0
/dev/sda1 / ext4 defaults 0 1
/dev/sda2 swap swap defaults 0 0
/dev/mapper/home /home ext4 defaults 0 1
/etc/crypttab:
home /dev/sda3 /media/usbhd-sdc1/keyfiles/arch_server_-_luks.key
So now I plug in the flashdrive, turn on the server, unplug the flashdrive and udev automatically unmounts the flashdrive while leaving the mountpoint /media/usbhd-sdc1 for the next boot.
</edit>
Last edited by rwd (2009-12-04 19:36:14)

graysky wrote:@ratcheer - You can try now if it's a major pain in the balls by enabling [testing] and using the updated linux package.
If you do enable testing make sure you aren't like myself: I'm not competent enough to enable testing..
Edit:
To elaborate a bit.  If you enable testing and then just do a "pacman -Syu" then you are going to pull in all sorts of packages you may not want and it may be complicated to get rid of later.  To avoid this I would enable testing, do this:
sudo pacman -Syy
sudo pacman -S testing/linux
So it would pull in the absolute minimum that I wanted from testing.  Then I would disable the testing repository and pacman -Syy again.  That would convert the new linux package and packages it requires to manual packages.  E.g. they would be shown under "pacman -Qm"
Because once you start pulling packages in from testing it is almost a one-way street.  As I instructed above, that is my gross understanding.  I don't use testing at all, it is supposed to be used if you are actively testing Arch and providing feedback while doing so.
Last edited by headkase (2012-10-03 01:51:51)

Similar Messages

  • How to unlock an used iBook?

    How can unlock an used iBook ?

    Which exact iBook model is it?
    You can choose from this list:
    http://www.everymac.com/systems/apple/ibook/index-ibook.html
    Which version of the operating system is it running now (if you know)?
    What happens when you try to start up?

  • [Solved] How to list recently used windows?

    I like the Unity feature where a key binding either opens or focuses an application window. With KDE I can define a keyboard shortcut which, for example, performs
    wmctrl -xa emacs.Emacs || emacs
    However, I'd like it to focus on the last focused window, not the first opened window. Is there a command to list all windows in the order they were recently used? (Clearly the Task Switcher gets this information from somewhere.)
    Last edited by raul_l (2014-12-16 16:58:24)

    The command I was looking for is
    xprop -root | grep "^_NET_CLIENT_LIST_STACKING"
    If anyone is interested, this script
    #!/bin/bash
    app=$1
    workspace=$(wmctrl -d | grep '\*' | cut -d ' ' -f1)
    win_list=$(wmctrl -lx | grep $app | grep " $workspace " | awk '{print $1}')
    IDs=$(xprop -root|grep "^_NET_CLIENT_LIST_STACKING" | tr "," " ")
    IDs=(${IDs##*#})
    for (( idx=${#IDs[@]}-1 ; idx>=0 ; idx-- )) ; do
    for i in $win_list; do
    if [ $((i)) = $((IDs[idx])) ]; then
    wmctrl -ia $i
    exit 0
    fi
    done
    done
    exit 1
    in conjunction with the key binding
    the_above_script.sh emacs.Emacs || emacs
    produces the correct Unity behavior. (How to mark this thread solved?)
    EDIT: I modified the script a little bit. It turns out wmctrl and xprop use slightly different formats for displaying hexadecimal numbers.
    Last edited by raul_l (2014-12-17 12:08:07)

  • [SOLVED]How can I setWhereClause using a session value ?

    I have a session value that I want to use to pass as the bind variable to my Where clause on a View object.
    I have dragged the view from the data control pallete onto my page as an ADF form.
    I need to be able to set the Where clause of this view programmatically but I don't know where I should do this. Basically on entering this page the where clause should get set programmatically to the session value.
    I thought about creating a static block in my page's backing bean and doing it there but how would I access the view object from there ?
    Or should I create a Service method that sets the where clause and does an executeQuery and expose that to my page and execute it from my page's backing bean ?
    cheers

    Hi Dom,
    If you are using Oracle's binding layer - you could add a binding for "ExecuteWithParams" to the pagedef (right-click the bindings folder, add action binding, pick your View Object, choose execute with parameters as action); use an EL expression based upon sessionScope as the value for the bind variable.Then, add an invokeAction to the pageDef (right-click executables folder, choose invokeAction), specifying your executeWithParams binding as the binds property.
    Hope this gets you started.
    John

  • How to unlock and use HR , OE users

    hello gurus ,
    I am using oracle 10g , I installed database using option 'adavanced' , I wanna use HR and OE user for practice but can't access these account , I used these commands
    ALTER USER hr IDENTIFIED BY hr ACCOUNT UNLOCK;
    GRANT CONNECT, RESOURCE to hr;
    ALTER USER oe IDENTIFIED BY OE ACCOUNT UNLOCK;
    GRANT CONNECT, RESOURCE to OE;its shows error:
    user doesn't exist in system....
    I am connected to sql * plus using sys/<pasword> as sysdba
    what should I do ,
    thanks

    yeah that can be the reason because while installing database I left sample schema unchecked ,
    is there any solution for practice , means can I find any thing , user , schema , or any backup file in which lots of entries are already inserted , actually I just wanna practice on fetching records using SQL queries for practice ,
    or should I re-install the database ?

  • How to unlock ipod using voice contol

    how to ulnlock my ipod 4th gen usin voice control..pls help

    You do not.
    You have to slide to unlock/enter passcode to unlock
    if you
    Forgotten Screen-Lock Passcode
    Connect the iOS device to your computer and try to make a backup
    iOS: How to back up
    Then restore via iTunes. The iOS device will be erased. Place the iOS device in Recovery Mode if necessary to allow the restore.
    If recovery mode does not work try DFU mode.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up    
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store    

  • HOW TO UNLOCK TO USE ABROAD

    I'm going out of the country in a month; just wondering if it was possible to unlock my iphone 4s so I may use it there?!! my current servicers is with AT&T and I don't want to pay for roaming.

    carl wolf wrote:
    Regardless, virtually all carriers do have international access numbers that allow you to use your phone, without roaming charges.
    I've never heard of such a thing. Verizon certainly doesn't. If you use the phone while abroad, you pay roaming fees. Where are you getting this infomation?
    Thanks!

  • [SOLVED] Does systemd/arch append -n to a mount during boot?

    Hi all,
    I tried gdrivefs from AUR:
    https://aur.archlinux.org/packages/gdrivefs/
    When I put an the following line into the fstab
    /var/cache/gdfs.creds /mnt/gdrivefs gdfs allow_other 0 0
    I get this error:
    Mär 29 23:39:25 c64 mount[294]: usage: mount.gdfs [-h] [-d] [-o OPT] auth_storage_file mountpoint
    Mär 29 23:39:25 c64 mount[294]: mount.gdfs: error: unrecognized arguments: -n
    Mär 29 23:39:25 c64 systemd[1]: mnt-gdrive.mount mount process exited, code=exited status=2
    Apparently, someone adds a "-n" option to the mount command.
    Interestingly, if I add this line after boot to the fstab,
    mount /mnt/gdrivefs
    works. I reported a bug upstream to add a dummy "-n" option to gdfs. However, the maintainer is wondering who actually adds this "-n" option:
    https://github.com/dsoprea/GDriveFS/iss … t-87722639
    Any systemd experts around who have a clue about what's going on and/or can hint me to some documentation?
    Last edited by knue (2015-03-31 14:56:33)

    systemd does require /etc/mtab to be a symlink to /proc/self/mounts and that is read-only, so passing -n seems to make sense.
    Furthermore, the man page mount(8) describes the interface for external helpers as follows:
    EXTERNAL HELPERS
           The syntax of external mount helpers is:
                  /sbin/mount.suffix  spec  dir [-sfnv] [-o options] [-t type.sub‐
                  type]
           where the suffix is the filesystem type and the -sfnvo options have the
           same  meaning  as  the normal mount options.  The -t option is used for
           filesystems with subtypes  support  (for  example  /sbin/mount.fuse  -t
           fuse.sshfs).
           The  command mount does not pass the mount options unbindable, runbind‐
           able, private, rprivate, slave, rslave, shared, rshared, auto,  noauto,
           comment, x-*, loop, offset and sizelimit to the mount.<suffix> helpers.
           All other options are used in a comma-separated list as argument to the
           -o option.
    Apparently the gdfs helper does not fully implement that interface.

  • Hello, i recently bought an iPod 5th Generation and it came with a passcode which i did not know of, it is now disabled and i am wondering how to unlock the iPod

    Hello, i recently bought an ipod touch 5th generation and it came with a passcode which i did not know, it is now disabled and i am wondering on how to unlock it using itunes on the computer

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software
    If problem what happens or does not happen and when in the instructions? When you successfully get the iPod in recovery mode and connect to computer iTunes should say it found an iPod in recovery mode.
    However, you will likely run again the Activation Lock
    iCloud: Find My iPhone Activation Lock in iOS 7
    You either have to get the Apple ID and password of the previous owner and enter it or have them remove the iPod from their account.
    Find My iPhone Activation Lock: Removing a device from a previous owner’s account

  • After a clean install, how can I continue using Time Machine?

    After a clean install, how can I continue using Time Machine?
    I booted from my recovery partition, erased my HD, installed the same OS, (Lion, 10.7.5) then restored from my TM.
    If it asks if i want to use TM, I say yes. When I chose the drive, it seems to want to start all over, instead of just picking up where I left off.
    Is there any way of picking up where I left off?

    Hi Frank,
    You are sure you looking in your Library in /Users/YOUR_USERNAME/Library and not /Library at the top level of your harddrive?
    When you open iCal what do you see?  Are the calendars the two default Home and Work ones?
    I really appreciate the responses -- especially if you are in the UK as opposed to Ontario.
    Why, do you have something against London Ontario?
    John M

  • [SOLVED] How to Connect to a Linksys Switch

    Does anyone know how I can connect to a linksys ethernet switch? It seems dhcp isn't working....
    Last edited by tony5429 (2009-07-27 22:03:30)

    tony5429 wrote:Sorry; I was in a hurry when I posted the question. The switch is not connected to the internet. I tried connecting to it the way I've always connected to routers in the past - using the network daemon during boot-up. But this time it failed - I think I got a dhcp timeout notification. In my /etc/rc.conf I have eth0="dhcp" and INTERFACES=(eth0). I also tried using WICD which I have installed on the computer (it's a laptop with a wifi chip) by enabling the wicd daemon, disabling the network daemon and blacklisting the eth0 interface; but when WICD tried to connect to the switch, I got an error saying it was unable to acquire an IP address. Please correct me if I am wrong but I suspect this all means I am going to need to specify my own static IP address as the switch is not going to assign one to me automatically. If that is the case, how do I go about specifying my own IP address? Thanks!!
    As mentioned by arkham, switches operate at Layer 2, which isn't aware of IP addresses (Layer 3). So if this is actually a switch (not a router) then no, you won't be able to get a DHCP lease from it since it's not running a DHCP server.
    If there's nothing else on your network acting as a DHCP server, which it doesn't sound like there is, then you'll need to set a static IP.
    # Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
    # Interfaces to start at boot-up (in this order)
    # Declare each interface then list in INTERFACES
    #   - prefix an entry in INTERFACES with a ! to disable it
    #   - no hyphens in your interface names - Bash doesn't like it
    # DHCP:     Set your interface to "dhcp" (eth0="dhcp")
    # Wireless: See network profiles below
    eth0="eth0 10.16.1.175 netmask 255.255.255.0 broadcast 10.16.1.255"
    INTERFACES=(eth0)

  • HT201328 i had brough a used set iphone 4s from japan, how to unlock so that i can use in malaysia

    i had brough a used set iphone 4s from japan, how to unlock so that i can use in malaysia.
    PLs help i u have any ideal /way to solve. Thanks.

    if the carrier it's locked to will let you then yes
    otherwise no
    they are the only ones who have the power

  • How to undo "This solved my question" on this Using iPhone forum?

    How to undo "This solved my question" on this "Using iPhone" forum?
    new to this forum... how do you undo this?

    **** lol, In that case they should give a warning or some type of "You sure?" yes/no. I clicked completely by mistake. anyways...

  • HT1311 i sold my iphone and i cant figure out how to unlock it so it can be used.  can anyone help??

    i recently sold my iphone and it is locked so it cannot be used.  cant figure out how to unlock it....can anyone help??

    wilser01 wrote:
    i recently sold my iphone and it is locked so it cannot be used.  cant figure out how to unlock it....can anyone help??
    Did you erase it before you sold it?
    Settings> General > Reset - Erase all content & settings.
    Or did you leave all your personal info on it and give it to someone else?

  • How can I buy an iphone 4 unlocked to use it in my country

    Hello
    I want to ask how can I buy an iphone 4S unlocked to use it in my country. (Argentina), It is posibble?
    Thanks,  I'm waiting for your answer.

    If you buy an unlocked phone in a country other than your native one, the warranty will only apply in the country you bought it in.

Maybe you are looking for

  • Stock Ledger Report

    HI, There is any Stock Ledger Report material Wise and Date Wise with Opening , issue, Receipt & Closing Qt available. With details Shown Below Material Code, Date, Material Document, Goods Movement Qty, Opening stock, receipt, Issues, Closing Stock.

  • What happened to the zoom bar that lets me increase the size from, say, 100% to 125%? I just installed Firefox, and I no longer find that feature.

    A week or so ago I thoughtlessly installed Explorer 10 (Chrome 10?) and immediately began having problems with my google email page and one program I use through email. I got a message that I could not download Explorer 9 to reinstall it, because the

  • Add attachments using workflow api throwing error

    Hi, I am getting the following error when i am trying to add attachments using worklist API.      Missing class: invokeBPEL.MetaData      Dependent class: com.evermind.io.ClassLoaderObjectInputStream      Loader: oc4j:10.1.3      Code-Source: /D:/pro

  • Total Payable, Balances and Information Elements in SOE

    Hi All, In the SOE report, I am unable to see Total Payable(difference of Total Earnings and Total Deductions), Balances and Information elements. Can anyone please tell me how to get those in the SOE. Thanks in Advance,

  • Help on Report Layout Variant.

    Hello, I have a requirement as stated below: I have a custom report and it displays say 15 fields. I have created a variant for it to display only 10 fields. Now, is there a Function Module or a report that will give me details of these 10 fields tha