4
# Standard initramfs preamble
22
# When changing this, don't forget to update the copy in
23
# initramfs-tools-hook, as well as the list of all known cipher
24
# modules in the iterate_cipher_module call near the end of
25
# initramfs-tools-hook.
39
echo "WARNING| (loop-aes) Don't know how to handle encryption type $1" 1>&2
42
echo "WARNING| (loop-aes) Unknown encryption type $1" 1>&2
49
# Do we have any settings from the /conf/conf.d/loopaesroot file?
50
[ -r /conf/conf.d/loopaesroot ] && . /conf/conf.d/loopaesroot
51
loopaes_opts="${LOOPAESOPTS}"
53
# Does the kernel boot command line override them?
54
for x in $(cat /proc/cmdline); do
57
loopaes_opts=${x#loopaesopts=}
63
if [ -z "${loopaes_opts}" ]; then
64
# Apparently the root partition isn't encrypted
68
# If you change this, keep the version in initramfs-tools-script
72
for opt in $loopaes_opts; do
75
module="$(cipher_modname "${opt#encryption=}")"
76
if [ -n "$module" ]; then
77
rootencryption="${rootencryption}${rootencryption:+:}${module}"
79
losetup_opts="${losetup_opts} -e ${opt#encryption=}"
82
losetup_opts="${losetup_opts} -o ${opt#offset=}"
85
losetup_opts="${losetup_opts} -s ${opt#sizelimit=}"
88
losetup_opts="${losetup_opts} -S ${opt#pseed=}"
91
losetup_opts="${losetup_opts} -H ${opt#phash=}"
94
losetup_opts="${losetup_opts} -I ${opt#loinit=}"
97
losetup_opts="${losetup_opts} -C ${opt#itercountk=}"
100
losetup_opts="${losetup_opts} -K ${opt#gpgkey=}"
103
rootgpghome=${opt#gpghome=}
106
rootloop=${opt#loop=}
109
# Presumably a non-supported or filesystem option
116
# Begin real processing
119
# Define crypto variables
123
if [ -z "${rootloop}" ]; then
124
echo "root on loop enabled, but no loop device given"
128
if [ -z "${rootgpghome}" ]; then
131
losetup_opts="${losetup_opts} -G ${rootgpghome}"
134
for mod in "$rootencryption"; do
138
while ! [ -b "${rootloop}" ]; do
142
# Use /sbin/losetup to make sure that we get the loopaes modified one,
143
# not the busybox one.
144
while ! /sbin/losetup ${losetup_opts} "${rootloop}" "$ROOT"; do
148
# init can now pick up new FSTYPE, FSSIZE and ROOT
149
echo "ROOT=\"${rootloop}\"" >> /conf/param.conf