Setup Arch linux with i3
About once a year I try to clean up my computer and experiment with new setups on my computer. This time I have decided that I want to switch from the Manjaro i3 community edition. I was a little worried that when everyone keeps saying that installing Arch linux is difficult, but for the most part it wasn't much difficult. The process is quite straight forward when you follow the Arch Wiki. The only problem I had was with installing the bootloader.
First thing to plan was the layout of partition and space that I want them occupy on my system. In my computer Dell Inspiron 15 Gaming 7655 I have two SSD drives, 512 GB SSD + 1 TB SSD
.
The first rule I learned was to keep Windows and Linux operating systems on separate drives. Therefore I have decided to install Windows 10 on the 512 GB drive and Linux on the 1 TB drive.
Partitions
The partition structure of the system looks like this
On 512GB SSD there will be 250GB (C:), 150GB (D:), 100GB (Recovery)
┌───────┬───────┬───────┐
│ 250GB │ 150GB │ 100GB │
└───────┴───────┴───────┘
On 1TB SSD there will be 500MB (/boot), 100GB (/), 60GB (/home), 10GB (swap), 830GB (unallocated)
┌───────┬───────┬──────┬──────┬────────┐
│ 500MB │ 100GB │ 60GB │ 3GB | 830GB │
└───────┴───────┴──────┴──────┴────────┘
The recovery partition is a system partition that contains factory settings for my Windows, I could move it to an external CD, but I don't need to necessarily move it.
Arch installation
I have tried to follow multiple video tutorials, but I always got stuck on the bootloader installation. The tutorial that helped me in the end was this one
I will try to summarise the steps here:
- Make sure you have Windows installed first
- Download the arch iso from https://www.archlinux.org/download/
- Download rufus or other bootable USB creation tool
- Write the iso file on USB drive
- Reboot the computer and select the USB as a boot option by pressing F9
Once in Arch live OS:
- check you have an internet connection by typing
ping archlinux.org
- set correct time by
timedatectl set-ntp true
- use a command
lsblk
to show installed partitions and disks - use a command
fdisk /dev/sdX
to mamange partitions on a disksdX
- To create a new partiton do
Command [m for help]: n Partition type: p primary e extended Select (default p): Partition number (X-Y, default Z): Fist sector (X-Y, default X): Last sector, +sectors or +size{K,M,G} (X-Y, default Y): +500M
- Check the status with
Command [m for help]: p
- To save the changes do
Command [m for help]: w
- repeat this process until you create your (preferable 4) partitions
- you now have to format the disks with
mkfs.ext4 /dev/sdaX
- for swap partition you need to do
mkswap /dev/sdaX && swapon /dev/sdaX
- now mount the partition you want to be
/
partition withmount /dev/sdaX /mnt
- mount a home partition where the user will reside with
mkdir /mnt/home && mount /dev/sdaX /mnt/home
- now create to bootloader
mkdir /mnt/efi && mount /dev/sdaX /mnt/efi
- install linux
pacstrap /mnt base linux linux-firmware
- generate fstab file so you can boot properly with
genfstab -U /mnt >> /mnt/etc/fstab
- now login to the arch linux with
arch-chroot /mnt
- set the correct timezone
ln -sf /usr/share/zoneinfo/Eurote/Bratislava /etc/localtime
- switch to use a hardware clocks
hwclock --systohc
- install a text editor
sudo pacman -S nano
orsudo pacman -S vim
- edit the file
nano /etc/locale.gen
and find the line#en_US.UTF-8 UTF8
and uncomment it - update locale by doing
locale-gen
- create a file
nano /etc/locale.conf
and writeLANG=en_US.UTF-8
then save - create a file
nano /etc/hosts
and write127.0.0.1 localhost ::1 localhost 127.0.1.1 YOURNAME.localdomain YOURNAME
- install a network manager
sudo pacman -S networkmanager
orsudo pacman -S netctl
- enable the network manager by
sudo systemctl enable NetworkManager
- add your user
useradd -G wheel,audio,video -m YOURNAME
- set your password with
passwd YOURNAME
- set the root password with
passwd
- install the bootloader
sudo pacman -S grub efibootmgr
- install osprober
sudo pacman -S os-prober
- install grub
[root@archiso /]# grub-install --target=x86_64-efi --efi-directory=/efi/ --bootloader-id=GRUB Installing for x86_64-efi platform. Installation finished. No errors reported.
- generate a config file
grub-mkconfig -o /boot/grub/grub.cfg
- now reboot and check everything working
Post Arch installation
Now with Arch linux setup we have just a terminal interface. In order to have a usable deskktop we need to install Xorg. Then we can install a display manager if we want to such as lightdm or lxdm. After that we need to install a window manager such as i3, Xmonad, dwm, AwesomeWM or any other.
After we have a usable desktop enviroment we can install the tools that we are going to use:
- for wallpaper
feh
ornitrogen
- file manager
ranger
- terminal text editor
vim
ornvim
- web browser
firefox
- bar
polybar
- image viewer
sxiv
- pdf viewer
zathura
- markdown editor
typora
- text editor
code
(visual studio code) orsubl
(sublime text) - notifications
dunst
- chat app
discord
We now have a ready dualboot with Arch and Windows 10 ready. Although if we want to access the Windows 10 for something trivial, we need to reboot the computer, start Windows 10, do the thing, reboot the computer, go back to Arch. The next problem is that we want to share the data between these operating systems.
Share partitions between Windows and Linux
Windows 10 uses either FAT or NTFS format of partitions. Linux uses mostly ext4 format. Linux can read the NTFS partition, but Windows can't read the ext4 partition. Therefore we can mount the windows drive on linux.
# install ntfs-3g so you can set the mount permissions
sudo pacman -S ntfs-3g
# get the partition UUID
sudo blkid -S UUID
# automount the partition on boot
cp /etc/fstab /etc/fstabl.backup
nano /etc/fstab
# place this line there
UUID=YOUR-PARTITION-UUID /d ntfs-3g rw,defaults,uid=1000,fmask=0022,dmask=0000,utf8 0 0
Now when you reboot it should mount your Windows disk D:
to /d/
Boot to Windows 10 from Arch linux
As mentioned above, sometimes I don't want to reboot to Windows just for any small stuff. The solution I found was VirtualBox. Virtualbox allowes us to create virtual machines but, you may ask, we want to access our physical Windows, not a virtual one. Luckily Virtualbox has an option for that. It's called accessing a raw disk partition. Be careful and read the manual in the link before properly as the WARNING says Raw hard disk access is for expert users only. Incorrect use or use of an outdated configuration can lead to total loss of data on the physical disk. Most importantly, do not attempt to boot the partition with the currently running host operating system in a guest. This will lead to severe data corruption.
The steps are quite simple. First you do the command to create a .vmdk file VBoxManage internalcommands createrawvmdk -filename /root/win.vmdk -rawdisk /dev/sda
. This will mount the whole disk (which for me contains only Windows). You can also specify only certain partitions with -partitions 1,3
etc. Make sure to include a bootloader partition as well when specifying the partitions.
After creating the vmdk file you can start Virtualbox which needs to be run as root. Add a new machine, select Windows 10, create it from an existing image, add the vmdk file there. Set how much memory you want to assing and press done. Set the number of cores to at least 4, enable EFI and launch. You should boot into your real Windows 10 and everything should work fine. The progress and data are shared between your real Windows and the virtual one.