Following this guide from YouTube: https://www.youtube.com/watch?v=gB1N00wj3bw
This installation procedure follows installing a secure encrypted lvm version of Arch Linux on my MacBook Pro in Parallels.
Let us start by looking at the naming of harddrives:
fdisk -lIn this particular case, we want to use the /dev/sda harddrive:
fdisk /dev/sdao # makes a DOS disklabel
n # new partition - Boot
w <enter> # for default of p
<enter> # for default of 1
<enter> # for default of 2048
+400M # Boot drive, unencrypted
a # makes partition bootable
n # new partition
<enter> # for default of p
<enter> # for default of 2
<enter> # for default of 821248
<enter> # for default of 134217727
t # Change type of a partition
<enter> # for default of 2 (partition 2)
8E # for LVM
w # for writeWe have setup a boot partition as well as a main partition, however it is yet to be encrypted.
cryptsetup luksFormat /dev/sda2
YES
<password> # typical pwd for linux servers
<retype password>Now we need to install arch linux on that partition. To do that, we need to unencrypt (or "open") that partition:
cryptsetup open --type luks /dev/sda2 lvm # "lvm" is a name, optional what it is, but "lvm" is quite typical in the linux worldWe need to create a physical volume.
IMPORTANT: In the command below, the --dataalignment 1m is optional, however if a system is on an SSD, you really should use it. Will old spinning harddrives, you probably shouldn't use it.
pvcreate --dataalignment 1m /dev/mapper/lvmSetup volume group:
vgcreate volgroup0 /dev/mapper/lvm # "volgroup0" is an optional name, but that name is quite typical in the linux worldNow we need to create 3 volume groups that will contain the operating system and our failes
lvcreate -L 30GB volgroup0 -n lv_root # root volume
lvcreate -L 4GB volgroup0 -n lv_swap # swap volume
lvcreate -l 100%FREE volgroup0 -n lv_home # home volume
vgchange -ay # activate volume groupsStart by formatting our boot partition. ext2 is just fine for the boot partition:
mkfs.ext2 /dev/sda1Format the volume groups:
mkfs.ext4 /dev/volgroup0/lv_root # root volumegroup
mkfs.ext4 /dev/volgroup0/lv_home # home volumegroupmount /dev/volgroup0/lv_root /mnt # Mount root partition
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
mkdir /mnt/home
mount /dev/volgroup0/lv_home /mnt/homeLet's make sure we have internet
ip a # See ip
# If no ip:
dhcpcd # Get a new ip
ping 4.2.2.1
ping google.comIf wireless access is needed (if the computer is not connected by wire, and it isn't a vm):
cp /etc/netctl/examples/wireless-wpa /etc/netctl/<wireless-name> # "wireless name" can be anything, fx SSID, but doesn't need to be thatFind the name of the wireless card. It could be wlan0 fx. Then "vi" or "nano" /etc/netctl/<wireless-name>.
Let's install arch packages:
pacstrap -i /mnt base
<enter> # all
<enter> # yesGenerate fstab
genfstab -U -p /mnt >> /mnt/etc/fstab
cat /mnt/etc/fstab # verifychroot into our installation
arch-chroot /mntWe need a few packages:
pacman -S openssh vim tmux grub-bios linux-headers linux-lts linux-lts-headersSoftware is used for:
- openssh: For SSH access
- grub-bios: Required
- linux-headers: Optional, but common for compiling stuff
- linux-lts: Long Term Service release for the linux kernel. It's a bit older, but recommended. The kernel can always be switched out
- linux-lts-headers:
- wpa_supplicant & wireless_tools: Optional: For wireless access
After all packages are installed, we need to modify the following file. If we don't, the system won't boot, and we can just start all over:
vim /etc/mkinitcpio.confFind a line that says something with HOOKS=(base udev[...]). Place the cursor between block and filesystems and add:
encrypt lvm2
The whole line should be something like:
HOOKS=(base udev autodetect modconf block encrypt lvm2 filesystems keyboard fsck)
Setup the hooks we just created to make sure that the installation supports lvm as well as booting into an encrypted volume
mkinitcpio -p linuxThis step is optional, unless lts-kernel is installed. Then it is required.
mkinitcpio -p linux-ltsRemove the pound (#) form the language that you want to use. Fx en_US.UTF-8:
vim /etc/locale.genThen generate the locale:
locale-genThen time:
rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime
hwclock --systohc --utc # Sync clocksystemctl enable sshd.servicepasswdvim /etc/default/grubFind the line that says GRUB_CMDLINE_LINUX_DEFAULT="quiet". In the quotes (where it says quiet), enter:
[...] ="cryptdevice=/dev/sda2:volgroup0 quiet"
MAKE sure it is EXCACTLY right. Otherwise it won't boot.
Then install grub:
grub-install --target=i386-pc --recheck /dev/sdacp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mogrub-mkconfig -o /boot/grub/grub.cfgThere will be a lot of warnings; don't worry about it.
Now just exit and unmount everything.
exit
umount /mnt/boot
umount /mnt/home
umount /mntNow it's the moment of truth whether or not the installation was successful:
reboot