Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Lantizia/8342311ce650cf17b6c2a89552d3c54e to your computer and use it in GitHub Desktop.
Save Lantizia/8342311ce650cf17b6c2a89552d3c54e to your computer and use it in GitHub Desktop.
### Ubuntu MATE 18.04 with encryption and hibernation side-by-side another OS
##############################################################################
###
### All filesystems/labels/layouts/sizes/etc... used are the defaults that would
### be used in an entire disk with encryption install.
###
### Exceptions are...
### 2 GiB for /boot to allow for plenty of older kernels
### 20 GiB for swap to account for 16 GiB RAM hibernating plus a bit extra
###
### This script assumes no Linux partitions, yet space has been made for them.
### An example layout before starting would be...
### /dev/nvme0n1p1 499 MiB NTFS System Partition
### /dev/nvme0n1p2 100 MiB EFI Partition
### /dev/nvme0n1p3 16 MiB MS Reserved Partition
### /dev/nvme0n1p4 95 GiB Windows NTFS Partition
###
# Boot a Ubuntu MATE 18.04 USB pen with 'Try Ubuntu MATE without installing'
# Open the installer and pick the usual language and keyboard options
# Choose a minimal installation with downloaded updates and third party software
# Choose 'Something else' for installation type and...
# Create /dev/nvme0n1p5 as...
Size: 2147
Use as: Ext4 journaling file system
# Create /dev/nvme0n1p6 as...
Size: 407539 (whatever is left to use on the disk)
Use as: physical volume for encryption
Choose a security key: <whatever>
Confirm the security key: <whatever>
# Then open up 'MATE Terminal'
sudo su
pvcreate /dev/mapper/nvme0n1p6_crypt
vgcreate ubuntu-mate-vg /dev/mapper/nvme0n1p6_crypt
lvcreate -L 20G -n swap_1 ubuntu-mate-vg
lvcreate -l 100%FREE -n root ubuntu-mate-vg
# Back in the installer use 'Back' then 'Something else' again to refresh and...
# Change /dev/mapper/ubuntu--mate--vg-root to...
Use as: Ext4 journaling file system
Mount point: /
# Change /mapper/ubuntu--mate--vg-swap_1 to...
Use as: swap area
# Change /dev/nvme0n1p5 to...
Use as: Ext4 journaling file system
Format the partition: true
Mount point: /boot
# Make sure /dev/nvme0n1 is where the bootloader is installed to
# Choose time zone and give it your system and login information
# Click 'Continue Testing' when it's done then back in the terminal...
mount /dev/mapper/ubuntu--mate--vg-root /mnt
mount /dev/nvme0n1p5 /mnt/boot
mount /dev/nvme0n1p2 /mnt/boot/efi
for i in /dev /proc /sys /run; do mount -B $i /mnt$i; done
chroot /mnt
echo "nvme0n1p6_crypt UUID=$(blkid -s UUID -o value /dev/nvme0n1p6) none luks,discard" > /etc/crypttab
update-initramfs -u -k all
sed -i 's/^\(GRUB_CMDLINE_LINUX_DEFAULT.*\)"/\1 resume=\/dev\/mapper\/ubuntu--mate--vg-swap_1"/' /etc/default/grub
update-grub
exit
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment