Danke an absolut für die angebotene Hilfe.
Ich habe mir heute mal Zeit genommen und versucht mich in die Welt des neuen Systemd einzulesen. Leider nicht wirklich erfolgreich.
Hier nun einige meiner Versuche:
Leider hat mein USB-Stick mit dem Schlüssel nicht lange durchgehalten, den Anfang des Sticks mit Zufallsdaten zu überschreiben scheint das Dateisystem nicht auf Dauer vertragen zu haben. Ich habe die Vorlage aus der oben genannten Webseite etwas abgewandelt und habe den Schlüssel an das unpartitionierte Ende kopiert. Ich habe das mal alles mitprotokolliert.
Kontrolle des USB-Stick:
# fdisk -l /dev/sdh
Disk /dev/sdh: 1,9 GiB, 2013265920 bytes, 3932160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x054bdde4
Device Boot Start End Sectors Size Id Type
/dev/sdh1 * 2048 3930111 3928064 1,9G 6 FAT16
Den Schlüssel, der bereits im Luksheader hinterlegt ist, auf den USB-Stick kopiert:
# dd if=/root/key of=/dev/sdh bs=512 seek=3930161
4+0 Datensätze ein
4+0 Datensätze aus
2048 Bytes (2,0 kB) kopiert, 0,00118767 s, 1,7 MB/s
Die ID des USB-Sticks abfragen:
# ls -l /dev/disk/by-id/
lrwxrwxrwx 1 root root 9 Sep 27 13:59 usb-Generic_Flash_Disk_CCBB1206251346300122371807-0:0 -> ../../sdh
Die /etc/cryptab anpassen.
# <target name> <source device> <key file> <options>
#cryptsda3 UUID="1c2cfd04-bbbf-4260-a700-d765c74ff79c" /dev/disk/by-id/usb-Generic_Flash_Disk_CCBB1206251346300122371807-0:0 luks,tries=1,keyfile-size=2048,keyfile-offset=2012242432
cryptsda3 UUID="1c2cfd04-bbbf-4260-a700-d765c74ff79c" LABEL=FAT luks,keyfile-offset=2012242432,keyfile-size=2048,hash=sha256
cryptmd0 UUID="dc11d569-b9df-4201-a66a-25739cadd837" /root/cd0 luks
Ich habe unterschiedliche Einstellungen und Optionen durch probiert, ohne Erfolg.
Die /etc/default/cryptdisks habe ich wieder in den Urzustand versetzt. Ich vermute, das man hier ein Dateisystem mounten kann auf dem der Schlüssel als Datei ablegt ist. Auch das hatte ich versucht, bin aber gescheitert. Wenn ich in der fstab einen Mountpunkt für den USB-Stick angebe, wird dieser im Hauptsystem gemountet, nicht aber in der RAMdisk.
# Run cryptdisks initscripts at startup? Default is Yes.
CRYPTDISKS_ENABLE=Yes
# Mountpoints to mount, before cryptsetup is invoked at initscripts. Takes
# mountpoins which are configured in /etc/fstab as arguments. Separate
# mountpoints by space.
# This is useful for keyfiles on removable media. Default is unset.
CRYPTDISKS_MOUNT=""
#CRYPTDISKS_MOUNT="/dev/disk/by-id/usb-Generic_Flash_Disk_CCBB1206251346300122371807-0:0-part1"
# Default check script. Takes effect, if the 'check' option is set in crypttab
# without a value.
CRYPTDISKS_CHECK=blkid
# Default precheck script. Takes effect, if the 'precheck' option is set in
# crypttab without a value.
# Default is 'un_blkid' for plain dm-crypt devices if unset here.
CRYPTDISKS_PRECHECK=
Den USB_Stick in die /etc/fstab einzubinden, nützt nichts. Dieser erscheint nach dem booten im Verzeichnis /usb, wird aber von der Initramfs anscheinend ignoriert:
# <file system> <mount point> <type> <options> <dump> <pass>
# USB-Key
#/dev/disk/by-id/usb-Generic_Flash_Disk_CCBB1206251346300122371807-0:0-part1 /usb vfat utf8 0 0
# (root) /dev/VGsys/LVroot, Block device 253:1, LV-UUID FSoLkW-sXA3-hbLh-H0rL-ndvL-9az3-Gx5y04
UUID=34caf3d6-17f4-4ed9-904e-b5639e504f9f / ext4 defaults,noatime,errors=remount-ro 0 1
# sda2 /boot -Partition
UUID=fc6972d9-5de9-4c38-8090-86eee965b960 /boot ext4 defaults,noatime,errors=remount-ro 0 2
# sda1 EFI-Partition
# UUID=353A-9BD6 /boot/efi vfat utf8 0 0
# /home /dev/mapper/cryptmd0
UUID="bca08917-e956-40bf-ad1a-fb62e101158c" /home ext4 defaults,noatime,errors=remount-ro 0 2
# (swap) /dev/VGsys/LVswp, Block device 253:2, LV-UUID dE0Jh7-PVs0-GexD-nhMT-AiZ3-v1n4-BZ3wfM
UUID=0ebf9a48-c88c-4316-aec9-143c64a4b099 none swap sw 0 0
In /etc/default/grub habe ich ein rootdelay angegeben, leider auch ohne Auswirkungen:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT=2
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX="cryptopts=source=UUID=1c2cfd04-bbbf-4260-a700-d765c74ff79c,target=cryptsda3,lvm=/dev/VGsys/LVroot,rootdelay=10"
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=1920x1080
GRUB_GFXPAYLOAD_LINUX=keep
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
Zum Schluss die Generatoren für Systemd gestartet:
# systemctl --system daemon-reload
den Grub geupdatet:
# update-grub
und eine neue Initramfs erstellt:
# update-initramfs -u -k 4.2.1-towo.1-siduction-amd64
update-initramfs: Generating /boot/initrd.img-4.2.1-towo.1-siduction-amd64
cryptsetup: WARNING: target cryptsda3 uses a key file, skipped
Die Warnmeldung stört mich etwas weil da steht „skipped“, ich bin aber nicht sicher ob das wirklich relevant ist. Der Schlüssel ist ja nicht direkt dort.
Leider habe noch nicht herausgefunden, wie ich den Bootlog aus dem Initramfs aufzeichnen kann. Ich hab mal ein Bildschirmfoto nach der altmodischen Art gemacht, hier die Meldungen:
cryptsetup: cryptsetup failed, bad password or options?
/scrips/local-top/cryptroot: /scrips/local-top/cryptroot: line 1: line 1: /lib/cryptsetup/askpass: not found/sbin/cryptsetup: not found
cryptsetup: cryptsetup failed, bad password or options?
lvmetad is not active yet, using direct activation during sysinit
Volume group „VGsys“ not found
Cannot process volume group VGsys
Gave up waiting for root device. Common problems:
- Boot args (cat /proc/cmdline)
- Check rootdelay= (did the system wait long enough?)
- Check root= (did the system wait for the right device?)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/mapper/VGsys-LVroot does not exist. Dropping to a shell!
Könnte sein, das Cryptsetup gar nicht im Initramfs funktioniert? Das LVM kann natürlich nicht aktiv werden wenn die Partition noch nicht zur Verfügung steht. Die Kernel-Module sollten alle da sein, in der /etc/initramfs-tools/initramfs.conf ist der Eintrag MODULES=most gesetzt. Wenn ich in der /etc/crypttab unter <key file> „none“ eintrage, werde ich nach der Passphrase gefragt. Das aufschließen der Partition und anschließende starten des LVM funktioniert einwandfrei. Das Einbinden des RAID mit /home macht keine mucken. Alles wäre wunderschön, wenn die nervige und unsichere Aufforderung zur Passphrase nicht wäre. Es muss doch möglich sein da irgendwie ein Keyfile auf einem externen Medium für einzusetzten.
Ich habe beim durchstöbern einen systemd-cryptsetup-generator gefunden. Ich bin aber noch nicht ganz dahinter gestiegen, wie der funktioniert. In der Man-Page steht etwas von einer „rd.fstab“, die nur vom Initramfs ausgewertet wird. Kann man irgendwo eine spezielle fstab einrichten für meinen USB-Stick?
Das neue Systemd scheint ja nicht schlecht zu sein, aber nur für Leute, die die Zeit haben sich darin einzuarbeiten. Gibt es noch andere wichtige Konfig-Dateien, eventuell wichtig sind?
Vielen Dank schon mal für Hinweise und Hilfen.