Fixup initramfs mmc booting

This commit is contained in:
SolidHal 2019-09-26 11:34:59 -07:00
parent e9c3d36dc2
commit 59893f5cf0
2 changed files with 23 additions and 26 deletions

View File

@ -37,7 +37,7 @@ ROOT_DEV="${BLKID%1:*}"
echo ${ROOT_DEV} echo ${ROOT_DEV}
#uncomment for debugging #uncomment for debugging
exec setsid /bin/sh -c 'exec /bin/sh </dev/tty1 >/dev/tty1 2>&1' # exec setsid /bin/sh -c 'exec /bin/sh </dev/tty1 >/dev/tty1 2>&1'
# we use this to change what cmdline options get passed into # we use this to change what cmdline options get passed into
# the next boot stage, aka to enable root encryption # the next boot stage, aka to enable root encryption
@ -49,7 +49,6 @@ mount ${ROOT_DEV}3 /newroot
umount /sys umount /sys
umount /proc umount /proc
umount /dev
# exec setsid /bin/sh -c 'exec /bin/sh </dev/tty1 >/dev/tty1 2>&1' # exec setsid /bin/sh -c 'exec /bin/sh </dev/tty1 >/dev/tty1 2>&1'

View File

@ -57,22 +57,23 @@ then
dmesg -E dmesg -E
echo Writing kernel partition echo Writing kernel partition
dd if=/dev/zero of=/dev/mmcblk2p1 bs=512 count=65536
dd if="$BOOT_DEVICE"1 of=/dev/mmcblk2p1 dd if="$BOOT_DEVICE"1 of=/dev/mmcblk2p1
BOOT_DEV_NAME=mmcblk2p2 BOOT_DEV_NAME=mmcblk2p2
ROOT_DEV_NAME=mmcblk2p3 ROOT_DEV_NAME=mmcblk2p3
CRYPTO=false CRYPTO=false
#Handle full disk encryption #Handle full disk encryption
read -p "Would you like to setup full disk encrytion using LUKs/DmCrypt? [Y/n]" -n 1 -r # read -p "Would you like to setup full disk encrytion using LUKs/DmCrypt? [Y/n]" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]] # if [[ $REPLY =~ ^[Yy]$ ]]
then # then
CRYPTO=true # CRYPTO=true
# Since iteration count is based on cpu power, and the rk3288 isn't as fast as a usual # # Since iteration count is based on cpu power, and the rk3288 isn't as fast as a usual
# desktop cpu, maually supply -i 15000 for security at the cost of a slightly slower unlock # # desktop cpu, maually supply -i 15000 for security at the cost of a slightly slower unlock
cryptsetup -s 512 luksFormat -i 15000 /dev/mmcblk2p2 # cryptsetup -s 512 luksFormat -i 15000 /dev/mmcblk2p2
cryptsetup luksOpen /dev/mmcblk2p2 mmcblk2p2-encrypted # cryptsetup luksOpen /dev/mmcblk2p2 mmcblk2p2-encrypted
ROOT_DEV_NAME=mapper/mmcblk2p2-encrypted # ROOT_DEV_NAME=mapper/mmcblk2p2-encrypted
fi # fi
echo Writing Filesystem, this will take about 4 minutes... echo Writing Filesystem, this will take about 4 minutes...
mkfs.ext4 -F -b 1024 /dev/$ROOT_DEV_NAME mkfs.ext4 -F -b 1024 /dev/$ROOT_DEV_NAME
@ -81,20 +82,17 @@ then
rsync -ah --info=progress2 --info=name0 --numeric-ids -x / /mnt/mmc/ rsync -ah --info=progress2 --info=name0 --numeric-ids -x / /mnt/mmc/
#Remove the live-fstab and install a base fstab #Remove the live-fstab and install a base fstab
rm /mnt/mmc/etc/fstab rm /mnt/mmc/etc/fstab
if [ $CRYPTO false] echo "/dev/mmcblk2p3 / ext4 defaults,noatime 0 1" > /mnt/mmc/etc/fstab
then umount /dev/$ROOT_DEV_NAME
echo "/dev/mmcblk2p2 / ext4 defaults,noatime 0 1" > /mnt/mmc/etc/fstab
umount /dev/mmcblk2p2
echo Running fsck echo Running fsck
e2fsck -p -f /dev/mmcblk2p2 e2fsck -p -f /dev/$ROOT_DEV_NAME
fi # if [ $CRYPTO true ]
if [ $CRYPTO true ] # then
then # # unmount and close encrypted storage
# unmount and close encrypted storage # cryptsetup luksClose mmcblk2p2-encrypted
cryptsetup luksClose mmcblk2p2-encrypted # echo Running fsck
echo Running fsck # #TODO run fsck on luks part
#TODO run fsck on luks part # fi
fi
echo Rebooting... Please remove the usb drive once shutdown is complete echo Rebooting... Please remove the usb drive once shutdown is complete
reboot reboot
fi fi