Skip to content

Instantly share code, notes, and snippets.

@legallyrobert
Created January 31, 2019 02:37
Show Gist options
  • Save legallyrobert/367cf17d37a5ae381eddf8588fa0e907 to your computer and use it in GitHub Desktop.
Save legallyrobert/367cf17d37a5ae381eddf8588fa0e907 to your computer and use it in GitHub Desktop.
Arch Linux Dual Boot Notes

Arch Dual Boot Notes

For Mid-2014 MacBook Pro, Retina 15"

Assuming a bootable USB was created, and booted into successfully.

Installation

Make font larger:

 # setfont sun12x22

Stop GPU overheating

 # grep . -r /sys/firmware/acpi/interrupts/gpe\*
 // highest number needs disabled
 # echo “disable” > /sys/firmware/acpi/interrupts/gpe17

Connect ethernet:

 # ip link -> ~”en0ps25”
 # dhcpcd <interface>
 // confirm connection
 # ping google.ca

Partition disk:

 # fdisk -l
 # cgdisk /dev/sda
 // select GPT, and create: /dev/sda3   of type linux 8300
 # lsblk

Format disk:

 # mkfs.ext4 /dev/sda3

Mount disks:

 # mount /dev/sda3 /mnt

Mount pre-existing EFI partition:

 # mkdir -p /mnt/boot
 # mount /dev/sda1 /mnt/boot		    // sda1 == EFI System Partition

Install base base-devel

 # pacstrap /mnt base base-devel

Generate fstab

 # genfstab -L -p /mnt >> /mnt/etc/fstab
 $ vi (/mnt?)/etc/fstab
 > /dev/sda3	/	ext4	rw,relatime,data=ordered,discard		0 1

Change root base into /mnt:

 # arch-chroot /mnt /bin/bash

Permanent TTY font

 # pacman -S terminus-font
 # setfont ter-932n
 # vi /etc/vconsole.conf
 > FONT=ter-932n

Uncomment locale

 # vi /etc/locale.gen
 # locale-gen
 # echo LANG=en_CA.UTF-8 > /etc/locale.conf

Hardware clock and timezone

 # ln -s /usr/share/zoneinfo/Zone/ZubZone /etc/localtime
 # hwclock —systohc —utc

Hostname

 # echo bespin > /etc/hostname
 # echo “127.0.0.1 bespin.localdomain bespin” >> /etc/hosts
 # systemctl enable dhcpcd

Set root user password

 # passwd

Kernel modules for fan speed/temp:

 # vi /etc/modules
 // add 2 lines: coretemp; applesmyc

Install Intel Ucode

 # pacman -Syu intel-ucode

Find PARTUUID:

 # blkid | awk '{print $1" "$(NF)}'
 // /dev/sda3 PARTUUID is: 2bcf28ae-2cc2-4484-8c1f-76d41883d5d6

Bootloader:

 # vi /boot/loader/entries/arch.conf	
 > title Arch Linux
 > linux /vmlinuz-linux
 > initrd /intel-ucode.img
 > initrd /initramfs-linux.img
 > options root=/dev/sdXY rw quiet acpi_mask_gpe=[GPE NUMBER HERE] acpi_osi=Darwin

Tell systemd-boot to use arch.conf (as default?)

 $ echo “default arch” > /boot/loader/loader.conf
 $ echo “timeout 5” >> /boot/loader/loader.conf

Install systemd-boot:

 # bootctl install

Post-install

Create user account

 # useradd -m -G wheel -s /bin/bash NAME
 # passwd PASSWD

Install essential packages:

 # pacman -S sudo vim

Set editor

 # vim /etc/environment
 > EDITOR=vim

Add wheel group to sudoers

 # visudo
 // uncomment %wheel ALL=(ALL) ALL

Reboot, remove installation media, pray to god, then login to account

 # exit
 # umount -R /mnt
 # reboot							    //REBOOT 1

Swap:

 $ sudo fallocate -l 16G /swapfile
 $ sudo chmod 600 /swapfile
 $ sudo mkswap /swapfile
 $ vim /etc/fstab
 > /swapfile	none		swap	defaults	0	0
 $ vim /etc/sysctl.d/99-sysctl.conf
 > vm.swappiness=10
 $ swapon /swapfile

Get offset of swapfile:

 $ sudo filefrag -v /swapfile     // first non-zero entry: 342016

Append swap options in boot entry:

 $ vim /boot/loader/entries/arch.conf
 > options = … resume=/dev/sda3 resume_offset=342016

Add “resume” hook after udev:

 $ vim /etc/mkinitcpio.conf
 $ mkinitcpio -p linux

Prevent immediate wake from suspend/hibernate:

 $ vim /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"

Install yay to install mbpfan-git

 $ pacman -S git
 $ git clone https:    //aur.archlinux.org/yay.git
 $ cd yay
 $ makepkg -si
 $ yay -S mbpfan
 $ sudo vim /etc/mbpfan.conf
     // fan1: {2160, 6156}; fan2: {2000, 5700}
	    # lowest value of "cat /sys/devices/platform/applesmc.768/fan\*_min"
	min_fan_speed = 2000

	    # highest value of "cat /sys/devices/platform/applesmc.768/fan\*_max"
	max_fan_speed = 6156
	
	    # try ranges 55-63, default is 63
	low_temp = 54

	    # try ranges 58-66, default is 66	
	high_temp = 66

	    # take highest number returned by
	    # "cat /sys/devices/platform/coretemp.\*/hwmon/hwmon\*/temp\*_max"
	    # divide by 1000	
	max_temp = 84

	    # default is 7 seconds
	polling_interval = 7
 $ service mob-fan start
 $ cp mbpfan.service /etc/systemd/system
 $ systemctl enable mbpfan.service

Power consumption:

 $ sudo pacman -S tlp
 $ sudo systemctl enable tlp
 $ sudo systemctl enable tlp-sleep
 $ sudo tlp start

USB Power saving:

 $ vim /etc/modprobe.d/snd_hda_intel.conf
 > options snd_hda_intel power_save=1

Regulate CPU speed:

 $ yay -S thermald
 $ sudo systemctl enable thermald
 $ sudo systemctl start thermald

Keyboard backlight:

 $ yay -S kbdlight
 // usage: kbdlight up [percentage] | down [percentage]

Calibrate powersaving (Intel powertop)

 $ pacman -S powertop
 $ powertop --calibrate					    // do not interrupt
 $ powertop --auto-tune

To apply optimal settings at boot:

 $ vim /etc/systemd/system/powertop.service
 > [Unit]
 > Description=Powertop tunings
 >
 > [Service]
 > Type=oneshot
 > ExecStart=/usr/bin/powertop --auto-tune
 >
 > [Install]
 > WantedBy=multi-user.target
 $ systemctl enable powertop.service

Enable audio:

 $ yay -S alsa-utils pulseaudio
     // systemd
 $ alsamixer 							    // unmute all mixers

Audio powersaving and switching output from HDMI to PCH

 $ vim /etc/modprobe.d/60-snd_hda_intel.conf            // to add:
 > options snd_hda_intel index=1,0 power_save=1

Fix unwanted laptop resume after close, ensure XHC1 is still disabled

 $ cat /proc/acpi/wakeup

Wifi:

 $ yay -S broadcom-wl
 $ pacman -S network manager
 $ systemctl enable NetworkManager

Reboot:

 $ sudo reboot					    //  REBOOT 2
 $ speaker-test -c 2
 $ ip link     // check for Wifi Interface e.g. wlp2s0
 $ nmcli dev wifi connect SSID password PASSWD

After rebooting check output to verify XHC1 status is disabled

 $ cat /proc/acpi/wakeup

Getting Graphical

Install Xorg:

 $ pacman -S xorg-server org-xrandr xorg-xinit xorg-fonts
@legallyrobert
Copy link
Author

Powersaving, battery, and graphics are all shit with this install.

Call me crazy but I've just decided to sell my MacBook in favour of the PineBook Pro which is due to come out very soon... hopefully! Probably going to install Arch on it, or maybe OpenBSD tbh. We shall see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment