Skip to content

Instantly share code, notes, and snippets.

@lucaswerkmeister
Last active December 24, 2016 16:46
Show Gist options
  • Save lucaswerkmeister/a835a2b325f894a856d0533b79cba273 to your computer and use it in GitHub Desktop.
Save lucaswerkmeister/a835a2b325f894a856d0533b79cba273 to your computer and use it in GitHub Desktop.
Make your Arch Linux device emit ownership information on boot

Make your Arch Linux device emit ownership information on boot

Scenario: You’ve lost your device. Actually Honest Achmed finds it, and would like to return it to you. However, the label that you had carefully attached to your device was ripped off. How does Achmed know who to return the device to? He attempts to boot the device, but since you use full-disk encryption (you do use full-disk encryption, don’t you?), that doesn’t get him any further than the decryption password prompt. Fortunately, you have arranged for a simple message to be printed before that prompt, which tells Achmed how to contact you about the device he found:

  1. Create the file /etc/initcpio/install/owner with the following content:

    #!/bin/bash
    
    build() {
        add_runscript
    }
    
    help() {
        cat <<HELPEOF
    This hook prints information about the device's owner,
    so that someone who finds it can contact the owner to return it.
    HELPEOF
    }
    
    # vim: set ft=sh ts=4 sw=4 et:

    (This file, and the next one, don’t need to be executable: the default file mode works just fine.)

  2. Create the file /etc/initcpio/hooks/owner with the following content:

    #!/usr/bin/ash
    
    run_hook() {
        msg 'This device is the property of Lucas Werkmeister <[email protected]>.'
    }
    
    # vim: set ft=sh ts=4 sw=4 et:

    (Adjust line 4 to contain your information, of course.)

  3. Edit /etc/mkinitcpio.conf to insert owner in the HOOKS list, somewhere before the encrypt hook. (I put it between block and owner. If you’re feeling adventurous, you can probably try putting it at the very front, before even base, since the hook shouldn’t have any requirements.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment