🔐 Setting up Debian via GRML offers a powerful way to customize your installation while ensuring top-notch security. This method gives you full control over the process, allowing you to build a system tailored to your needs from the ground up. In this guide, we'll explore the steps involved in setting up Debian on an encrypted LVM using these tools. Get ready for a journey into the art of building a secure Linux system! 🚀
Before diving in, make sure you have the following:
💡 Why GRML? GRML is a powerful live environment packed with tools that make it perfect for advanced installations like this. It's lightweight, flexible, and designed with system administrators in mind.
🎯 Start by booting into the GRML live environment from your USB stick or ISO. Once you're in, you'll be greeted by a terminal. Don’t worry; this is where all the magic happens.
💾 Identify your target disk using lsblk
or fdisk
:
lsblk
For this example, we'll assume your target disk is /dev/sda
.
Partition the Disk:
fdisk
to create a new GPT partition table:
fdisk /dev/sda
Don’t forget to set the EFI partition's type to EFI System
.
🔒 Encrypting your system with LUKS ensures your data is secure, even if the physical disk is stolen.
Initialize LUKS on the second partition:
cryptsetup luksFormat /dev/sda2
Type "YES" when prompted, and set a strong passphrase. 🧠
Open the encrypted volume:
cryptsetup open /dev/sda2 cryptroot
This maps the encrypted partition to /dev/mapper/cryptroot
.
📦 Logical Volume Management (LVM) provides flexibility by allowing you to resize or add volumes without major headaches.
Create a physical volume:
pvcreate /dev/mapper/cryptroot
Create a volume group:
vgcreate debian-vg /dev/mapper/cryptroot
Create logical volumes:
lvcreate -L 15G -n root debian-vg
lvcreate -L 2G -n swap debian-vg
lvcreate -l 100%FREE -n home debian-vg
🛠️ With your logical volumes ready, it’s time to format them:
Format the EFI partition:
mkfs.vfat /dev/sda1
Format the logical volumes:
mkfs.ext4 /dev/debian-vg/root
mkfs.ext4 /dev/debian-vg/home
mkswap /dev/debian-vg/swap
Mount the filesystems:
mount /dev/debian-vg/root /mnt
mkdir /mnt/home
mount /dev/debian-vg/home /mnt/home
mkdir /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi
📦 debootstrap is a lightweight tool for installing Debian from scratch.
Install the base system:
debootstrap stable /mnt http://deb.debian.org/debian/
Chroot into the new system:
for _dr in proc sys dev dev/pts run; do mount --bind /${_dr} /mnt/${_dr}; unset _dr; done
chroot /mnt bash
Configure basic settings:
echo "mydebian" > /etc/hostname
/etc/fstab
for your partitions. For example:
echo "/dev/mapper/debian--vg-root / ext4 defaults 0 1" >> /etc/fstab
echo "/dev/mapper/debian--vg-home /home ext4 defaults 0 2" >> /etc/fstab
echo "UUID=$(blkid -s UUID -o value /dev/sda1) /boot/efi vfat umask=0077 0 1" >> /etc/fstab
/etc/crypttab
to unlock the encrypted volume on boot:
echo "cryptroot UUID=$(blkid -s UUID -o value /dev/sda2) none luks" >> /etc/crypttab
apt update
apt install linux-image-amd64 grub-efi sudo openssh-server
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=debian
update-grub
passwd
adduser myuser
usermod -aG sudo myuser
Exit the chroot and unmount everything:
exit
for _dr in proc sys dev/pts dev run; do umount /mnt/${_dr}; unset _dr; done
🌟 Reboot the system, remove the GRML media, and enter your LUKS passphrase when prompted. After booting, fine-tune your installation by:
ufw
.🎉 Congratulations! You've successfully installed Debian using GRML. This setup provides not only flexibility and performance but also robust security for your data. Take a moment to appreciate your work; you’ve built something powerful and secure from scratch. 🚀