Topic: Install Full disk encryption (including /boot ) on Virtual Machine
Hi all . I decided to check how installing an encrypted disk and the /boot partition works
to a virtual machine (qemu)
Below you will see my results, I did not write in detail about each command, sorry if it is poorly written, I was just testing))
This example uses luksFormat --type luks1 /dev/sdb1 . Don't use Luks1 it is not safe, use Luks2+argon2id today!
Since version 2.4.0 (released August 18, 2021), cryptsetup uses Argon2id by default. You can read why in detail in this article.
https://mjg59.dreamwidth.org/66429.html
If you see errors or better solutions, better command , write here.
I checked, everything works!
It is assumed that the user is not currently using HyperbolaGNU
as a main computer.
Download the necessary programs, an iso image https://wiki.hyperbola.info/doku.php?id … redirect=1 and install the virtual machine.
$ sudo apt install qemu qemu-kvm qemu-system-x86_64
$ qemu-img create -f qcow2 hyperbola.qcow2 15G
$ qemu-system-x86_64 -hda hyperbola.qcow2 -boot d -cdrom hyperbola-milky-way-v0.4.3-dual.iso -m 2048 -smp 2 -enable-kvm -nic user,hostfwd=tcp::10037-:4571
We have booted the virtual machine with HyperbolaGNU now let's increase the font (optional)
# сd /usr/share/kbd/consolefonts
# setfont sun12*22.psfu.gz enter
Let's enable ssh on the local machine (PC)
$ sudo service ssh start
(systemD)
or
$ sudo rc-service ssh start
( OpenRC)
Check the firewall on your local machine to see if it is blocking ssh, etc.
$ sudo ufw status numbered
Let's create a password on the virtual machine (Hyperbola Live Media)
# passwd root
Let's enable ssh on the virtual machine (Hyperbola Live Media)
# rc-service sshd start
Change port 22 to 4571 (example)
# nano /etc/ssh/sshd_config
# nano /etc/ssh/ssh_config
Restart SSH on virtual machine (Hyperbola Live Media)
# rc-service sshd restart
Check port
# netstat -tulpena
Create normal user on Hyperbola Live Media and password
# useradd test
# passwd test
Connect from your local machine to the virtual machine (Hyperbola Live Media ) via ssh
$ ssh test@localhost -p 10037
check
# whoami
# uname -a
# lsblk
sda 8:0 0 15G 0 disk
Now you can copy and paste the commands from this instruction into your terminal)
use dd for erase data
# dd if=/dev/urandom of=/dev/sda bs=1M status=progress
(171.235 s)
# cfdisk /dev/sda ( select dos > primary etc)
Now you have sda1 partition
# ip -c a
# dhclient your adapter (ens2 example)
# ping -c 3 gnu.org
# pacman -Syy cryptsetup
# rc-update add lvm boot
# rc-update add dmcrypt boot
# modprobe dm-mod
# cryptsetup -v --cipher serpent-xts-plain64 --key-size 512 --hash whirlpool --iter-time 500 --use-random --verify-passphrase luksFormat --type luks1 /dev/sda1
Check next time ))
cryptsetup --cipher aes-xts-plain64 --hash sha512 --iter-time 5000 --key-size 512 --pbkdf argon2id
--use-urandom --verify-passphrase luksFormat --type luks2 /dev/sda
Notice: name disk -sda1 ,not sda !
type luks1 not luks2 !
WARNING!
========
This will overwrite data on /dev/sda1 irrevocably.
Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for /dev/sda1:
Verify passphrase:
Key slot 0 created.
Command successful.
Check
# lsblk -f
# cryptsetup open /dev/sda1 lvm
# pvcreate /dev/mapper/lvm
# pvs
PV VG Fmt Attr PSize PFree
/dev/mapper/lvm lvm2 --- <15.00g <15.00g
# vgcreate matrix /dev/mapper/lvm
# vgs
VG #PV #LV #SN Attr VSize VFree
matrix 1 0 0 wz--n- <15.00g <15.00g
# lvcreate -l +100%FREE matrix -n rootvol
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
rootvol matrix -wi-a----- <15.00g
# mkfs.ext4 /dev/mapper/matrix-rootvol
# lsblk -f(check)
# mount /dev/matrix/rootvol /mnt
Create the /boot and /home directories
# mkdir -p /mnt/home
# mkdir -p /mnt/boot
Install the base system
# pacstrap /mnt
Generate an Fstab
# genfstab -U -p /mnt >> /mnt/etc/fstab
# cat /mnt/etc/fstab (check)
Chroot
# arch-chroot /mnt
Setting up clock...
Setting up time zone..
Setting up the consolefont ...
Setting up Kernel Modules
# nano /etc/mkinitcpio.conf
MODULES=i915 (I wrote without quotes)
HOOKS="base udev autodetect modconf block keyboard keymap consolefont encrypt lvm2 filesystems fsck shutdown"
Update Kernel
# mkinitcpio -p linux-libre-lts
==>ERROR Hook 'encrypt'...
==>WARNING missing isci..
OK,
# pacman -S cryptsetup
# pacman -S core/isci-lts-firmware
# mkinitcpio -p linux-libre-lts
Setting up hostname
# echo " hyperbola" > /etc/hostname
# nano /etc/hosts
127.0.0.1 localhost.localdomain localhost hyperbola
::1 localhost.localdomain localhost hyperbola
Set the root password
#passwd
****************************
****************************
Installing Grub
# pacman -S grub
# nano /etc/default/grub
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda1:lvm"
# grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux-libre-lts
Found initrd image: /boot/initramfs-linux-libre-lts.img
Found fallback initramfs image: /boot/initramfs-linux-libre-lts-fallback.img
done
# exit
# umount -R /mnt
# lvchange -an /dev/matrix/rootvol
# cryptsetup close lvm
# openrc-shutdown -p now
Start your new HyperbolaGNU.
$ qemu-system-x86_64 -hda hyperbola.qcow2 -m 2048 -smp 2 -enable-kvm
exit the virtual machine ctrl+alt +g
Below are screenshots of my virtual machine after installation. You will need to enter your password twice.
Try it and write how it turned out for you.
https://lufi.ethibox.fr/r/00U2Xyh4rJ#Zw … Z/gIxPt5k=
https://lufi.ethibox.fr/r/LHDMCM6xbc#Yp … 1hpE31Pxw=
https://lufi.ethibox.fr/r/ZsUZQPZNm1#3V … +ox4FX5Jg=