Installing ArchLinux With Btrfs in Vmware

A log to my VMware Arch Linux installation.

Before installation

Create a virtual machine and adjust depend config on your need(Except for the UEFI firmware part):

To prevent the creation of vmem files for acceleration, add the following lines to your .vmx file(:

1
2
3
4
5
prefvmx.minVmMemPct = "100"
MemTrimRate = "0"
mainMem.useNamedFile = "FALSE"
sched.mem.pshare.enable = "FALSE"
prefvmx.useRecommendedLockedMemSize = "TRUE"

Boot up the vm, and check if the firmware is UEFI or not:

1
ls /sys/firmware/efi/efivars

if it’s legacy BIOS, it will returns No such file or directory.

Partitioning

Create a new GPT partition table and partitioned with an EFI Partition no less than 300MiB and an Linux partition with cgdisk or any other partition tools you want to use:

1
cgdisk /dev/sda

Format partitions

EFI

1
mkfs.fat -F32 /dev/sda1

Root system

1
mkfs.btrfs -f -L Arch /dev/sda2

Building BTRFS subvolume

  • @:corresponding to /
  • @home:corresponding to/home
  • @cache:corresponding to /var/cache
  • @docker:corresponding to /var/lib/docker
  • @log:corresponding to /var/log

Enabling COW in @cache, @log is not needed.

  1. Mount root partition to /mnt:
1
mount -t btrfs -o compress=lzo /dev/sda2 /mnt

Generally we lzo is good enough. Reports shows that btrfs is way slower even under Zstd:1, while lzo has nearly no difference compared with non-compressed.

  1. Create subvolumes:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
btrfs subvol create /mnt/@
btrfs subvol create /mnt/@home
btrfs subvol create /mnt/@cache
btrfs subvol create /mnt/@docker
btrfs subvol create /mnt/@log
btrfs subvol create /mnt/@tmp
btrfs subvol create /mnt/@swap
# Use chattr to disable COW 
chattr +C /mnt/@cache
chattr +C /mnt/@log
chattr +C /mnt/@swap
# Umount the partition
umount /mnt

Mount partitions and subvolumes

1
2
3
4
5
6
7
8
mount -o noatime,nodiratime,ssd,compress=lzo,subvol=@ /dev/sda2 /mnt
mkdir -p /mnt/{boot/efi,home,var/{log,lib/docker,cache},tmp,swap}
mount -o noatime,nodiratime,ssd,compress=lzo,subvol=@home /dev/sda2 /mnt/home
mount -o noatime,nodiratime,ssd,compress=lzo,subvol=@log /dev/sda2 /mnt/var/log
mount -o noatime,nodiratime,ssd,compress=lzo,subvol=@docker /dev/sda2 /mnt/var/lib/docker
mount -o noatime,nodiratime,ssd,compress=lzo,subvol=@cache /dev/sda2 /mnt/var/cache
mount -o noatime,nodiratime,ssd,compress=lzo,subvol=@tmp /dev/sda2 /mnt/tmp
mount -o noatime,nodiratime,ssd,compress=lzo,subvol=@swap /dev/sda2 /mnt/swap

Mount EFI partition:

1
mount /dev/sda1 /mnt/boot/EFI

Install the system

1
pacstrap /mnt base base-devel linux linux-firmware btrfs-progs networkmanager dhcpcd iwd vim sudo zsh zsh-completions {intel,amd}-ucode net-tools linux-headers curl git wget 

Generate fstab

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

Check again carefully after generation. Then proceed to post installation.

Post Installation

1
arch-chroot /mnt	

Set mirror for pacman

Use reflector or just update /etc/pacman.d/mirrorlist, then apply changes via pacman -Syy.

Install bootloader

In this article we use grub as the bootloader, since it is one of a few bootloaders has a good support to btrfs.

1
pacman -S grub efibootmgr os-prober
1
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Arch

successful results is shown below.

grub install success result

Then do some optimization. Increase the log level and add nowatchdog param to accelerate the speed of booting and powering off:

1
nano /etc/default/grub

and edit as below:

grub config

Save it and then generate new grub config file to apply changes.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
[root@archiso /] # grub—mkconfig —o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/intel—ucode.img /bootzamd—ucode.img /boot/initramfs—linux.img
Found fal Iback initrd image(s) in /boot :
intel—ucode.img amd—ucode.img initramfs—linux—fallback.img
Warning: os—prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

Set hostname and hosts

1
2
3
newHostname="Your-new-hostname"
echo $newHostname > /etc/hostname
echo -e "127.0.0.1   localhost\n" "::1         localhost\n" "127.0.1.1   $newHostname.localdomain $newHostname" >> /etc/hosts

Set Timezone

1
ln -sf /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime

Set locale

1
nano /etc/locale.gen

and uncomment en-US.UTF-8 UTF-8 and any locale you wanna to use, then generate locale and set en_US locale:

1
locale-gen && echo 'LANG=en_US.UTF-8'  > /etc/locale.conf

Setting up user accounts

First set the root account password:

1
passwd root	
1
2
yourName="example"
useradd -m $yourName && echo "Set a new password for the user $yourName" && passwd $yourName

Desktop Environment

In this article we install KDE:

1
pacman -S plasma plasma-wayland-session egl-wayland kde-{accessibility,graphics,multimedia,network,pim,sdk,system,utilities}-meta

VMware Tools

Arch Linux is not supported in the official VMware Tools. OpenVMTools is commonly used.

Using Open VM Tools one cannot resize the screeen properly. Here’s a solution following to a reddit post:

1
2
3
4
5
sudo pacman -Syu
sudo pacman -S open-vm-tools
sudo pacman -Su xf86-input-vmmouse xf86-video-vmware mesa gtk2 gtkmm
echo needs_root_rights=yes | sudo tee /etc/X11/Xwrapper.config
sudo systemctl enable --now vmtoolsd

And you are good to go.

Reference:

https://blog.zrlab.org/posts/arch-btrfs

https://wiki.archwiki.org

https://ericclose.github.io/Installing-Arch-as-a-guest-with-UEFI-and-GPT.html

https://arch.icekylin.online/rookie/basic-install.html

https://www.reddit.com/r/archlinux/comments/b0ona0/vmtools_on_arch_linux_full_screen_or_resizing/

OwO
Built with Hugo
Theme Stack designed by Jimmy