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 -l
In this particular case, we want to use the /dev/sda
harddrive:
fdisk /dev/sda
o # 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 write
We 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 world
We 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/lvm
Setup volume group:
vgcreate volgroup0 /dev/mapper/lvm # "volgroup0" is an optional name, but that name is quite typical in the linux world
Now 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 groups
Start by formatting our boot partition. ext2 is just fine for the boot partition:
mkfs.ext2 /dev/sda1
Format the volume groups:
mkfs.ext4 /dev/volgroup0/lv_root # root volumegroup
mkfs.ext4 /dev/volgroup0/lv_home # home volumegroup
mount /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/home
Let'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.com
If 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 that
Find 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> # yes
Generate fstab
genfstab -U -p /mnt >> /mnt/etc/fstab
cat /mnt/etc/fstab # verify
chroot into our installation
arch-chroot /mnt
We need a few packages:
pacman -S openssh vim tmux grub-bios linux-headers linux-lts linux-lts-headers
Software 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.conf
Find 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 linux
This step is optional, unless lts-kernel is installed. Then it is required.
mkinitcpio -p linux-lts
Remove the pound (#) form the language that you want to use. Fx en_US.UTF-8
:
vim /etc/locale.gen
Then generate the locale:
locale-gen
Then time:
rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime
hwclock --systohc --utc # Sync clock
systemctl enable sshd.service
passwd
vim /etc/default/grub
Find 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/sda
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
grub-mkconfig -o /boot/grub/grub.cfg
There 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 /mnt
Now it's the moment of truth whether or not the installation was successful:
reboot