# ln -s these files to /private/tftpboot:# initrd.gz# vmlinux-4.16.0-6-loongson-2f$sudolaunchctlload-F/System/Library/LaunchDaemons/tftp.plist
# set addr manually to 192.168.2.1
$# for py2 virtualenv and running x86 prebuilt binaries(e.g. bison)$sudopacman-Sypython2-virtualenvlib32-gcc-libs$mkdir-p~/bin
$mkdir-p~/virtualenv
$# build script is written in python 2$cd~/virtualenv
$virtualenv2-p/usr/bin/python2py2
$mkdir-p~/android/lineage
$curlhttps://storage.googleapis.com/git-repo-downloads/repo>~/bin/repo
$chmoda+x~/bin/repo
$vim~/.config/fish/config.fish
set-xPATH~/bin$PATHset-xUSE_CCACHE=1$execfish-l
$cd~/android/lineage
$repoinit-uhttps://github.com/LineageOS/android.git-blineage-15.1
$# alternatively, follow https://mirrors.tuna.tsinghua.edu.cn/help/lineageOS/$reposync
$source~/virtualenv/py2/bin/activate
$sourcebuild/envsetup.sh
$breakfastangler
$vim~/.config/fish/config.fish
$ccache-M50G
$cd~/android/lineage/device/huawei/angler
$./extract-files.sh
# Plug in Nexus 6P, maybe over ssh, see my another post$cd~/android/lineage
$croot
$brunchangler
$# Endless waiting... (for me, more than 2 hrs)
$exportKERN=4.16.0-2# or use uname -r with awk, see Makefile$clang-O2-I/usr/src/linux-headers-${KERN}-common/include-I/usr/src/linux-headers-${KERN}-common/arch/x86/include-emit-llvm-cbpf.c-o-|llc-march=bpf-filetype=obj-obpf.o
$exportIFACE=en0$sudotcqdiscadddev${IFACE}clsact||true$sudotcfilterdeldev${IFACE}egress
$sudotcfilteradddev${IFACE}egressbpfobjbpf.osecout_daddr
$sudotcfilterdeldev${IFACE}ingress
$sudotcfilteradddev${IFACE}ingressbpfobjbpf.osecin_saddr
接下来,按照教程,先解锁 bootloader。连接手机,进入 USB Debugging Mode,重启进入 bootloader 并且解锁:
$adbrebootbootloader
$fastbootflashingunlock
# Confirm unlocking, and then the data should be wiped
接下来刷入 TWRP。还是进入 bootloader,然后刷入。
$ fastboot flash recovery twrp-3.2.1-0-angler.img
# Select recovery, and enter it
进入 TWRP 后,把我们刚刚下载的 zip 文件都 push 到手机上,并用 TWRP 安装:
# Select Wipe -> Advanced Wipe, Select Cache, System and Data and wipe then
# Install lineageos, opengapps, addonsu and follow on-screen instructions
# Reboot into system
为了测试一个硬件的 terminal,想在 Windows 上向串口开一个 tty,跑各种软件来测试。这件事情在 Linux 上和 macOS 上都有实践,但一直不知道 Windows 上怎么搞。经过了一番搜索,找到了 https://blogs.msdn.microsoft.com/wsl/2017/04/14/serial-support-on-the-windows-subsystem-for-linux/ 和 https://unix.stackexchange.com/a/123559 的方案。
一直听说 tinc 比较科学,所以尝试自己用 tinc 搭建一个网络。这里,macOS 这段没有固定 IP 地址,Linux 机器有固定 IP 地址 linux_ip。假设网络名称为 example , macOS 端名为 macos 地址为 192.168.0.2, linux 端名为 linux 地址为 192.168.0.1。
- (str) masquerade_address:
the "masqueraded" IP address to provide along PASV reply when
pyftpdlib is running behind a NAT or other types of gateways.
When configured pyftpdlib will hide its local address and
instead use the public address of your NAT (default None).
- (dict) masquerade_address_map:
in case the server has multiple IP addresses which are all
behind a NAT router, you may wish to specify individual
masquerade_addresses for each of them. The map expects a
dictionary containing private IP addresses as keys, and their
corresponding public (masquerade) addresses as values.
- (list) passive_ports:
what ports the ftpd will use for its passive data transfers.
Value expected is a list of integers (e.g. range(60000, 65535)).
When configured pyftpdlib will no longer use kernel-assigned
random ports (default None).
Server <---> NAT Router <---> My Laptop
On NAT Router, port 8022 is forwarded to Server:22
1. mosh router # works
2. mosh --ssh="ssh -p 8022" router # works
首先在 NAT Router 上配置 miniupnpd(以 Debian 为例)
sudoaptinstallminiupnpd
# you will get a dialog upon installation# input your wan interface and listening ip accordinglysudovim/etc/default/miniupnpd
# edit START_DAEMON=0 to START_DAEMON=1sudovim/etc/miniupnpd/miniupnpd.conf
# edit ext_ifname, listening_ip accordingly# set secure_mode=yes# add 'allow 60000-60023 internal_ip/prefix 60000-60023'# before the last line 'deny 0-65535 0.0.0.0/0 0-65535'sudosystemctlenable--nowminiupnpd
首先遇到的问题是,一启动之后就会花屏。我们一开始怀疑是 NVIDIA 驱动的问题,于是想改 kernel param 但是发现,这个 ISO 是 hybrid 的,我们在 macOS 和 Windows 上都不能 mount 上这种类型的盘。于是我们选择自己搞分区表。我们把 U 盘插到电脑上,然后在 Linux 虚拟机内重新分区为 GPT,然后 mount 到 /mnt/usb,再重新下载 archlinux iso,不过此时刚好上游更新了 archlinux-2018.05.01 的影响。我们把 ISO 中根分区 mount 到 /mnt/iso 上来,然后 cp -a /mnt/iso/* /mnt/usb 。调整了 grub 中的内核参数,仍然无果。我们认为问题可能在显卡上,就把那张显卡拔下来了,果然显示就正常了,但是新的问题就来了。
一启动,fstab 尝试把 LABEL=ARCHISO_201805 挂在上来,但是失败。于是我们把 U 盘插到 mac 上,用 Disk Utility 给分区命了名,再插回去,然后这个 Live CD 的 Systemd 就成功起来了。接下来就是根据官方的 Installation Guide 进行安装各种东西。安装完后,在 /boot/EFI 的操作上也出现了一些问题,一开始忘记调用 grub-mkconfig ,导致重启以后进入 grub-rescue,所以又回到 Live CD 重新 grub-mkconfig 。同时对 systemd-networkd 也进行了相应的调整,这样开机以后可以配好网络。主要就是在网卡上配上两个 VLAN 和相应的 DHCP 和静态地址。
接下来对以前的东西进行迁移。主要就是按照十分详细的 Arch Wiki 进行相应的配置。由于空间所限,我们把原来的 home 目录直接 mount --bind 到 /home,但是不可避免地,会出现用户 id 不对应的问题。于是我们把需要用到的用户的 /etc/{passwd,group,shadow} 统统拷贝到新的系统的相应地方。然后是配置 winbind,就是按部就班地按照 Arch Wiki 和以前的配置进行更新,然后成功地把 AD 上的用户获取到。此时再次出现了 uid 不对应的问题,此时我们使用 chown -R user:user /home/user 的方法。
剩下的工作就是琐碎的安装各种常用软件。不必多说。
P.S. 我研究出了一个很好用的 mosh + tmux 的 fish function: (但是有时工作有时不工作,不明白什么回事)
function tmosh
mosh $argv -- tmux new-session bash -c 'tmux set -g mouse on; tmux setw -g mode-keys vi; fish'
end