Category: Linux
Encrypted Slackware on USB Stick
Lession for today is: We need an bootable Slackware 12.2 on an LUKS encrypted USB stick.
The encryption part is not that hard and well documented in README_CRYPT.TXT so i will concentrate on the things that are new.
UUID
Our USB stick needs to work on most desktop boxes so we cannot hardcode /dev/sda1 in /etc/fstab, /etc/crypttab or when creating our initrd. Sad but true Slackware 12.2 supports UUID only in /etc/fstab out of the box so i've needed to patch the missing pieces to get it working.
That patch is against /etc/rc.d/rc.6 scripts from current.
--- slackware-current/source/a/sysvinit-scripts/scripts/rc.6.orig 2008-12-02 21:32:00.000000000 +0100
+++ slackware-current/source/a/sysvinit-scripts/scripts/rc.6 2009-07-29 12:05:59.000000000 +0200
@@ -208,6 +208,11 @@
LUKS=$(echo $line | tr 't' ' ' | tr -s ' ' | cut -f1 -d' ')
DEV=$(echo $line | tr 't' ' ' | tr -s ' ' | cut -f2 -d' ')
OPTS=$(echo $line | tr 't' ' ' | tr -s ' ' | cut -f4 -d' ')
+
+ if echo $DEV | egrep -q "(LABEL=|UUID=)" ; then
+ DEV=`findfs $DEV`
+ fi
+
if /sbin/cryptsetup.static isLuks $DEV 2>/dev/null ; then
echo "Locking LUKS crypt volume '${LUKS}':"
/sbin/cryptsetup.static luksClose ${LUKS}
--- slackware-current/source/a/sysvinit-scripts/scripts/rc.S.orig 2009-04-22 04:48:39.000000000 +0200
+++ slackware-current/source/a/sysvinit-scripts/scripts/rc.S 2009-07-29 13:18:19.000000000 +0200
@@ -74,6 +74,7 @@
PASS="${LUKSARRAY[2]}"
OPTS="${LUKSARRAY[3]}"
LUKSOPTS=""
+ if echo $DEV | egrep -q "(LABEL=|UUID=)" ; then DEV=`findfs $DEV` ; fi
if echo $OPTS | grep -wq ro ; then LUKSOPTS="${LUKSOPTS} --readonly" ; fi
# Skip LUKS volumes that were already unlocked (in the initrd):
After you have applied that patch you can replace all device entries in /etc/fstab and /etc/crypttab with UUID entries. To find the UUID for your devices you can use blkid or tune2fs -l.
initrd
You have already created an initrd during the installation if you followed the encryption guide but that initrd cannot mount a root device per UUID. To get that feature we need to patch the init script of the initrd tree which is a shellscript in a small busybox environment. The base for that initrd is /usr/share/mkinitrd/initrd-tree.tar.gz and mkinitrd does not much more than extracting that archive, modify a few files with config parameters and put that all in an compressed cpio archive when you create a new initrd.
So you need to patch that init script in /usr/share/mkinitrd/initrd-tree.tar.gz. The init script from current which will soon get Slackware 13 already has LABEL support so i've taken that and added UUID and luksdev support.
--- slackware-current/source/a/mkinitrd/init.orig 2009-04-03 00:13:59.000000000 +0200
+++ slackware-current/source/a/mkinitrd/init 2009-07-29 12:05:12.000000000 +0200
@@ -79,10 +79,13 @@
luksdev=/dev/*)
LUKSDEV=`echo $ARG | cut -f2 -d=`
;;
+ luksdev=LABEL=*|luksdev=UUID=*)
+ LUKSDEV=`echo $ARG | cut -f2- -d=`
+ ;;
waitforroot=*)
WAIT=`echo $ARG | cut -f2 -d=`
;;
- root=LABEL=*)
+ root=LABEL=*|root=UUID=*)
ROOTDEV=`echo $ARG | cut -f2- -d=`
;;
resume=*)
@@ -137,11 +140,17 @@
/sbin/mdadm -A -s
fi
- # Find root device if a label was given:
- if echo $ROOTDEV | grep -q "LABEL=" ; then
+ # Find root device if a label or uuid was given:
+ if echo $ROOTDEV | egrep -q "(LABEL=|UUID=)" ; then
ROOTDEV=`findfs $ROOTDEV`
fi
+ if echo $LUKSDEV | egrep -q "(LABEL=|UUID=)" ; then
+ if findfs $LUKSDEV 1>/dev/null 2>/dev/null ; then
+ LUKSDEV=`findfs $LUKSDEV`
+ fi
+ fi
+
# Make encrypted root partition available:
# The useable device will be under /dev/mapper/
# Three scenarios for the commandline exist:
@@ -175,6 +184,12 @@
# Make encrypted root partition available (scenario 3):
# We have to handle cases here where the LUKS volume is created on a LV
if [ -x /sbin/cryptsetup ]; then
+ if echo $LUKSDEV | egrep -q "(LABEL=|UUID=)" ; then
+ if findfs $LUKSDEV 1>/dev/null 2>/dev/null ; then
+ LUKSDEV=`findfs $LUKSDEV`
+ fi
+ fi
+
if /sbin/cryptsetup isLuks ${LUKSDEV} 1>/dev/null 2>/dev/null ; then
# Only act if we could not open the LUKS device before (i.e. is on a LV):
if [ "x$CRYPTDEV" == "x" ]; then
findfs
Slackware current already includes findfs in the initrd busybox environment but for Slackware 12.2 you need a static compiled version of findfs which is part of e2fsprogs. So you have to include it in your /usr/share/mkinitrd/initrd-tree.tar.gz under bin or sbin.
let's create our initrd
mkinitrd -c -k 2.6.27.7-smp -m ext3:ehci_hcd:uhci_hcd:usb_storage
-f ext3 -r cryptroot -C UUID="ae04abe2-90f4-472c-9db6-ac0d2b14c4a5" -w 10
It's that easy. You need the USB kernel modules which are ehci_hcd uhci_hcd and usb_storage and wait a few seconds at boot until the drive appears so we add "-w 10" to wait for 10 seconds.
Don't forget to call lilo before rebooting and have fun with your mobile Slackware USB stick.
Programming, Linux : Read more : comments (0) : 29.07.2009 14:36
Ubuntu powernowd hangs ...
Was macht man wenn man Ubuntu oder eine seiner Abkömmlinge startet aber vor der Installation schon der powernowd das System einfriert? Den Bug dazu gibts auch: https://bugs.launchpad.net/ubuntu/+source/powernowd/+bug/48792
Beim Bootmenü F6 drücken und single als Boot Option hinzufügen. Damit kommt man ins Recovery Menue besser bekannt als Single User Mode. Die Option Drop to root shell prompt gibt einem eine root shell mit der sich folgendes ausführen lässt.
chmod -x /etc/init.d/powernowd*
init 2
Dieser Befehl verhindert das laden des beanstandeten powernow daemons und init wechselt den Runlevel auf 2 womit nun das gefixte System startet.
Linux : Read more : comments (0) : 06.07.2008 18:55
BlueLife ist Windows frei
Vor einigen Jahren habe ich schon damit begonnen meine Rechner im Netzwerk von Windows zu befreien. Angefangen hat es im Sommer 2004 mit einem RedHat 9.0 auf einem Server. Nach einer immer stärker werdenden Unzufriedenheit mit RedHat musste es dann aber recht schnell einem FreeBSD 5.4 weichen und seitdem wird auf Servern nichts anderes mehr verwendet.
Auf den Clients war das viel langwieriger und so hat es noch ganze 2 Jahre gedauert bis das erste Windows 2000 durch ein Open Source Betriebssystem ersetzt worden ist. Aber das war ein wichtiger Schritt den ich im Nachhinein schon viel früher hätte wagen sollen. Trotzdem hat es nocheinmal fast 2 weitere Jahre gedauert bis das letzte Windows endgültig verschwunden ist und gestern war es endlich so weit. Müttern zu erklären wieso jetzt einiges ander aussieht als früher und wieso es überhaupt notwendig ist das Betriebssystem und die Programme zu wechseln kann mühselig sein deshalb habe ich es in Etappen vollzogen und versucht ihr den Umstieg etwas zu erleichtern.
Angefangen hat es vor langer Zeit damit, dass ich ihr den Internet Explorer weggenommen und durch Firefox ersetzt habe. Etappenweise sind so einige Microsoft Produkte durch Open Source Lösungen ersetzt worden und gestern war die letzte Etappe bei der Windows einem Xubuntu 8.04 weichen musste. Für mich wäre es wohl nicht das richtige Betriebssystem aber Ubuntu hat eindeutig einen höheren WAF als FreeBSD also kann ich damit leben und freue mich einfach, dass ich jetzt hoch offiziell vollkommen Windows frei bin. Ein schönes Gefühl.
FreeBSD, Personal : Read more : comments (3) : 02.05.2008 22:26