Fog: Difference between revisions

From wikinotes
(Replaced content with "Named after Dean Fog. = Notes = <blockquote> {| class="wikitable" |- | t2linux archlinux install |- | t2linux archlinux mbp-16.1 |} </blockquote><!-- Notes -->")
Tag: Replaced
 
(30 intermediate revisions by the same user not shown)
Line 1: Line 1:
Archlinux on a macbook. Named after Dean Fog.
Named after Dean Fog.
 
{{ TODO |
these install instructions don't belong here.<br>
I need a section for archlinux variant installs like archlinux-arm, and this alt-kernel }}


= Notes =
<blockquote>
{| class="wikitable"
{| class="wikitable"
|-
|-
| t2linux install docs || https://wiki.t2linux.org/distributions/arch/installation/
| [[t2linux archlinux install]]
|-
| t2linux wifi docs || https://wiki.t2linux.org/guides/wifi/
|-
| t2linux pacman repo || https://github.com/Redecorating/archlinux-t2-packages
|-
| arch install || https://wiki.archlinux.org/title/Installation_guide#Set_the_console_keyboard_layout
|-
| systemd boot || https://wiki.archlinux.org/title/Systemd-boot
|-
|}
 
= Safety Net =
<blockquote>
Using the dedicated GPU 100% of the time produces lots of heat, and wasted battery life when you don't need it.<br>
Defaulting to the dedicated graphics has been known to prevent MacOS from being able to boot.<br>
Since Partition settings are locked into MacOS (and I'm uncertain whether I could boot from a USB),<br>
it would be prudent to enable ssh in your MacOS install).
 
<syntaxhighlight lang="yaml">
# MacOS
(apple) > System Preferences:
  - Security & Privacy:
    - Privacy Tab:
      - Full Disk Access:
        - +: Applications/Utilities/Terminal
</syntaxhighlight>
 
<syntaxhighlight lang="bash">
# MacOS
sudo systemsetup -setremotelogin on
 
# you probably also want to harden your /etc/ssh/sshd_config...
</syntaxhighlight>
</blockquote><!-- Safety Net -->
 
= Install Media =
<blockquote>
Download install media
{|
|-
| raw (out of date) || https://dl.t2linux.org/archlinux/iso/index.html
|-
| w/ wifi drivers || https://github.com/t2linux/archiso-t2/releases
|-
|-
| [[t2linux archlinux mbp-16.1]]
|}
|}
 
</blockquote><!-- Notes -->
<syntaxhighlight lang="yaml">
diskutil list
diskutil unmountDisk /dev/disk2
dd if=path/to/archlinux-version-x86_64.iso of=/dev/rdisk2 bs=1m
</syntaxhighlight>
</blockquote><!-- install media -->
 
= Partition Setup =
<blockquote>
You can't change the partition scheme from outside of macos unfortunately.
 
<syntaxhighlight lang="yaml">
- macbook, start bootcamp (preinstalled)
  - drag slider for size (deletes apfs snapshots?)
 
- disk utility
  - create a partition (any format) for your linux install
 
- restart, holding cmd+r
  - Utilities > Startup Security Utility:
    - [x] No Security
    - [x] Allow booting from external media
 
- restart, holding opt
  - you don't need to connect to wifi in bootloader
  - boot from EFI
</syntaxhighlight>
</blockquote><!-- Partition Setup -->
 
= Base Install =
<blockquote>
{{ NOTE |
Use the wifi-enabled ISO, spoke with devs and wired kernel is outdated
}}
 
== (archiso) wlan setup ==
<blockquote>
<syntaxhighlight lang="bash">
iwctl
device list
station wlan0 scan
station wlan0 get-networks
station wlan0 connect ${SSID}
 
ping archlinux.org
</syntaxhighlight>
</blockquote><!-- (archiso) wlan setup -->
 
== (archiso) format && baseinstall ==
<blockquote>
<syntaxhighlight lang="bash">
timedatectl set-ntp true
 
pacman -Sy
# pacman-key --refresh-keys
 
fdisk -l                  # find disk/partition
mkfs.ext4 /dev/nvme0n1p3  # format partition as ext4
 
mount /dev/nvme0n1p3 /mnt      # your install
mkdir -p /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot  # reuse macbook's EFI paritition
 
# if necesary, copy/modify /etc/pacman.conf to /mnt/pacman.conf
# and use: `pacstrap -C /mnt/pacman.conf`
pacstrap /mnt \
  base base-devel                          `# base packages/build-tools` \
  linux-t2 linux-t2-headers linux-t2-docs  `# t2-kernel` \
  efivar efibootmgr dosfstools              `# tools to manage efi` \
  linux-firmware dkms \
  apple-bcm-wifi-firmware \
  iwd networkmanager netstat-nat net-tools \
  neovim git openssh man-db
 
genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt
</syntaxhighlight>
</blockquote><!-- (archiso) format && baseinstall -->
 
== (chroot) Add t2linux repo ==
<blockquote>
<syntaxhighlight lang="bash">
cat << EOF >> /etc/pacman.conf
[mbp]
Server = https://dl.t2linux.org/archlinux/$repo/$arch
EOF
 
pacman -Syy
</syntaxhighlight>
</blockquote><!-- (chroot) Add t2linux repo -->
 
== (chroot) Base Settings ==
<blockquote>
<syntaxhighlight lang="bash">
ln -sf /usr/share/zoneinfo/America/Toronto /etc/localtime
hwclock --systohc
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "fog" > /etc/hostname
mkinitcpio -P
passwd
</syntaxhighlight>
</blockquote><!-- (chroot) Base Settings -->
 
== (chroot) Bootloader ==
<blockquote>
<syntaxhighlight lang="bash">
cat << EOF > /boot/loader/loader.conf
default archlinux
timeout 1
EOF
 
# find PARTUUID of 'archlinux' install partition
# (not EFI partition, not UUID)
blkid
 
cat << EOF > /boot/loader/entries/archlinux.conf
title Arch Linux
linux vmlinuz-linux-t2
initrd initramfs-linux-t2.img
# no quotes around PARTUUID
options intel_iommu=on iommu=pt pcie_ports=compat root=PARTUUID=${PARTUUID} rw
EOF
 
# if you cannot write /boot, use --no-variables
bootctl install
 
systemctl mask systemd-boot-system-token
 
# remount efivars as read-only (or kernel panic)
# USE EITHER: (1 works for me)
#    echo efivarfs /sys/firmware/efi/efivars efivarfs ro,remount,nofail 0 0 >> /etc/fstab
# OR
#    add 'efi=noruntime' to options in '/boot/loader/entries/archlinux.conf'
</syntaxhighlight>
</blockquote><!-- (chroot) Bootloader -->
 
== Reboot ==
<blockquote>
<syntaxhighlight lang="yaml">
- exit && reboot
- hold 'option' while booting to choose boot
- after selection, wait for timeout (choosing with enter seems to fail)
</syntaxhighlight>
</blockquote><!-- Reboot -->
 
== Debugging Boot Issues ==
<blockquote>
<syntaxhighlight lang="bash">
# from archiso, specify the journal of your chroot
journalctl --directory=/var/log/journal
</syntaxhighlight>
</blockquote><!-- Debugging Boot Issues -->
</blockquote><!-- Base Install -->
 
= Post Install =
<blockquote>
== Wifi Drivers ==
<blockquote>
Boot into macos
<syntaxhighlight lang="bash">
curl -#O https://wiki.t2linux.org/tools/wifi.sh
chmod +x wifi.sh
./wifi.sh
</syntaxhighlight>
 
Boot into linux
<syntaxhighlight lang="bash">
sudo umount /dev/nvme0n1p1
sudo mkdir /tmp/apple-wifi-efi
sudo mount /dev/nvme0n1p1 /tmp/apple-wifi-efi
bash /tmp/apple-wifi-efi/wifi.sh
sudo reboot
</syntaxhighlight>
 
Now verify output of wifi driver is error-free.
<syntaxhighlight lang="bash">
sudo journalctl -k --grep=brcmfmac  # check for errors
ip link                            # check for wlan0
</syntaxhighlight>
 
Now you can test a connection
<syntaxhighlight lang="bash">
systemctl start iwd
iwctl
> station wlan0 scan
> station wlan0 get-networks
> station wlan0 connect ${SSID}
</syntaxhighlight>
 
Finally, use NetworkManager (for wireguard, routing) with iwd as backend
<syntaxhighlight lang="bash">
cat << EOF > /etc/NetworkManager/NetworkManager.conf
[device]
wifi.backend=iwd
EOF
 
sudo systemctl enable --now iwd
sudo systemctl restart NetworkManager
 
route              # confirm routing table present
ping archlinux.org  # test
</syntaxhighlight>
</blockquote><!-- Wifi -->
 
== CPU fan ==
<blockquote>
Install and configure [[mbpfan]],<br>
monitor effectiveness with [[lm_sensors]].
</blockquote><!-- CPU fan -->
 
== GPU ==
<blockquote>
=== Dedicated GPU Drivers ===
<blockquote>
Install GPU drivers (OSS reputably better here)
<syntaxhighlight lang="bash">
lscpi -nn | grep VGA  # find gpu
 
pacman -S xf86-video-ati    # oss
# or
pacman -S xf86-video-amdgpu # proprietary
</syntaxhighlight>
 
=== Hybrid Graphics ===
<blockquote>
{{ WARNING |
<code>gpu-switch</code> has not been tested on anything beyond 2015's MBP offerings.<br>
It does not work on a 2019 MBP.<br>
To undo this footgun, see https://apple.stackexchange.com/questions/267581/gpu-problem-boot-hangs-on-grey-screen/295805#295805
 
<pre>
nvram -p  # print all variables
 
# reboot, holding: cmd+opt+p+r until 2x chimes resets nvram
#
# you'll need to set anything stored in nvram:
#  * boot chime preferences
#  * efibootmgr entries
</pre>
 
}}
First, install dedicated GPU drivers
 
 
Next, install patched bootloader
<syntaxhighlight lang="bash">
# there is an AUR package, but it is very out of date
 
sudo pacman -S gnu-efi
 
git clone https://github.com/aa15032261/apple_set_os-loader
cd apple_set_os-loader
 
make
sudo cp /boot/EFI/BOOT/BOOTX64.EFI /boot/EFI/BOOT/BOOTX64.EFI.orig
sudo cp ./bootx64.efi /boot/EFI/BOOT/BOOTX64.EFI
</syntaxhighlight>
 
reboot, and verify that it worked
<syntaxhighlight lang="bash">
lspci -s 00:02.0 # should list intel card
</syntaxhighlight>
 
List currently active GPU
<syntaxhighlight lang="bash">
pacman -S mesa-utils
glxinfo | grep "OpenGL renderer"
</syntaxhighlight>
 
Install latest gpu-switch
<syntaxhighlight lang="bash">
# there is an AUR package, but it is very out of date
#
# this is a friendly little shellscript, can change if needed.
 
curl https://raw.githubusercontent.com/0xbb/gpu-switch/master/gpu-switch > gpu-switch
chmod +x gpu-switch
sudo chown root:root gpu-switch
sudo mv gpu-switch /usr/bin/
</syntaxhighlight>
 
Since efivars is mounted as read-only, you'll need to boot from arch-iso and run the following
<syntaxhighlight lang="bash">
sudo gpu-switch -i  # next boot uses integrated graphics
sudo gpu-switch -d  # next boot uses dedicated graphics
</syntaxhighlight>
</blockquote><!-- Hybrid Graphics -->
</blockquote><!-- Dedicated GPU Drivers -->
</blockquote><!-- GPU -->
 
== Heat/Power Optimization ==
<blockquote>
=== Configuration ===
<blockquote>
Install and Enable
 
* [[mbpfan]]
* [[cpupower]]
* [[tlp]]
* [[thermald]]
 
<syntaxhighlight lang="bash">
# /boot/loader/entries/archlinux.conf
 
# disable intel_pstate so userspace power management available.
options intel_pstate=disable # ...
</syntaxhighlight>
 
<syntaxhighlight lang="bash">
# /etc/default/cpupower
 
# enable conservative governor, the most resistant to ramp up cpu cycles
# some others: ondemand, userspace
governor='conservative'
</syntaxhighlight>
 
<syntaxhighlight lang="bash">
# find warnings with tlp (ex: warning: systemd-rfkill.service is not masked, to correct this...)
sudo tlp-stat -s
 
# correct warnings
sudo systemctl mask systemd-rfkill.service
sudo systemctl mask systemd-rfkill.socket
</syntaxhighlight>
</blockquote><!-- Configuration -->
 
=== Monitoring ===
<blockquote>
* [[powertop]]
* [[i7z]]
 
monitoring some usage stats
<syntaxhighlight lang="bash">
sudo i7z                          # cpu freq per core
sudo tlp-stats -p                  # power optimizations
sudo tlp-stats -t                  # temp/fan-speeds
watch eval 'sensors | head -n 10'  # cpu temps
watch eval 'cpupower frequency-info | grep "current CPU"'
</syntaxhighlight>
</blockquote><!-- Monitoring -->
</blockquote><!-- Heat/Power Optimization -->
 
== Trackpad ==
<blockquote>
<syntaxhighlight lang="bash">
pacman -S xf86-input-synaptics
reboot # for driver to be used
 
# test it out if you like
synclient AccelFactor=0.05  # smaller movements travel further
</syntaxhighlight>
 
make permanent
<syntaxhighlight lang="conf">
# /etc/X11/xorg.conf.d/70-synaptics.conf
 
Section "InputClass"
  Identifier "touchpad"
  Driver "synaptics"
  MatchIsTouchpad "on"
 
  # moving mouse-pointer
  Option "AccelFactor" "0.01"
  Option "MinSpeed" "1.2"
  Option "MaxSpeed" "2.5"
 
  # scroll momentum speed
  Option "VertScrollDelta" "250"
EndSection
</syntaxhighlight>
</blockquote><!-- Trackpad -->
 
== Function Keys ==
<blockquote>
{{ TODO |
* default to function keys
* multimedia keys don't work
* following suspend/resume, touchbar doesn't work at all
}}
</blockquote><!-- Function Keys -->
 
== Disable Boot Sound ==
<blockquote>
<syntaxhighlight lang="yaml">
# MacOs
System Preferences:
  Sound:
    - [ ] Play Sound on Startup
</syntaxhighlight>
</blockquote><!-- Disable Boot Sound -->
 
== Default Boot ==
<blockquote>
Choosing default Disk
<syntaxhighlight lang="yaml">
- boot macos
- apple-menu > system preferences:
  - startup disk
</syntaxhighlight>
 
Choosing default EFI bootloader
<syntaxhighlight lang="bash">
# show installed bootloaders
#
#  BootOrder: 0080,0000  # boot priority
#  Boot0080:  Mac OS X  # macos boot entry
#  Boot0000:  Foo        # foo boot entry
efibootmgr
 
efibootmgr -o 0000,0080  # change boot priority
</syntaxhighlight>
</blockquote><!-- Default Boot -->
 
== Audio ==
<blockquote>
TODO
</blockquote><!-- Audio -->
</blockquote><!-- Post Install -->

Latest revision as of 01:51, 13 March 2022