<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.3">Jekyll</generator><link href="https://pass86.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://pass86.github.io/" rel="alternate" type="text/html" /><updated>2023-04-15T17:11:25+00:00</updated><id>https://pass86.github.io/feed.xml</id><title type="html">Jimmy’s Pages</title><subtitle>Jimmy's Pages</subtitle><entry><title type="html">Install Arch Linux on MBP18</title><link href="https://pass86.github.io/2023/04/15/install-arch-linux-on-mbp18.html" rel="alternate" type="text/html" title="Install Arch Linux on MBP18" /><published>2023-04-15T00:00:00+00:00</published><updated>2023-04-15T00:00:00+00:00</updated><id>https://pass86.github.io/2023/04/15/install-arch-linux-on-mbp18</id><content type="html" xml:base="https://pass86.github.io/2023/04/15/install-arch-linux-on-mbp18.html">&lt;p&gt;我有一台闲置的MacBook Pro 2018，一直都不知道拿来做什么，放在抽屉里，有一天拿来用居然开不了机了，去苹果店检查是主板坏了，苹果的做法是只换不修，换主板需要5K多，修好再卖个二手都不一定能赚钱。后面在淘宝上找到一家华强北的店可以修苹果电脑，最近去把它修好了，只花了几百块，问了下这台MBP能卖多少钱，说只能卖3K左右，真不想这样贱卖了。&lt;/p&gt;

&lt;p&gt;但是又不想这样闲置下去，于是想了几个可以用它来做的事情。我一直没有一台电脑是拿Arch Linux作为主力桌面系统的，之前装在NUC上的Arch Linux是作为服务器运行，追求稳定长时间运行，不打算装桌面系统。那我为什么需要一台Arch Linux桌面系统呢，目前想到两个应用的地方：一是用来编译Open Wrt，我一直想自己编译调试Open Wrt，但一直没有合适让我折腾的环境；二是用来编译AOSP，之前编译AOSP的环境是安装在移动硬盘上的一个Ubuntu，需要编译时插到我的PC上，感觉也是很临时。这个MBP装上Arch Linux可以作为我在Linux下的主力开发机。&lt;/p&gt;

&lt;p&gt;2018年的MBP有T2芯片，Arch Linux官方的ISO没有支持好，我装了官方的ISO测试，可以安装到MBP的SSD上去，系统可以启动，但是笔记本键盘，无线网卡，USB有线网卡都不能用，只能用USB键盘。这样的系统装上去也没啥用处了。在MBP上装Linux这个事情，看来也是有不少人有这需求，于是有了&lt;a href=&quot;https://github.com/t2linux&quot;&gt;Linux for T2&lt;/a&gt;，从这里&lt;a href=&quot;https://github.com/t2linux/archiso-t2/releases&quot;&gt;archiso-t2&lt;/a&gt;下Arch Linux的ISO，再按照&lt;a href=&quot;https://wiki.t2linux.org/distributions/arch/installation/&quot;&gt;Installation wiki&lt;/a&gt;，结合我之前安装Arch Linux经验，我已经能在MBP18上运行Arch Linux，笔记本键盘，无线网卡，USB有线网卡，USB键盘都测试可用，不过还没有装桌面系统，这个后面再做。其中也是遇点坑，有必要把整个过程记录下来，下次装的时候也能快点，希望也能帮助到有同样需求的网友。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;制作安装U盘&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这次我参考了&lt;a href=&quot;https://wiki.t2linux.org/guides/preinstall/&quot;&gt;t2linux文档&lt;/a&gt;使用dd的方式，之前用dd一直填的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;of=/dev/diskX&lt;/code&gt;，速度很慢，这次用了&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;of=/dev/rdiskX&lt;/code&gt;，U盘是满速写入，比之前快了很多。&lt;/p&gt;

&lt;p&gt;macOS中使用dd需要给终端增加权限，系统设置=&amp;gt;隐私与安全性=&amp;gt;完全磁盘访问权限=&amp;gt;+=&amp;gt;终端。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 查看U盘是哪个disk&lt;/span&gt;
diskutil list
&lt;span class=&quot;c&quot;&gt;# 假如是/dev/disk2，先卸载它&lt;/span&gt;
diskutil unmountDisk /dev/disk2
&lt;span class=&quot;c&quot;&gt;# 写入archlinux-t2的ISO&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo dd &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;archlinux-t2-2023.03.23-t2-x86_64.iso &lt;span class=&quot;nv&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/rdisk2 &lt;span class=&quot;nv&quot;&gt;bs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1m
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;关闭文件保险箱&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;系统设置=&amp;gt;隐私与安全性=&amp;gt;文件保险箱=&amp;gt;关闭…&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;磁盘分区&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;打开&lt;a href=&quot;https://support.apple.com/guide/disk-utility/dskutl14027/mac&quot;&gt;磁盘工具&lt;/a&gt;，左边选中APPLE SSD，右边点击分区=&amp;gt;点击加号=&amp;gt;添加分区=&amp;gt;名称和格式随意（后面会被抹掉），大小我给Macintosh HD留了50GB，其他全给Arch Linux=&amp;gt;应用。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;提取Wi-Fi和蓝牙的固件&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;相当于Wi-Fi和蓝牙的驱动是用苹果官方的，完整文档在&lt;a href=&quot;https://wiki.t2linux.org/guides/wifi-bluetooth/&quot;&gt;这里&lt;/a&gt;，下载提取脚本&lt;a href=&quot;https://wiki.t2linux.org/tools/firmware.sh&quot;&gt;firmware.sh&lt;/a&gt;。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 做的事情就是把固件打包放到EFI分区&lt;/span&gt;
bash ~/Downloads/firmware.sh
&lt;span class=&quot;c&quot;&gt;# 可以检查下是否有firmware.sh和firmware.tar.gz&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;diskutil mount disk0s1
&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; /Volumes/EFI
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;从U盘启动&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这里有个坑，U盘要用USB Type-A到Type-C的转接头，直接插在MBP上，试了插在贝尔金的Dock和绿联的Hub上都会导致启动卡死，后面用了Google Pixel 2包装盒里带的转接头才顺利进入U盘系统。&lt;/p&gt;

&lt;p&gt;安装时需要联网下载软件包，所以要连接有线网络，我用的是绿联那个带网线接口的Hub。&lt;/p&gt;

&lt;p&gt;插入安装U盘，MBP启动时按住option，直到出现选择启动磁盘的画面，选择&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EFI Boot&lt;/code&gt;。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;查看硬盘情况&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fdisk &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;创建文件系统&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkfs.ext4 /dev/nvme0n1p3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;挂载文件系统&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mount /dev/nvme0n1p3 /mnt
&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /mnt/boot/efi
mount /dev/nvme0n1p1 /mnt/boot/efi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置代理&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;懂的都懂。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HTTP_PROXY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;http://192.168.1.1:8080
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HTTPS_PROXY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;http://192.168.1.1:8080
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;安装基础包&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;又一个坑，不要使用t2strap那种方式，我最开始使用这种方式，结果/mnt/etc/pacman.conf直接被覆盖了，arch-chroot后，连个vim都装不上。&lt;/p&gt;

&lt;p&gt;这里也要安装上python，文档里并没有说，后面运行firmware.sh时会用到python。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pacstrap /mnt base linux-t2 apple-t2-audio-config apple-bcm-firmware linux-firmware iwd grub efibootmgr vim python
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;增加软件源&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim /mnt/etc/pacman.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Redecorating-t2]
Server = https://github.com/Redecorating/archlinux-t2-packages/releases/download/packages

[arch-mact2]
Server = https://mirror.funami.tech/arch-mact2/os/x86_64
SigLevel = Never
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;生成文件系统挂载信息&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;genfstab &lt;span class=&quot;nt&quot;&gt;-U&lt;/span&gt; /mnt &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; /mnt/etc/fstab
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;切换到安装的系统&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;相当于后面的操作都是针对于挂载到/mnt的系统。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;arch-chroot /mnt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置时区&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-sf&lt;/span&gt; /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock &lt;span class=&quot;nt&quot;&gt;--systohc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置文本编码格式&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim /etc/locale.gen
&lt;span class=&quot;c&quot;&gt;# 取消注释en_US.UTF-8 UTF-8&lt;/span&gt;
locale-gen
vim /etc/locale.conf
&lt;span class=&quot;c&quot;&gt;# 增加一行LANG=en_US.UTF-8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置主机名&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim /etc/hosts
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;127.0.0.1 localhost
::1 localhost
127.0.1.1 mbp.localdomain mbp
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;生成initial RAM disk&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 增加apple-bce到MODULES里&lt;/span&gt;
vim /etc/mkinitcpio.conf
mkinitcpio &lt;span class=&quot;nt&quot;&gt;-P&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;安装启动器&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# GRUB_CMDLINE_LINUX里增加intel_iommu=on iommu=pt pcie_ports=compat&lt;/span&gt;
vim /etc/default/grub
&lt;span class=&quot;c&quot;&gt;# 苹果的EFI boot loader会去读取/EFI/BOOT/BOOTX64.EFI，这里就把GRUB写到那里&lt;/span&gt;
grub-install &lt;span class=&quot;nt&quot;&gt;--target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;x86_64-efi &lt;span class=&quot;nt&quot;&gt;--efi-directory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/boot/efi &lt;span class=&quot;nt&quot;&gt;--bootloader-id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;GRUB &lt;span class=&quot;nt&quot;&gt;--removable&lt;/span&gt;
grub-mkconfig &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; /boot/grub/grub.cfg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置root密码&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;passwd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;返回到U盘系统&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;重启&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;reboot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置有线网络&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim /etc/systemd/network/20-wired.network
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Match]
Name=en*

[Network]
DHCP=yes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;systemd-networkd
systemctl start systemd-networkd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 增加一行nameserver 192.168.1.1&lt;/span&gt;
vim /etc/resolv.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;使用Wi-Fi和蓝牙的固件&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;umount /dev/nvme0n1p1
&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; /tmp/apple-wifi-efi
mount /dev/nvme0n1p1 /tmp/apple-wifi-efi
bash /tmp/apple-wifi-efi/firmware.sh
&lt;span class=&quot;c&quot;&gt;# 检查日志&lt;/span&gt;
journalctl &lt;span class=&quot;nt&quot;&gt;-k&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--grep&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;brcmfmac
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置无线网络&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pacman &lt;span class=&quot;nt&quot;&gt;-S&lt;/span&gt; networkmanager iw wpa_supplicant
systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;NetworkManager
systemctl start NetworkManager
&lt;span class=&quot;c&quot;&gt;# 选择Wi-Fi，输入密码&lt;/span&gt;
nmtui
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;查看电池状态&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pacman &lt;span class=&quot;nt&quot;&gt;-S&lt;/span&gt; acpi
acpi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;运行效果&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/mbp18-archlinux.jpeg&quot; alt=&quot;MBP18-ArchLinux&quot; /&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">我有一台闲置的MacBook Pro 2018，一直都不知道拿来做什么，放在抽屉里，有一天拿来用居然开不了机了，去苹果店检查是主板坏了，苹果的做法是只换不修，换主板需要5K多，修好再卖个二手都不一定能赚钱。后面在淘宝上找到一家华强北的店可以修苹果电脑，最近去把它修好了，只花了几百块，问了下这台MBP能卖多少钱，说只能卖3K左右，真不想这样贱卖了。</summary></entry><entry><title type="html">How to copy file without cp command</title><link href="https://pass86.github.io/2022/01/03/how-to-copy-file-without-cp-command.html" rel="alternate" type="text/html" title="How to copy file without cp command" /><published>2022-01-03T00:00:00+00:00</published><updated>2022-01-03T00:00:00+00:00</updated><id>https://pass86.github.io/2022/01/03/how-to-copy-file-without-cp-command</id><content type="html" xml:base="https://pass86.github.io/2022/01/03/how-to-copy-file-without-cp-command.html">&lt;p&gt;前一阵子偶然翻出了我9年前的Android Pad，顺便拿来玩了一下，这个系统是Android 4.1.2的版本，我用adb shell可以连接进去，当时想在里面拷贝一个文件，执行了cp命令时才发现没有这个命令，这太让我意外了，该怎么办呢？&lt;/p&gt;

&lt;p&gt;我用下面这条命令成功完成了cp的功能，觉得挺有意思的，所以记录一下。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;foo.dat &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; bar.dat
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">前一阵子偶然翻出了我9年前的Android Pad，顺便拿来玩了一下，这个系统是Android 4.1.2的版本，我用adb shell可以连接进去，当时想在里面拷贝一个文件，执行了cp命令时才发现没有这个命令，这太让我意外了，该怎么办呢？ 我用下面这条命令成功完成了cp的功能，觉得挺有意思的，所以记录一下。 cat foo.dat &amp;gt; bar.dat</summary></entry><entry><title type="html">Backup System Disk to NAS</title><link href="https://pass86.github.io/2021/06/06/backup-system-disk-to-nas.html" rel="alternate" type="text/html" title="Backup System Disk to NAS" /><published>2021-06-06T00:00:00+00:00</published><updated>2021-06-06T00:00:00+00:00</updated><id>https://pass86.github.io/2021/06/06/backup-system-disk-to-nas</id><content type="html" xml:base="https://pass86.github.io/2021/06/06/backup-system-disk-to-nas.html">&lt;p&gt;又入手了一个NUC，这次买的是我本来最想买的NUC11PAHi5。上次那个NUC定位为一个稳定的Linux开发环境，这次的NUC定位是一个不稳定的体验测试环境，比如说玩下破解游戏，破解就意味着很大可能带有后门或者病毒。在我主力系统上我是不会安装破解软件的。&lt;/p&gt;

&lt;p&gt;我把上个NUC的一条16GB内存拆到这台NUC上，老电脑的256GB的SATA SSD安装到NUC上，就可以安装系统了。&lt;/p&gt;

&lt;p&gt;安装系统，驱动，设置账号等，这些操作每次重装系统都会浪费不少时间，而这台NUC重装系统的可能性是比较大，说不定哪天就拿来玩下Arch Linux桌面系统。所以我有了备份整个系统的需求。&lt;/p&gt;

&lt;p&gt;最开始想到的是大学时代非常流行的Ghost工具，可以全盘备份，那时还是XP时代。能不能备份Linux系统我没试过，我希望的是一个通用的备份方案，不受限于安装的什么系统。&lt;/p&gt;

&lt;p&gt;想了下这个过程，插上一个U盘，启动引导到U盘上系统，然后可以访问NAS的共享文件夹，把硬盘压缩备份到NAS的共享文件夹下。&lt;/p&gt;

&lt;p&gt;这个用Arch Linux的安装U盘，进入shell然后mount到NAS的共享文件夹，再通过dd拷贝不就可以实现了吗。果然搜索到了Arch Linux的Wiki，已经有比较详细的教程了，所以我采取了这种方案。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mount NAS Backup&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; /mnt/backup
mount &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; cifs //192.168.1.100/backup /mnt/backup &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;foo
&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; /mnt/backup
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Install pigz&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;为了利用多核，需要安装pigz(Parallel implementation of the gzip file compressor)&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pacman &lt;span class=&quot;nt&quot;&gt;-Sy&lt;/span&gt; pigz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Create Disk Image&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fdisk &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;dd &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/sda &lt;span class=&quot;nv&quot;&gt;bs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;256K &lt;span class=&quot;nv&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;progress | pigz &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /mnt/backup/disk.img.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Restore System&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fdisk &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt;
unpigz &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; /mnt/backup/disk.img.gz | &lt;span class=&quot;nb&quot;&gt;dd &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/sda &lt;span class=&quot;nv&quot;&gt;bs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;256K &lt;span class=&quot;nv&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;progress
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Stats&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;35.3 GB used, 256 GB copied, 13.38 GB saved&lt;/p&gt;

&lt;p&gt;使用dd是不会关心硬盘到底使用了多少空间的，它是整个硬盘拷贝，所以硬盘容量越大，花的时间越多，现在我倒庆幸这个老硬盘只有256GB，因为经过了压缩，所以最终的镜像会比你使用的空间小，比如我用了35.3GB，实际镜像只有13.38GB。&lt;/p&gt;

&lt;p&gt;我尝试了直接使用gzip，不利用多核要慢很多。dd的bs选项也非常影响速度，默认的512非常慢，256K对这个环境来说个不错的选择。&lt;/p&gt;

&lt;p&gt;备份&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;single core bs=64K  124 MB/s    34:27   12.71 GB
multi core  bs=256K 405 MB/s    10:35   13.38 GB
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;还原&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;single core bs=256  43.8 MB/s   1:37:25 12.71 GB
single core bs=256K 271 MB/s    15:46   12.71 GB
multi core  bs=256K 370 MB/s    11:32   13.38 GB
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">又入手了一个NUC，这次买的是我本来最想买的NUC11PAHi5。上次那个NUC定位为一个稳定的Linux开发环境，这次的NUC定位是一个不稳定的体验测试环境，比如说玩下破解游戏，破解就意味着很大可能带有后门或者病毒。在我主力系统上我是不会安装破解软件的。</summary></entry><entry><title type="html">Install Arch Linux on Intel NUC</title><link href="https://pass86.github.io/2021/03/13/install-arch-linux-on-intel-nuc.html" rel="alternate" type="text/html" title="Install Arch Linux on Intel NUC" /><published>2021-03-13T00:00:00+00:00</published><updated>2021-03-13T00:00:00+00:00</updated><id>https://pass86.github.io/2021/03/13/install-arch-linux-on-intel-nuc</id><content type="html" xml:base="https://pass86.github.io/2021/03/13/install-arch-linux-on-intel-nuc.html">&lt;p&gt;Arch Linux是我喜欢的一个Linux发行版本，喜欢它的滚动发行方式和最新的软件版本。在此之前我用过CentOS、Fedora和Ubuntu，CentOS基本上是用不上最新版本的软件，经常得自己下载源码编译，如果想使用Linux桌面系统的的话，Fedora和Ubuntu还是不错的选择。&lt;/p&gt;

&lt;p&gt;安装Arch Linux是全命令行操作，要想安装成功将经历一次历险，同时也能学到Linux的一些知识，能对系统进行非常精细化的定制，这一点让我很爽，系统的安装内容全是我真正想要的东西，每个启动进程我都能理解它负责的功能是什么。&lt;/p&gt;

&lt;p&gt;之前我是在Thinkpad上安装了Arch Linux，有段时间我还常在上面写C++代码，折腾过Arch Linux的桌面，那机器配置已经过时，型号是T450，i5双核四线程，8GB内存，目前我对装Linux系统机器的定位是一个24小时开机的Server，如果拿笔记本来担当，它的键盘和屏幕实在是有点浪费，安放位置也比较尴尬，有电源又得有网线，要打开屏幕才能触摸到电源按钮，反正就不像一个稳稳的待在那里的一个服务器。&lt;/p&gt;

&lt;p&gt;所以我有再组装一台PC的想法，最后了解到了Intel NUC，简直就是完美满足我的需求，功耗低，体积小，可自定义RAM和SSD。刚好NUC 11最近发布，我非常想买的是NUC11PAHi5，但是等了两个周，能买到i5只有NUC11PAKi5，i7有考虑过，但是价格多1400块，看了下YouTube上性能评测，实在觉得不值。最终我用直接一步到位1T SSD说服了自己不用再考虑扩展存储了。发现内存涨价好多啊，买得我肉疼。&lt;/p&gt;

&lt;p&gt;配置是这样的: NUC11PAKi5(i5-1135G7, 4核8线程, 8MB缓存, 2.4GHz-4.2GHz)，Kingston RAM(16GB, DDR4, 3200MHz) x 2，西部数据SSD(1TB, NVMe)。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/nuc-11-pak-i5.jpeg&quot; alt=&quot;NUC11PAKi5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Arch Linux虽然我之前安装过几次，但是这次安装并不顺利，因为之前分区都是用的BIOS with MBR的方式，在这个NUC上执行时grub-install时会报错，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;error &quot;cannot find EFI directory&quot;&lt;/code&gt;，于是我又得重来尝试UEFI with GPT的分区，期间又遇到了之前没有遇到过的问题，所以在此记录下详细的安装过程备忘。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;制作安装U盘&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;官网下载ISO后，推荐使用Rufus这个工具写入U盘，之前用过macOS的dd，很慢。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;BIOS禁用Secure Boot&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;启动时按F2可进入BIOS。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;从U盘启动&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;插入安装U盘，启动时按F10选择该U盘为启动设备。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;同步网络时间&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;确保连接网线并接入互联网。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ping archlinux.org
timedatectl set-ntp &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;查看硬盘情况&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fdisk &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;SATA硬盘会显示/dev/sda，NVMe硬盘会显示/dev/nvme0n1。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;创建EFI分区&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fdisk /dev/nvme0n1
g &lt;span class=&quot;c&quot;&gt;# create a new empty GPT partition table&lt;/span&gt;
n &lt;span class=&quot;c&quot;&gt;# add a new partition&lt;/span&gt;
&amp;lt;enter&amp;gt; &lt;span class=&quot;c&quot;&gt;# Partition number&lt;/span&gt;
&amp;lt;enter&amp;gt;  &lt;span class=&quot;c&quot;&gt;# First sector&lt;/span&gt;
+512M  &lt;span class=&quot;c&quot;&gt;# Last sector&lt;/span&gt;
t &lt;span class=&quot;c&quot;&gt;# change a partition type&lt;/span&gt;
1 &lt;span class=&quot;c&quot;&gt;# EFI System&lt;/span&gt;
p &lt;span class=&quot;c&quot;&gt;# print the partition table&lt;/span&gt;
w &lt;span class=&quot;c&quot;&gt;# write table to disk and exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;创建根分区&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fdisk /dev/nvme0n1
n &lt;span class=&quot;c&quot;&gt;# add a new partition&lt;/span&gt;
&amp;lt;enter&amp;gt; &lt;span class=&quot;c&quot;&gt;# Partition number&lt;/span&gt;
&amp;lt;enter&amp;gt; &lt;span class=&quot;c&quot;&gt;# First sector&lt;/span&gt;
&amp;lt;enter&amp;gt; &lt;span class=&quot;c&quot;&gt;# Last sector&lt;/span&gt;
p &lt;span class=&quot;c&quot;&gt;# print the partition table&lt;/span&gt;
w &lt;span class=&quot;c&quot;&gt;# write table to disk and exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;创建文件系统&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;我之前有尝试过Btrfs，但是最后那套系统启动不了，跟Btrfs有关，所以这次我选择了默认的ext4。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkfs.fat &lt;span class=&quot;nt&quot;&gt;-F32&lt;/span&gt; /dev/nvme0n1p1
mkfs.ext4 /dev/nvme0n1p2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;挂载文件系统&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mount /dev/nvme0n1p2 /mnt
&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /mnt/boot/efi
mount /dev/nvme0n1p1 /mnt/boot/efi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;调整镜像列表&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;把中国的镜像地址剪切到文件头部，提高下载速度。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim /etc/pacman.d/mirrorlist
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;安装基础包&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pacstrap /mnt base linux linux-firmware base-devel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;生成文件系统挂载信息&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;genfstab &lt;span class=&quot;nt&quot;&gt;-U&lt;/span&gt; /mnt &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; /mnt/etc/fstab
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;切换到安装的系统&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;相当于后面的操作都是针对于挂载到/mnt的系统。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;arch-chroot /mnt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置时区&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-sf&lt;/span&gt; /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock &lt;span class=&quot;nt&quot;&gt;--systohc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;安装Vim&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;后面需用Vim进行配置文件的编辑。&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pacman &lt;span class=&quot;nt&quot;&gt;-S&lt;/span&gt; vim
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置文本编码格式&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim /etc/locale.gen
&lt;span class=&quot;c&quot;&gt;# 取消注释en_US.UTF-8 UTF-8&lt;/span&gt;
locale-gen
vim /etc/locale.conf
&lt;span class=&quot;c&quot;&gt;# 增加一行LANG=en_US.UTF-8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置主机名&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim /etc/hosts
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;127.0.0.1 localhost
::1 localhost
127.0.1.1 HOME-SERVER.localdomain HOME-SERVER
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;安装启动器&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pacman &lt;span class=&quot;nt&quot;&gt;-S&lt;/span&gt; grub efibootmgr intel-ucode
grub-install /dev/nvme0n1p1
grub-mkconfig &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; /boot/grub/grub.cfg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置root密码&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;passwd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;返回到U盘系统&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;重启&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;reboot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;添加管理员&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim /etc/sudoers
&lt;span class=&quot;c&quot;&gt;# 取消注释%wheel ALL=(ALL) ALL&lt;/span&gt;
useradd &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-G&lt;/span&gt; wheel user00
passwd user00
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置网络&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;vim /etc/systemd/network/20-wired.network
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Match]
Name=en*

[Network]
DHCP=yes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;systemd-networkd
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl start systemd-networkd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim /etc/resolv.conf
&lt;span class=&quot;c&quot;&gt;# 增加一行nameserver 192.168.2.1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;启用SSH登录&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;pacman &lt;span class=&quot;nt&quot;&gt;-S&lt;/span&gt; openssh
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;vim /etc/ssh/sshd_config
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Port 56666
StrictModes no
RSAAuthentication yes
PubkeyAuthentication yes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;sshd
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl start sshd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; ~/.ssh
vim ~/.ssh/authorized_keys
&lt;span class=&quot;c&quot;&gt;# 增加远端系统里ssh-keygen生成的id_rsa.pub里的内容&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;更新系统&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;pacman &lt;span class=&quot;nt&quot;&gt;-Syu&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;关机&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;poweroff
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">Arch Linux是我喜欢的一个Linux发行版本，喜欢它的滚动发行方式和最新的软件版本。在此之前我用过CentOS、Fedora和Ubuntu，CentOS基本上是用不上最新版本的软件，经常得自己下载源码编译，如果想使用Linux桌面系统的的话，Fedora和Ubuntu还是不错的选择。</summary></entry><entry><title type="html">Fix xcodebuild archive Provisioning profile error on Apple M1</title><link href="https://pass86.github.io/2021/02/01/fix-xcodebuild-archive-provisioning-profile-error-on-apple-m1.html" rel="alternate" type="text/html" title="Fix xcodebuild archive Provisioning profile error on Apple M1" /><published>2021-02-01T00:00:00+00:00</published><updated>2021-02-01T00:00:00+00:00</updated><id>https://pass86.github.io/2021/02/01/fix-xcodebuild-archive-provisioning-profile-error-on-apple-m1</id><content type="html" xml:base="https://pass86.github.io/2021/02/01/fix-xcodebuild-archive-provisioning-profile-error-on-apple-m1.html">&lt;p&gt;最近入手了Mac mini M1(16GB RAM, 256GB SSD)，买它的主要目的就是用来运行GitHub Actions的self-hosted runner。&lt;/p&gt;

&lt;p&gt;然而在把之前的iOS项目在Mac mini上用命令行构建时遇到了这个错误: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;error: Provisioning profile &quot;iOS Team Provisioning Profile: *&quot; doesn't include the currently selected device &quot;Mac mini&quot; (identifier ...&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;之前我是用的x86 MBP来做self-hosted runner，没有出现过这个问题。我之前买过Apple Developer的Membership，但是后面没有续订已经过期了，因为发现直接用免费的Automatically manage signing也能满足我的需求。Membership过期后Apple Developer网站上证书相关操作页面都没有入口，为了把Mac mini的identifier加上去，我又续订了。&lt;/p&gt;

&lt;p&gt;在Apple Developer的Devices页面增加了报错信息里的identifier后，我命令行构建iOS App可以成功。&lt;/p&gt;

&lt;p&gt;然而在我配置好GitHub Actions后，通过GitHub Actions runner运行构建脚本时，却遇到同样的错误，仔细一看identifier和我配置的不一样。一阵Google后发现我之前我配置的是Provisioning UDID，现在报错信息里是Hardware UUID，这两个ID可以在System Information里看到，在我x86 MBP上这两个值是一样的，在Mac mini M1上这两个值是不一样的。&lt;/p&gt;

&lt;p&gt;我把Hardware UUID加到Devices里，再更新Provisioning Profiles(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/Library/MobileDevice/Provisioning Profiles&lt;/code&gt;)，验证Hardware UUID是没有加入到&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PROVISIONED DEVICES&lt;/code&gt;的。&lt;/p&gt;

&lt;p&gt;通过不断的Google，终于找到一个和我一样的案例，而且作者自己给出了解决方法，在xcodebuild参数里增加&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-destination 'generic/platform=iOS'&lt;/code&gt;就可以了。&lt;/p&gt;

&lt;p&gt;所以其实不用买Membership也是可以解决问题，我知道在x86 Mac上是不用在Devices里加UDID，但鉴于M1是ARM架构可以运行iOS的App的，我以为这是个新的机制要求。这都是些黑盒的东西，xcodebuild的文档对&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-destination&lt;/code&gt;也没有更详细的说明，而且通过GitHub Actions运行报错的又是Hardware UUID。&lt;/p&gt;

&lt;p&gt;推测在不加&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-destination&lt;/code&gt;参数时，xcodebuild默认会寻找一个当前支持的设备，iOS App在x86 Mac下是不支持的，所以没有设置当前设备，而在M1 Mac下则支持有了选择。&lt;/p&gt;

&lt;p&gt;然而为什么Github Actions调用时取到的是Hardware UUID，这个就难以理解了。&lt;/p&gt;

&lt;p&gt;总之，我目前能Make it work就达到我的目的了。&lt;/p&gt;</content><author><name></name></author><summary type="html">最近入手了Mac mini M1(16GB RAM, 256GB SSD)，买它的主要目的就是用来运行GitHub Actions的self-hosted runner。</summary></entry><entry><title type="html">Build AOSP for Pixel 2</title><link href="https://pass86.github.io/2021/01/09/build-aosp-for-pixel2.html" rel="alternate" type="text/html" title="Build AOSP for Pixel 2" /><published>2021-01-09T00:00:00+00:00</published><updated>2021-01-09T00:00:00+00:00</updated><id>https://pass86.github.io/2021/01/09/build-aosp-for-pixel2</id><content type="html" xml:base="https://pass86.github.io/2021/01/09/build-aosp-for-pixel2.html">&lt;p&gt;我是从2019年底才开始接触AOSP(Android Open Source Project)的，因为当时在研究Android内存这块，了解到Android 10推出的Perfetto框架，能从系统底层记录堆内存的分配情况，听起来太酷了。但是实际使用过程中发现它的一个严重bug，比如记录王者荣耀的堆内存分配，heapprofd会在王者荣耀启动后没多久就退出，我改Perfetto的代码修了这个bug，quick and dirty，于是我就有构建AOSP的需求。同时也和Google工程师沟通，他在master修复了这个bug，当然这个过程是漫长的。&lt;/p&gt;

&lt;p&gt;从Android 9开始AOSP默认只支持Pixel系列，所以买了一台测试手机Pixel 2，花了不到1000块，性价比还是挺高的。&lt;/p&gt;

&lt;p&gt;当时我是在macOS下构建的AOSP，因为AOSP需要文件系统区分大小写，所以在macOS的下要么买一个新的SSD格式化为区分大小写的，要么创建一个区分大小写的disk image。用iMac(i7-6700K, 16GB RAM, 512GB SSD)构建花了3个多小时，用MBP(i7-7920HQ, 16GB RAM, 250GB disk image)花了6个多小时。&lt;/p&gt;

&lt;p&gt;最近我又准备构建AOSP，在macOS下却遇到了一些莫名其妙的错误，Google许久没解决掉，加上我新组装了一台PC，想利用它的高配置，构建更快点，我尝试了在Windows 10上利用WSL构建AOSP，也是遇到各种错误。我反思了一下，为什么不用官方推荐的Ubuntu呢，浪费时间在这些莫名其妙的错误上，不太值。于是专门购买一块SSD来安装Ubuntu，官方推荐的是18.04，我安装了20.04，还好也可以构建成功。在PC(i7-10700K, 32GB RAM, 1TB SSD)上花了1小时10分钟，Nice。&lt;/p&gt;

&lt;p&gt;下面列出在Ubuntu上构建AOSP各个步骤，最简化的流程。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;安装依赖包&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;官方列出&lt;/p&gt;

&lt;p&gt;sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig&lt;/p&gt;

&lt;p&gt;实践解决error while loading shared libraries: libncurses.so.5&lt;/p&gt;

&lt;p&gt;sudo apt-get install libncurses5&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;下载代码管理工具repo&lt;/code&gt;，这是一个python脚本，如果你的默认python不是python3的话，需要打开文件把第一行的python改成python3&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;mkdir -p ~/bin&lt;/p&gt;

&lt;p&gt;curl https://storage.googleapis.com/git-repo-downloads/repo &amp;gt; ~/bin/repo&lt;/p&gt;

&lt;p&gt;chmod a+x ~/bin/repo&lt;/p&gt;

&lt;p&gt;vim .bashrc&lt;/p&gt;

&lt;p&gt;export PATH=~/bin:$PATH&lt;/p&gt;

&lt;p&gt;在中国大陆需要设置http_proxy和https_proxy，原因应该都懂的，AOSP推荐用bash，设置好环境变量后，需要重开一个bash&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;创建代码目录&lt;/code&gt;，可用空间官方推荐需要250GB，下载后代码库70GB左右，构建完成后占用170GB左右&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;mkdir ~/aosp&lt;/p&gt;

&lt;p&gt;cd ~/aosp&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置代码URL和版本&lt;/code&gt;，版本可以在这里找到，&lt;a href=&quot;https://source.android.com/setup/start/build-numbers&quot;&gt;https://source.android.com/setup/start/build-numbers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;repo init -u https://android.googlesource.com/platform/manifest -b android-10.0.0_r41&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;下载代码&lt;/code&gt;，5M的出口带宽，峰值500KB/s左右，我下了一天&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;repo sync&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;下载设备驱动&lt;/code&gt;，&lt;a href=&quot;https://developers.google.com/android/drivers&quot;&gt;https://developers.google.com/android/drivers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pixel 2的代号是walleye，下载解压后会得到extract-google_devices-walleye.sh和extract-qcom-walleye.sh，移动到AOSP的代码目录，分别执行两个sh脚本&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;设置构建参数&lt;/code&gt;，userdebug版本可以拥有root权限，这当然是我想要的&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;source build/envsetup.sh&lt;/p&gt;

&lt;p&gt;lunch aosp_walleye-userdebug&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;启动构建&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;m&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;刷机&lt;/code&gt;，在Pixel 2设置里开启USB debugging和OEM unlocking，Pixel 2通过USB连接到PC&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;adb reboot bootloader&lt;/p&gt;

&lt;p&gt;fastboot flashall -w&lt;/p&gt;

&lt;p&gt;如果想清除构建的内容的话，可以执行make clobber。&lt;/p&gt;

&lt;p&gt;虽然我是Apple的粉丝，但是能使用从源码构建出的系统，感觉是一件很酷的事情，拥有root权限也能更方便的去调试App，这台Pixel 2成为了我的Playground。&lt;/p&gt;</content><author><name></name></author><summary type="html">我是从2019年底才开始接触AOSP(Android Open Source Project)的，因为当时在研究Android内存这块，了解到Android 10推出的Perfetto框架，能从系统底层记录堆内存的分配情况，听起来太酷了。但是实际使用过程中发现它的一个严重bug，比如记录王者荣耀的堆内存分配，heapprofd会在王者荣耀启动后没多久就退出，我改Perfetto的代码修了这个bug，quick and dirty，于是我就有构建AOSP的需求。同时也和Google工程师沟通，他在master修复了这个bug，当然这个过程是漫长的。</summary></entry><entry><title type="html">Fix exportArchive: No signing certificate “Mac App Distribution” found</title><link href="https://pass86.github.io/2020/12/27/fix-export-archive-no-signing-certificate-mac-app-distribution-found.html" rel="alternate" type="text/html" title="Fix exportArchive: No signing certificate “Mac App Distribution” found" /><published>2020-12-27T00:00:00+00:00</published><updated>2020-12-27T00:00:00+00:00</updated><id>https://pass86.github.io/2020/12/27/fix-export-archive-no-signing-certificate-mac-app-distribution-found</id><content type="html" xml:base="https://pass86.github.io/2020/12/27/fix-export-archive-no-signing-certificate-mac-app-distribution-found.html">&lt;p&gt;这个错误提示出现在Unity项目整合平台SDK后使用xcodebuild -exportArchive时。明明是导出的iOS平台工程，为什么会出现Mac App的关键字呢?而iOS的发布证书是有正确配置的，之前是可以正常工作的。这让我非常疑惑，甚至周末都来解决这个问题，但是经过多次的Google查找是否有类似问题，但是没有遇到iOS工程输出这种错误的。所以周末我并没有解决问题。&lt;/p&gt;

&lt;p&gt;周一和平台相关的同事沟通后，发现有此类案例，原因是Copy Bundle Reources里有拷贝Static Library。我在Unity导出的Xcode工程里手动删除了相关的项，再次执行之前的导出脚本，成功了!&lt;/p&gt;

&lt;p&gt;那为什么会有这些Static Library在Xcode工程的Copy Bundle Reources里呢？链接这些库使用的是XUPorter插件，经过Review后发现代码里有两份XUPorter，一份是之前加入的，另一份是新加入SDK里的，被加入了额外的namespace所以没有编译错误。&lt;/p&gt;

&lt;p&gt;而之前的XUPorter会在OnPostProcessBuild里查找Assets目录下所有.projmods文件加入XCProject使用。问题就出在这里，新加入的SDK里也有很多.projmods文件，所以被误加入了XCProject，导致生成出来的Xcode工程不符合预期，然后Xcode导出的行为也就不符合预期。&lt;/p&gt;

&lt;p&gt;解决方法就是把之前的XUPorter搜索.projmods的目录限定到更明确的Mods目录。跑整个构建流程，没有问题了。&lt;/p&gt;

&lt;p&gt;我觉得这个问题非常的罕见，而且错误提示也非常离谱，和问题的源头离得很远，也浪费了我的周末时间，所以我希望记录下来帮助到再次遇到此类问题的程序员，通过Google搜索快速解决此类问题。&lt;/p&gt;</content><author><name></name></author><summary type="html">这个错误提示出现在Unity项目整合平台SDK后使用xcodebuild -exportArchive时。明明是导出的iOS平台工程，为什么会出现Mac App的关键字呢?而iOS的发布证书是有正确配置的，之前是可以正常工作的。这让我非常疑惑，甚至周末都来解决这个问题，但是经过多次的Google查找是否有类似问题，但是没有遇到iOS工程输出这种错误的。所以周末我并没有解决问题。</summary></entry><entry><title type="html">Unity Async Load Internal</title><link href="https://pass86.github.io/2020/11/08/unity-async-load-internal.html" rel="alternate" type="text/html" title="Unity Async Load Internal" /><published>2020-11-08T00:00:00+00:00</published><updated>2020-11-08T00:00:00+00:00</updated><id>https://pass86.github.io/2020/11/08/unity-async-load-internal</id><content type="html" xml:base="https://pass86.github.io/2020/11/08/unity-async-load-internal.html">&lt;p&gt;前段时间，在优化游戏的Loading时长，想利用多线程，把加载任务并发起来，减少整体的耗时。&lt;/p&gt;

&lt;p&gt;这个项目使用的是Unity2019，手机上资源使用AssetBunndle加载，优化前整个加载都是用的同步接口，同步加载AB，同步加载AB里Assets。&lt;/p&gt;

&lt;p&gt;当我改成异步接口加载Assets时，测试结果居然比使用同步接口还是长，而且长了好几秒。这个结果让我很诧异，异步接口不是多线程的吗，总时间该减少才对啊。&lt;/p&gt;

&lt;p&gt;于是进行了Profiler，查看CPU Usage，在Loading的后面一段主线程消耗非常的平稳，能看到很多帧的UpdatePreloading的消耗。而加载线程很早就跑完了任务。&lt;/p&gt;

&lt;p&gt;充满了疑惑，还好之前申请源码权限，去分析了源码。&lt;/p&gt;

&lt;p&gt;原来异步加载有一部分工作在主线程完成，而这一部分工作，优先级是kBelowNormalPriority，Unity每帧只分配了4ms的时间片，这样做应该是为了保证帧率吧，所以花了很多帧才把全部异步加载的工作完成。&lt;/p&gt;

&lt;p&gt;有个例外是如果此时调用了同步加载场景的接口LoadScene，主线程会把所有异步加载已在主线程排队的任务全部完成。利用这个逻辑，可以先进行资源异步加载，再进行场景同步加载，就不用走主线程时间分片了。这样做后，测试结果还是慢，因为不是所有加载任务都在LoadScene之前就排队到主线程了，取决于加载线程的执行速度。&lt;/p&gt;

&lt;p&gt;所以从这里得出的结论是，使用异步接口并不能减少Loading时长，反而会更久，异步接口主要保证主线程帧率不受影响，所以更适合在游戏过程中进行异步加载。&lt;/p&gt;</content><author><name></name></author><summary type="html">前段时间，在优化游戏的Loading时长，想利用多线程，把加载任务并发起来，减少整体的耗时。</summary></entry><entry><title type="html">Home Network Set Up</title><link href="https://pass86.github.io/2020/09/30/home-network-set-up.html" rel="alternate" type="text/html" title="Home Network Set Up" /><published>2020-09-30T00:00:00+00:00</published><updated>2020-09-30T00:00:00+00:00</updated><id>https://pass86.github.io/2020/09/30/home-network-set-up</id><content type="html" xml:base="https://pass86.github.io/2020/09/30/home-network-set-up.html">&lt;p&gt;重新装修房子时，弱电箱拉了网线到卧室、电视墙。虽然大部分时间都是在用WiFi，但是高速传输还是得靠有线网络，所以留下扩展的可能性。&lt;/p&gt;

&lt;p&gt;不过这次没想周全，每个接入点只拉了一根网线，实际使用时发现每个接入点有两根网线是比较灵活的，可以一根来一根回。&lt;/p&gt;

&lt;p&gt;比如说你想把路由器放在电视柜的话，就得一根来的接入互联网，一根回的到弱电箱的交换机分发到各个房间。所以目前我的路由器只能在弱电箱附近。&lt;/p&gt;

&lt;p&gt;如果是全屋地毯的话，把网线埋在地毯下面应该也是个很灵活的解决方法。&lt;/p&gt;

&lt;p&gt;以下就是我目前在家里的网络拓扑图。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/home-network.png&quot; alt=&quot;Home Network&quot; /&gt;&lt;/p&gt;

&lt;p&gt;许多路由器的默认IP都是192.168.1.1，在多路由时会冲突，这里需要设置下。电信网关使用192.168.1.1，Linksys WRT1900ACS使用192.168.2.1，Linksys WRT32X使用192.168.3.1。&lt;/p&gt;

&lt;p&gt;我个人使用的网络在Linksys WRT32X后面有两个好处，一是我重启路由不会影响其他人，二是我是可以连接到Linksys WRT32X的管理页面的，不用切换网络。&lt;/p&gt;

&lt;p&gt;接下来说说路由器，之前用过塑料壳、铁壳的TP-Link，使用体验没啥差别。不知什么时候了解到OpenWrt，能自己安装路由器的系统，而且还是开源的，这点就让我感到兴奋。比较各个兼容硬件后，发现Linksys的WRT系列兼容性是比较好的。于是我就之前就买了一台Linksys WRT1900ACS，刷了OpenWrt。&lt;/p&gt;

&lt;p&gt;折腾OpenWrt系统时，常重启路由器，导致网络不稳定，被女朋友吐槽网络好差。这次为了让我折腾OpenWrt时，不影响到其他人，我另外购置一台路由器作为家里的主路由，Linksys WRT32X，使用原装的系统。&lt;/p&gt;

&lt;p&gt;再来聊聊NAS，最开始我不知道有NAS这个东西，只是有低功耗下载的需求，当时去华强北的赛格买了个准系统，不带风扇，装的Windows，硬盘忘了有多大，反正没有500G，远程桌面很卡，倒是能满足我当时的需求。&lt;/p&gt;

&lt;p&gt;自从进了PT圈后，小硬盘满足不了小水管了。有试过e-SATA的外接硬盘盒，感觉这个方案很临时。然后买了个4盘位的U-NAS，原装的系统用过一段时间后，爱折腾的我把它先后装了CentOS，Arch Linux，自定义Samba，Transmission等等，软件折腾后开始折腾硬件，拆机换了系统盘后，开始不稳定，时不时就死机了。期间两次丢了所以NAS硬盘上的数据，删库跑路这种事情在家里常干…&lt;/p&gt;

&lt;p&gt;经历了这么多折腾后发现也没啥好结果，于是我把目光转向了群辉，体验过他的DSM后，瞬间不想折腾了，于是这次买了群辉的DS718+，之前U-NAS的4盘位其实最多也就插了3个硬盘，4盘位还多个风扇，耗电和噪音都更多，所以这次选择2盘位。&lt;/p&gt;

&lt;p&gt;买之前很在意视频在NAS上硬解码，这样就可以在iPad上看动辄10G的1080p电影了，实际情况是，DS video因为版权问题不支持很多格式的内置字幕。&lt;/p&gt;

&lt;p&gt;NAS目前对我来主要有两个用处，一是挂PT存放高清电影🎬，二就是Time Machine备份我的MBP。&lt;/p&gt;

&lt;p&gt;其实我倒不是怕MBP正常使用的硬盘质量问题，我是怕MBP常背出去，万一哪天摔坏了、弄丢了、被偷了，没有Plan B的话，心里有点不安。总有些东西没有在iCloud或者GitHub上。比如各种环境搭建，软件安装，也是比较折腾的过程。&lt;/p&gt;

&lt;p&gt;使用Time Machine有点心得，如果用WiFi备份的话，速度很慢，经常一晚上都无法完成一次备份，所以在家都把MBP关闭WiFi，连接到Belkin Thunderbolt 3 Dock上，用有线网络，千兆网很快完成一次备份。&lt;/p&gt;

&lt;p&gt;如果你是个高清电影爱好者，喜欢自己下1080p或者4K的电影看，有大电视的话，Apple TV 4K绝对是最佳伴侣。&lt;/p&gt;

&lt;p&gt;在Apple TV 4K上使用Infuse播放NAS里的电影，整个体验非常舒服顺畅，Infuse能很好的呈现你的收藏，封面，简介，字幕。&lt;/p&gt;

&lt;p&gt;至于电视我选择了Sony A9G OLED，画面效果没有让我失望，看4K电影，有身临其境的感觉。&lt;/p&gt;

&lt;p&gt;使用OpenWrt的好处之一就是科学上网我可以在路由器上做，我的方案使用了：SSH tunnel、Squid、Proxy auto-config、Auto Proxy Discovery。&lt;/p&gt;

&lt;p&gt;Nintendo Switch直接设置网络代理到Squid（192.168.2.1:8080），浏览商店时顺畅多了，看介绍视频也能顺畅看完了😺。&lt;/p&gt;

&lt;p&gt;同样也可以设置PS4。可惜Apple TV 4K没有找到这样的设置。&lt;/p&gt;

&lt;p&gt;这些事情其实在去年年底就做完了，使用了快一年，目前处于稳定状态。&lt;/p&gt;</content><author><name></name></author><summary type="html">重新装修房子时，弱电箱拉了网线到卧室、电视墙。虽然大部分时间都是在用WiFi，但是高速传输还是得靠有线网络，所以留下扩展的可能性。</summary></entry><entry><title type="html">Restart Writing Blog</title><link href="https://pass86.github.io/2020/09/29/restart-writing-blog.html" rel="alternate" type="text/html" title="Restart Writing Blog" /><published>2020-09-29T00:00:00+00:00</published><updated>2020-09-29T00:00:00+00:00</updated><id>https://pass86.github.io/2020/09/29/restart-writing-blog</id><content type="html" xml:base="https://pass86.github.io/2020/09/29/restart-writing-blog.html">&lt;p&gt;记得大学和刚毕业几年的时候，还经常写博客，大部分是些笔记和心情随想，记录了我的成长过程，回头去看，满满的画面感。&lt;/p&gt;

&lt;p&gt;Blogger、CSDN博客、百度博客、QQ空间，主要用过这几个，对于程序员的我来说，总有些束缚感，有些不想要的东西无法去掉。&lt;/p&gt;

&lt;p&gt;自己架设服务器一是不想花钱，二是怕被黑了，三是感觉自己写的内容对别人来说也没太大价值。&lt;/p&gt;

&lt;p&gt;于是写博客这个事情就很少再做了。&lt;/p&gt;

&lt;p&gt;如今发现自己的记性严重下降，表述能力愈发降低，于是想通过写文章的方式对大脑锻炼，改善这方面的不足。&lt;/p&gt;

&lt;p&gt;对我来说，非常满意GitHub Pages这种模式和效果。&lt;/p&gt;

&lt;p&gt;那就让我重新开始博客之旅吧！👨‍💻&lt;/p&gt;</content><author><name></name></author><summary type="html">记得大学和刚毕业几年的时候，还经常写博客，大部分是些笔记和心情随想，记录了我的成长过程，回头去看，满满的画面感。</summary></entry></feed>