quinta-feira, março 22, 2018

Arch Linux Experiment

I am a Fedora user since Fedora 20 and I can't see myself using any other distribution in the near future. Before that I used openSuse and Slackware. The latter by the way, it was my first and only distribution until 2010, I believe. It was a long ride because I used Slackware since 1997.

I've some experience with other distributions as well. Debian, Ubuntu, Linux Mint and Arch Linux are some of them. The latter is the distribution that I keep running my Raspberry Pi B+, only because Fedora doesn't support ARMv6 architecture, but I'm thinking about moving it back to Raspbian just because I don't need to have the latest software to run a file server.

Recently I decided to test Arch Linux in my main development machine as well. It's an i5 Acer laptop with 8GB RAM and 1TB HDD. It was a fun ride, but after one week I believe, I returned to Fedora. Not because Arch Linux is a bad distribution, quite the opposite, I think it's great, fast and light.

So this post is a recipe for installing Arch Linux in case I want to return to it in the future. First, you need to setup your keyboard layout. Mine is Brazillian Portuguese:

loadkeys br-abnt2

Then, disk partition. This is a trick one because you need to check if you system is UEFI or not. Most new hardware do, just like mine, so here is the layout I used:

# 1 - ef02 (boot partition 200MB)
# 2 - 8300 (root partition all the rest)
# 3 - 8200 (swap partition == RAM size)
gdisk /dev/sda
mkfs.fat -F32 /dev/sda1
mkfs.ext4 /dev/sda2
mkswap /dev/sda3
mount /dev/sda2 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
swapon /dev/sda3

Just as a reference, this is a BIOS layout - no, you don't need to format the boot partition:

# 1 - ef02 (boot partition 1Mb)
# 2 - 8300 (root partition all the rest)
# 3 - 8200 (swap partition == RAM size)
gdisk /dev/sda
mkfs.ext4 /dev/sda2
mkswap /dev/sda3
mount /dev/sda2 /mnt
swapon /dev/sda3

Connect to your wireless network:

wifi-menu

In order to start installing software, first you'll need to enable your country's mirrors:

vi /etc/pacman.d/mirrorlist

Now, you need to install all your system. Basically you'll need base and grub packages. If you use EFI, it's nice to have efibootmgr as well. Below is a list of all software I had to install to achieve my regular workflow. I use GNOME in Fedora, but here I tried other desktop environments too, so below setup is for XFCE:

pacstrap /mnt base base-devel grub intel-ucode efibootmgr pulseaudio networkmanager blueman tlp sudo cronie openssh nfs-utils autofs rsync wget git xorg-server xf86-video-intel xfce4 xfce4-pulseaudio-plugin xfce4-whiskermenu-plugin xfce4-notifyd pavucontrol network-manager-applet redshift python-gobject python-xdg librsvg lightdm-gtk-greeter-settings light-locker adapta-gtk-theme papirus-icon-theme arc-gtk-theme arc-icon-theme archlinux-wallpaper ttf-hack gedit firefox-i18n-pt-br libreoffice-fresh-pt-BR audacity keepassxc meld gnome-builder flatpak-builder pdfgrep audacious mpv thunar-volman gvfs gnome-disk-utility neovim docker xorg-xhost gitg tracker scrot gthumb hexchat

Then KDE:

pacstrap /mnt base base-devel grub intel-ucode efibootmgr pulseaudio networkmanager blueman tlp sudo cronie openssh nfs-utils autofs rsync wget git xorg-server xf86-video-intel plasma konsole kate dolphin archlinux-wallpaper firefox-i18n-pt-br libreoffice-fresh-pt-BR audacity keepassxc meld gnome-builder flatpak-builder pdfgrep audacious mpv docker xorg-xhost gitg scrot hexchat

And finally GNOME:

pacstrap /mnt base base-devel grub intel-ucode efibootmgr pulseaudio networkmanager blueman tlp sudo cronie openssh nfs-utils autofs rsync wget git xorg-server xf86-video-intel gnome gedit archlinux-wallpaper firefox-i18n-pt-br libreoffice-fresh-pt-BR audacity keepassxc meld gnome-builder flatpak-builder pdfgrep audacious mpv docker xorg-xhost gitg scrot polari

There are other software that I use regularly in my development machine, like spotify, steam, skype but I didn't bother to install them for this test.

Last thing before going chroot, we need to generate our fstab:

genfstab -U /mnt > /mnt/etc/fstab

Then, chroot to your new system:

arch-chroot /mnt

Set hostname:

echo myacer.mydomain > /etc/hostname

Set local time and enable clock synchronization:

ln -sf /usr/share/zoneinfo/Brazil/East /etc/localtime
timedatectl set-ntp true

Set locale:

echo pt_BR.UTF-8 UTF-8 > /etc/locale.gen
locale-gen
echo LANG=pt_BR.UTF-8 > /etc/locale.conf

Set keyboard for console:

echo KEYMAP=br-abnt2 > /etc/vconsole.conf

Install kernel:

mkinitcpio -p linux

Set root password:

passwd

Config boot loader with your kernel parameters and install it:

grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ArchLinux --recheck
# for ACER screen freeze: GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.enable_rc6=0"
# for DELL screen freeze: GRUB_CMDLINE_LINUX_DEFAULT="quiet video=SVIDEO-1:d"
# for ACPI warning message: GRUB_CMDLINE_LINUX_DEFAULT="quiet loglevel=3"
vi /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg

Add users:

useradd -m -G wheel myuser
useradd -m otheruser
passwd myuser
passwd otheruser

Enable login manager (gdm for GNOME, sddm for KDE or lightdm for everything else) and other services (tlp is specific for notebooks):

systemctl enable lightdm
systemctl enable NetworkManager
systemctl enable bluetooth
systemctl enable autofs
systemctl enable tlp
systemctl enable tlp-sleep
systemctl mask systemd-rfkill.service
systemctl mask systemd-rfkill.socket
systemctl enable cronie

Enable wheel group in sudoers:

vi /etc/sudoers

Add your servers' IP to your hosts file:

echo 999.999.999.999 server.domain server > /etc/hosts

Exit chroot, reboot, login and install pamac:

exit
reboot
cd /tmp
git clone https://aur.archlinux.org/pamac-aur.git
cd pamac-aur/
makepkg -si

Prevent bluetooth from starting on boot:

gsettings set org.blueman.plugins.powermanager auto-power-on false

Enable tap-to-click in gdm for GNOME and show date in GNOME Desktop clock:

gsettings set org.gnome.desktop.interface clock-show-date true
sudo -u gdm dbus-launch gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click true

Enable redshift for XFCE (GNOME and KDE doesn't need that):

redshift-gtk&

That's it and if you want to take a look in the end result, presenting XFCE: