Skip to content

Instantly share code, notes, and snippets.

@mikolec
Created February 27, 2024 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikolec/4b5dad366c5815e552f3da672325134b to your computer and use it in GitHub Desktop.
Save mikolec/4b5dad366c5815e552f3da672325134b to your computer and use it in GitHub Desktop.
installation commands for manual installation of Ubuntu 22.04 + LUKS
cryptsetup luksFormat --type=luks1 /dev/nvme0n1p7
cryptsetup luksOpen /dev/nvme0n1p7 cryptdrive
ls /dev/mapper/
mkfs.btrfs /dev/mapper/cryptdrive
gedit /usr/lib/partman/mount.d/70btrfs
#!/bin/sh
set -- $1
fs=$1
mp=$2
type=$3
options=$4
dump=$5
pass=$6
case $type in
btrfs)
options="${options%,subvol=*}"
#for removing the option subvol,when thats the only option
#eg: options=="subvol=@", no comma present
options="${options%subvol=*}"
mount -t btrfs ${options:+-o "$options"} $fs /target$mp || exit 1
case $mp in
/)
btrfs subvolume create /target$mp/@
chmod 755 /target$mp/@
umount /target$mp
options="${options:+$options,}subvol=@,ssd,noatime,space_cache=v2,commit=120,compress=zstd"
mount -t btrfs -o $options $fs /target$mp
;;
/home)
btrfs subvolume create /target$mp/@home
chmod 755 /target$mp/@home
umount /target$mp
options="${options:+$options,}subvol=@home,ssd,noatime,space_cache=v2,commit=120,compress=zstd"
mount -t btrfs -o $options $fs /target$mp
;;
esac
echo "umount /target$mp"
exit 0
;;
esac
exit 1
gedit /usr/lib/partman/fstab.d/btrfs
#!/bin/sh
. /lib/partman/lib/base.sh
home_found="unknown"
for dev in $DEVICES/*; do
[ -d $dev ] || continue
cd $dev
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
[ $fs != free ] || continue
[ -f "$id/method" ] || continue
[ -f "$id/acting_filesystem" ] || continue
method=$(cat $id/method)
filesystem=$(cat $id/acting_filesystem)
mountpoint=$(cat $id/mountpoint)
case "$filesystem" in
btrfs)
[ -f "$id/mountpoint" ] || continue
# due to #249322, #255135, #258117:
if [ "$mountpoint" = /tmp ]; then
rm -f $id/options/noexec
fi
options=$(get_mountoptions $dev $id)
if [ "$mountpoint" = / ]; then
if [ "$home_found" = "unknown" ]; then
home_found="false"
fi
pass=0
home_options="${options:+$options,}subvol=@home,ssd,noatime,space_cache=v2,commit=120,compress=zstd"
options="${options:+$options,}subvol=@,ssd,noatime,space_cache=v2,commit=120,compress=zstd"
home_path="$path"
home_mp="$mountpoint"home
elif [ "$mountpoint" = /home ]; then
pass=0
options="${options:+$options,}subvol=@home,ssd,noatime,space_cache=v2,commit=120,compress=zstd"
home_found=true
else
pass=0
fi
echo "$path" "$mountpoint" btrfs $options 0 $pass
;;
*)
if [ "$mountpoint" = "/home" ]; then
home_found="true"
fi
;;
esac
done
close_dialog
done
if [ "$home_found" = "false" ]; then
echo "$home_path" "$home_mp" btrfs "$home_options" 0 0
home_found="true"
fi
ubiquity --no-bootloader
#################
mount -o subvol=@,ssd,noatime,space_cache=v2,commit=120,compress=zstd /dev/mapper/cryptdrive /mnt
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo cp /etc/resolv.conf /mnt/etc/
sudo chroot /mnt
mount -av
btrfs subvolume list /
export UUIDP7=$(blkid -s UUID -o value /dev/nvme0n1p7) #this is an environmental variable
echo "cryptdrive UUID=${UUIDP7} none luks" >> /etc/crypttab
cat /etc/crypttab
export SWAPUUID=$(blkid -s UUID -o value /dev/nvme0n1p6)
echo "cryptswap UUID=${SWAPUUID} /dev/urandom swap,offset=1024,cipher=aes-xts-plain64,size=512" >> /etc/crypttab
cat /etc/crypttab
sed -i "s|UUID=${SWAPUUID}|/dev/mapper/cryptswap|" /etc/fstab
cat /etc/fstab
update-initramfs -k all -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment