Fanbo He <hefanbo@gmail.com> (CC BY 4.0)
2017/12/23
Insall Arch Linux along with Mac OS on MacBook Pro.
- Hardware: MacBook Pro (Retina, 13-inch, Early 2015)
- Software: Arch Linux (201711)
- In MacOS, run Disk Utility.app (located in /Applications/Utilities)
- Select the drive to be partitioned in the left-hand column (not the partitions!). Click on the Partition button.
- Add a new partition by pressing the + button and choose how much space you want to leave for MacOS (in this article, 32GB), and how much for the new partition. Keep in mind the new partition will be formatted in Arch Linux, so you can choose any partition type you want.
- Download Arch Linux image from https://www.archlinux.org/download/
- Make a bootable USB stick with LiLi USB Creator
- Plug the USB stick in
- Press power key. Hold
ALT
key until boot menu shows. SelectEFI boot
.
Connect to WiFi (WPA2, Hidden SSID)
Use the following command to find the network interface name, e.g., wlp3s0
# iw dev
Bring up the interface
# ip link set wlp3s0 up
Configure SSID and password:
# wpa_passphrase MYSSID > wpa.conf
Type password and press enter. Edit wpa.conf
, add following lines
ctrl_interface=/run/wpa_supplicant
update_config=1
network={
...
scan_ssid=1
...
}
Connect and obtain IP
# wpa_supplicant -B -i wlp3s0 -c wpa.conf
# dhcpcd wlp3s0
In case something goes wrong, use wpa_cli
to find some clues
# wpa_cli -i wlp3s0
# ls /sys/firmware/efi/efivars
# timedatectl set-ntp true
Check partition info to get device names, e.g., /dev/sda*
# fdisk -l
Modify partitions with cgdisk
:
# cgdisk /dev/sda
Delete the partition which is reserved for disk space. Add partition, type +128M
for start, and -128M
for end. Write and exit.
Format partition and mount, assuming that /dev/sda1
is the EFI partition, and /dev/sda3
is the partition for Linux.
# mkfs.ext4 /dev/sda3
# mount /dev/sda3 /mnt
# mkdir /mnt/boot
# mount /dev/sda1 /mnt/boot
Find PARTUUID for /dev/sda3
, e.g., XXXX-YYYY-ZZZZ
# ls -l /dev/disk/by-partuuid
In /etc/pacman.d/mirrorlist
, delete unwanted mirror entries. Install base:
# pacstrap /mnt base
# genfstab -U /mnt >> /mnt/etc/fstab
# arch-chroot /mnt
# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# hwclock --systohc
Uncomment en_US.UTF-8 UTF-8
in /etc/locale.gen
# locale-gen
Edit /etc/locale.conf
, add
LANG=en_US.UTF-8
Add hostname to /etc/hostname
Add entry to /etc/hosts
127.0.1.1 myhostname.localdomain myhostname
Change root password
# passwd
Install Intel micro code
# pacman -S intel-ucode
Install and configure systemd-boot
# bootctl --path=/boot install
Edit /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options root=PARTUUID=XXXX-YYYY-ZZZZ rw
Edit /boot/loader/loader.conf
default arch
Create new user
# useradd -m -G wheel -s /bin/bash your_user_name
# passwd your_user_name
Install some basic software
# pacman -S sudo vim wpa_supplicant
Edit /etc/environment
, add
EDITOR=vim
Add wheel group to sudoers
# visudo
Uncomment the line
%wheel ALL=(ALL) ALL
To enable auto-completion for sudo
, add this line to .bashrc
in the home directory
if [ "$PS1" ]; then
complete -cf sudo
fi
Press Ctrl-D
to exit chroot, unmount /mnt/boot
and /mnt
, reboot.
- Press power key, and system will boot to Arch Linux by default.
- Press power key, hold
ALT
until boot menu shows, and selectMacintosh HD
to boot to MacOS
Log in as normal user, and connect to WiFi.
Edit /etc/systemd/logind.conf
, set NAutoVTs
and ReserveVT
values.
$ sudo pacman -S --needed base-devel
$ echo keyring /etc/pacman.d/gnupg/pubring.gpg >> ~/.gnupg/gpg.conf
$ mkdir -p ~/software/aur
$ cd ~/software/aur
$ curl -O -J https://aur.archlinux.org/cgit/aur.git/snapshot/cower.tar.gz
$ tar xzf cower.tar.gz
$ cd cower
$ makepkg -si
$ cd ..
$ cower -d pacaur
$ cd pacaur
$ vim PKGBUILD
Remove lines related to zsh
because we don't use it, and run
$ makepkg -si
$ sudo pacman -S x86-video-intel xorg-server lxqt sddm
$ sudo pacman -S xorg-xrandr
$ sudo pacman -S libpulse libstatgrab libsysstat lm_sensors
$ sudo systemctl enable sddm
/usr/bin/xdg-open
expects the file manager to be pcmanfm
while it is pcmanfm-qt
actually in LXQt. To fix this, either edit xdg-open
or make a soft link to pcmanfm-qt
.
Create /etc/X11/xorg.conf.d/90-monitor.conf
, add
Section "Monitor"
Identifier "<default monitor>"
DisplaySize 286 179 # In millimeters
EndSection
Edit /etc/environment
, add
#QT_AUTSCREEN_SCALE_FACTOR=1
#QT_SCREEN_SCALE_FACTOR=2
QT_SCALE_FACTOR=2
GDK_DPI_SCALE=2
Edit /etc/vconsole.conf
, add
FONT=latarcyrheb-sun32
$ sudo pacman -S noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-cjk
$ sudo pacman -S papirus-icon-theme xcursor-flatbed
Go to Start -> Preferences -> LXQt settings -> Appearance
, and select themes for current user. To set cursor size, open .config/lxqt/session.conf
, add cursor_size=48
to Mouse
section.
To apply the cursor theme globally, edit /usr/share/icons/default/index.theme
, set
[Icon Theme]
Inherits=FlagbedCursors-Black
- Right click the application menu, select
Configure
, and you can choose the menu file. - You can copy the menu file from the default
Menu file
location to.config/menu
, and use it as an example.
Create /etc/sddm.conf
with the following contents
[Theme]
Current=elarun
The theme is defined in /usr/share/sddm/themes/elarun/Main.qml
Create /etc/X11/xorg.conf.d/30-touchpad.conf
Section "InputClass"
Identifier "TouchPad"
MatchDriver "libinput"
MatchProduct "bcm5974"
Option "AccelSpeed" "1"
Option "Tapping" "on"
EndSection
$ pacaur -S cmst
Go to Start -> Preferences -> Session Settings
, and add /usr/bin/cmst -m
to autostart.
Create /usr/local/bin/scr_light
with the following contents
sysfs="/sys/class/backlight/intel_backlight"
steps=347
max=`cat ${sysfs}/max_brightness`
level=`cat ${sysfs}/brightness`
step=`expr $max / $steps`
min=20
usage()
{
script=${0##*/}
echo
echo "Invalid usage of ${script}!"
echo " $1"
echo "----------------"
echo "$script up : increases brightness"
echo "$script down : decreases brightness"
echo "$script set # : sets brightness to # (integer)"
echo "----------------"
echo
exit 1
}
set_brightness()
{
level=$1
if [ $level -lt $min ] ; then
level=$min
elif [ $level -gt $max ] ; then
level=$max
fi
echo $level > $sysfs/brightness
}
case "$1" in
up)
let "level+=$step"
set_brightness $level
;;
down)
let "level-=$step"
set_brightness $level
;;
set)
if [[ ! $2 =~ ^[[:digit:]]+$ ]]; then
usage "second argument must be an integer"
fi
set_brightness $2
;;
*)
usage "invalid argument"
esac
Add user to video
group and allow this group to run the script without password
$ sudo usermod -aG video $USER
% sudo visudo
Add this line
%video ALL=(ALL) NOPASSWD: /usr/local/bin/scr_light
Open Shortcut Keys
settings, add sudo scr_light down
and sudo scr_light up
commands to appropriate keys.
Create /usr/local/bin/kbd_light
identical to /usr/local/bin/scr_light
with the following exceptions
sysfs="/sys/class/leds/smc::kbd_backlight"
steps=5
min=0
Add user to input
group and allow this group to run the script without password
Open Shortcut Keys
settings, add sudo scr_light down
and sudo scr_light up
commands to appropriate keys.
There is no sound by default because the default sound output is HDMI. To fix this, there are 3 methods:
Create /etc/modprobe.d/sound.conf
with the following content
options snd-hda-intel index=1,0
Create /etc/asound.conf
with the following content
defaults.pcm.card 1
Create /etc/modprobe.d/sound.conf
with the following content
options snd-hda-intel enable=0,1
To switch Fn
key mode, create /etc/modprobe.d/hid_apple.conf
options hid_apple fnmode=2
Edit /etc/systemd/logind.conf
, set
HandlePowerKey=Ignore
Use lsusb
or udevadm info
to check internal keyboard device info.
Use evtest
to check key scan code.
$ sudo pacman -S evtest
$ sudo evtest
Create /etc/udev/hwdb.d/10-kbd-modifiers.hwdb
evdev:input:b0003v05ACp0273* # correspongding to keyboard device info
KEYBOARD_KEY_700e3=leftmeta # leading space is required
KEYBOARD_KEY_700e3=leftalt
KEYBOARD_KEY_700e7=delete
KEYBOARD_KEY_700e6=rightctrl
Update database and reboot
sudo systemd-hwdb update
$ sudo pacman -S systemd-swap
Set swapfc_enabled=1
in /etc/systemd/swap.conf
. And
$ sudo systemctl enable systemd-swap
As systemd-swap
cannot be used for hibernation, a swap file must be created.
$ sudo fallocate -l 5G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
Edit /etc/fstab
, add
/swapfile none swap defaults 0 0
Create /etc/sysctl.d/99-sysctl.conf
vm.swappiness=10
$ sudo pacman -S xscreensaver
To customize lock dialog of xscreensaver
$ sudo pacman -S xorg-xrdb
Create .Xresources
to enlarge font size, hide New Login
button and the date string
xscreensaver.newLoginCommand:
xscreensaver.dateFormat:
xscreensaver.Dialog.headingFont: -*-noto mono-medium-r-normal-*-*-160-*-*-*-*-*-*
xscreensaver.Dialog.labelFont: -*-noto mono-medium-r-normal-*-*-240-*-*-*-*-*-*
xscreensaver.Dialog.unameFont: -*-noto mono-medium-r-normal-*-*-240-*-*-*-*-*-*
xscreensaver.passwd.passwdFont: -*-noto mono-medium-r-normal-*-*-240-*-*-*-*-*-*
xscreensaver.Dialog.buttonFont: -*-noto mono-medium-r-normal-*-*-240-*-*-*-*-*-*
Create /etc/X11/xorg.conf.d/10-fontpath.conf
Section "Files"
FontPath "/usr/share/fonts/noto"
EndSection
To test fonts, xorg-xfontsel
and xorg-xlsfonts
are recommended.
$ sudo filefrag -v /swapfile
Remember the physical_offset
value in the first row, which is refered as SWAPFILE_OFFSET here after.
Edit /boot/loader/entries/arch.conf
, add
optioins resume=PARTUUID=xxxx-yyyy-zzzz resume-offset=SWAPFILE_OFFSET
Edit /etc/mkinitcpio.conf
, add resume
behind udev
in HOOKS
.
$ sudo mkinitcpio -p linux
To prevent immediate wake up after suspend/hibernate, create /etc/udev/rules.d/90-wake.conf
# ARPT
SUBSYSTEM=="pci", KERNEL=="0000:03:00.0", ATTR{power/wakeup}="disabled"
# XHC1
SUBSYSTEM=="pci", KERNEL=="0000:00:14.0", ATTR{power/wakeup}="disabled"
# LID0
SUBSYSTEM=="acpi", KERNEL=="PNP0C0D:00", ATTR{power/wakeup}="disabled"
For information, the following commands may be useful
$ evtest
$ lspci
$ lsusb
$ cat /proc/acpi/wakeup
$ udevadm info /dev/inputevent2
$ udevadm info -a /dev/inputevent2
Reboot.
$ sudo pacman -S xarchiver
$ sudo pacman -S zip unzip p7zip unrar
$ sudo pacman -S fcitx-im fcitx-configtool fcitx-sunpinyin
Edit /etc/environment
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
$ sudo pacaur -S sirikali ecryptfs-simple
Create /etc/modules-load.d/ecryptfs.conf
with the following content
ecryptfs
$ sudo pacman -S samba gvfs-smb
Create /etc/samba/smb.conf
based on this file
Edit .config/gtk-3.0/settings.ini
[Settings]
gtk-recent-files-max-age=0
gtk-recent-files-limit=0
Edit .gtkrc-2.0
gtk-recent-files-max-age=0
$ pacaur -S bcwc-pcie-git
$ sudo pacman -S qemu virt-manager
$ sudo pacman -S ebtables dnsmasq
$ sudo systemctl enable libvirtd
$ sudo systemctl enable libvirt-guests
$ sudo usermod -aG libvirt $USER
$ pacman -S goldendict mpv
$ sudo pacman -S alsa-utiles
$ alsamixer
Mute S/PDIF
Disable DNS proxy of connman. Create folder /etc/systemd/system/connman.service.d
, and add file disable_dns_proxy.conf
[Service]
ExecStart=
ExecStart=/usr/bin/connmand -n --nodnsproxy
- Terminal emulator supporting Chinese
- Space between icons is too large when Chinese font is selected
- Color profile from Mac (tried that, but it seems to have no effect, maybe the default color profile is good enough)
- WiFi down after resuming from suspend/hibernate
- Turn off screen when lid close without sleeping