New howto for encrypted systems
[infodrom.org/www.infodrom.org] / src / Debian / tips / debian-cryptroot-usb.wml
1 #include <infodrom.style>
2 #include <debian.style>
3
4 <page title="Debian Tips">
5
6 <h1 align=center>Howto install Debian encryptedly on a USB stick</h1>
7
8 <p>This is an extension to <a href="debian-usb.html">Howto install
9 Debian on a USB stick</a>.  Filesystem options apply to an encrypted
10 system as well.  If you are unable to add these options during
11 installation you can always alter <code>/etc/fstab</code> later.</p>
12
13 <p>The installation of Debian on an encrypted USB stick is very easy.
14 Starting with Debian GNU/Linux 5.0 alias <code>lenny</code> the
15 installation automatically supports encrypted LUKS containers that
16 contain swap space and the root filesystem.</p>
17
18 <p>Hence, selecting the option "Guided - use entire disk and set up
19 encrypted LVM" as target will create a <code>/boot</code> partition of
20 255MB size and use the remaining space on the stick as encrypted LUKS
21 container for swap and the root filesystem.</p>
22
23 <p>After booting the new system the initial ramdisk will ask for the
24 password to unlock the encrypted container and continue with the
25 system boot process.  After adding the <code>rootdelay</code>
26 parameter to GRUB you will be able to boot into your new system.</p>
27
28 <p>A problem arises however, when Linux numbers your stick differently
29 than during the installation.  In that case the initial ramdisk cannot
30 unlock the proper container and the system cannot be bootet further.</p>
31
32 <p>You'll need an existing GNU/Linux system to rebuild the inital
33 ramdisk so that the proper container can be unlocked.  Mount the
34 <code>/boot</code> partition (probably <code>/dev/sdb1</code>) of your
35 USB stick and extract the initial ramdisk for inspection:</p>
36
37 <p><pre>
38   sudo mount /dev/sdb1 /mnt
39   mkdir /tmp/initrd
40   cd /tmp/initrd
41   zcat /mnt/initrd.img-2.6.26-2-686 | cpio -i
42 </pre></p>
43
44 <p>The file <code>/conf/conf.d/cryptroot</code> contains the mapping
45 between encrypted containers and filesystems.  The file looks like:</p>
46
47 <p><pre>
48   target=sda2_crypt,source=/dev/sda2,key=none,lvm=triste-root
49   target=sda2_crypt,source=/dev/sda2,key=none,lvm=triste-swap_1
50 </pre></p>
51
52 <p>You'll need to adjust the encrypted device names to use UUID as
53 well.  The <code>blkid</code> program will help you find out the
54 proper id.  After your adjustments the file should look like:</p>
55
56 <p><pre>
57   target=sda2_crypt,source=UUID=644399cc-e967-41e0-8d85-87d790cc13f8,key=none,lvm=triste-root
58   target=sda2_crypt,source=UUID=644399cc-e967-41e0-8d85-87d790cc13f8,key=none,lvm=triste-swap_1
59 </pre></p>
60
61 <p>After these adjustments the initial ramdisk needs to be rebuilt and
62 installed in <code>/boot</code> again:</p>
63
64 <p><pre>
65   cd /tmp/initrd
66   find . | cpio --dereference -o -H newc | gzip > ../initrd.img
67   sudo cp ../initrd.img /mnt/initrd.img-2.6.26-2-686
68 </pre></p>
69
70 </page>
71
72 # Local variables:
73 # mode: indented-text
74 # end: