WeiNote

yyrcd

gpu

os

pl

2021

Jul 14

2021-07-14 ·

内存 pageout swapout

$ vm_stat 2
Mach Virtual Memory Statistics: (page size of 16384 bytes)
    free   active   specul inactive throttle    wired  prgable   faults     copy    0fill reactive   purged file-backed anonymous cmprssed cmprssor  dcomprs   comprs  pageins  pageout  swapins swapouts
   56511   383075    10917   371732        0   111455     2131 68649803  5590148 38464146  1059943   257199      362954    402770   175812    75492   298067   705884  1240072    10900        0        0
   57043   383207    10916   371045        0   111480     2136     5898      357     3281        0        0      362953    402215   175811    75492        1        0        0        0        0        0
   59374   381386    10916   370487        0   111530     2128     2259      119     1407        0      152      362953    399836   175811    75492        0        0        0        0        0        0
   59436   381385    10917   370461        0   111491     2129     3927      238     2242        0        0      362954    399809   175811    75492        0        0        0        0        0        0
   58088   383078    10927   370769        0   110906     2106     5078      238     2648        0        0      362965    401809   175809    75492        2        0        0        0        0        0
   56127   383643    10993   371406        0   111726     2127     8707      119     3541        7        0      363066    402976   174009    75375     1751        0       64        0        0        0
   55010   384327    11000   372120        0   111361     2140     6645      357     3852        0        0      363116    404331   173978    75363       30        0       41        0        0        0
   57239   382808    11014   371050        0   111818     2178     6626      259     3642        0        0      363160    401712   173880    75363       98        0       17        0        0        0

Ref: 你到底需要多少内存?| macOS下非严谨测试 - YouTube

2021

Jul 02

2021-07-02 ·

安装 Windows

  1. NVME M.2 安装 Windows 的坑: https://www.dell.com/support/kbdoc/zh-cn/000132465/windows-10-安装-带-nvme-ssd-和-sata-驱动器
  2. linux 制做 U 盘时需要手动 sync
    cp src dest
    sync  # manual sync to assure write is done
    watch -n 1 -d 'cat /proc/meminfo | grep Dirty'  # check sync progress

2021

Jul 01

2021-07-01 ·

IO 性能测试

dd if=/dev/zero of=~/test1.img bs=1G count=1 oflag=dsync
dd if=/dev/zero of=~/test2.img bs=512 count=1000 oflag=dsync

2021

Jan 29

2021-01-29 ·

Cgroup V2

Nvidia-docker

Edit /etc/nvidia-container-runtime/config.toml and change #no-cgroups=false to no-cgroups=true. After a restart of the docker.service sudo systemctl restart docker everything will work as usual.

System

Kernel/KernelBootParameters - Ubuntu Wiki

sudo vim /etc/default/grub
# GRUB_CMDLINE_LINUX_DEFAULT="quiet splash systemd.unified_cgroup_hierarchy=1"
sudo update-grub

Docker

Plex needs

sudo mkdir /sys/fs/cgroup/systemd
sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd

https://github.com/docker/for-linux/issues/219#issuecomment-375160449 restart will have issue fix by add into /etc/init.d/my-cgroup-systemd

-rwxr-xr-x 1 root root 96 Mar  5 22:40 my-cgroup-systemd
mkdir /sys/fs/cgroup/systemd
mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd

then edit /etc/rc.local add the script file path

2019

2019

Jun 30

2019-06-30 ·

Wireguard

Install

Set Up WireGuard VPN on Ubuntu | Linode

Server

Enable ip forward

sudo vim /etc/sysctl.conf
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
sudo sysctl -p

IPv6

tcpdump

sudo tcpdump -i wg0 port 22
$ sudo tcpdump -i wg0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wg0, link-type RAW (Raw IP), capture size 262144 bytes
12:05:06.856663 IP 111.11.1.2 > 111.11.1.3: ICMP echo request, id 28433, seq 0, length 64
12:05:06.856721 IP 111.11.1.2 > 111.11.1.3: ICMP echo request, id 28433, seq 0, length 64
12:05:06.876567 IP 111.11.1.3 > 111.11.1.2: ICMP echo reply, id 28433, seq 0, length 64
12:05:06.876592 IP 111.11.1.3 > 111.11.1.2: ICMP echo reply, id 28433, seq 0, length 64
12:05:07.859800 IP 111.11.1.2 > 111.11.1.3: ICMP echo request, id 28433, seq 1, length 64
12:05:07.859827 IP 111.11.1.2 > 111.11.1.3: ICMP echo request, id 28433, seq 1, length 64
12:05:07.879684 IP 111.11.1.3 > 111.11.1.2: ICMP echo reply, id 28433, seq 1, length 64
12:05:07.879707 IP 111.11.1.3 > 111.11.1.2: ICMP echo reply, id 28433, seq 1, length 64

ping

richard@mbpr > ping 111.11.1.3
PING 111.11.1.3 (111.11.1.3): 56 data bytes
64 bytes from 111.11.1.3: icmp_seq=0 ttl=63 time=32.214 ms
64 bytes from 111.11.1.3: icmp_seq=1 ttl=63 time=32.074 ms
^C
--- 111.11.1.3 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 32.074/32.144/32.214/0.070 ms

Ref:

Mac wg-quick

wg-quick: Version mismatch: bash 3 detected, when bash 4+ required

brew install bash
export PATH=/usr/local/bin:$PATH

Mac run at login / startup

/Library/LaunchDaemons/com.startup.script.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.wireguard.startup.plist</string>
        <key>Disabled</key>
        <false/>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <false/>
        <key>LaunchOnlyOnce</key>
        <true/>
        <key>ProgramArguments</key>
        <array>
            <string>/bin/bash</string>
            <string>/Users/richard/bin/run-wg-on-start</string>
        </array>
        <key>StandardOutPath</key>
        <string>/tmp/wireguard.start.log</string>
        <key>StandardErrorPath</key>
        <string>/tmp/wireguard.start.err</string>
    </dict>
</plist>

~/bin/run-wg-on-start

#! /usr/local/bin/bash
export PATH=/usr/local/bin:$PATH
/usr/local/bin/wg-quick up /path/to/wireguard/wg0.conf
sleep 2147483647  # 24855 days
echo quitting wireguard after 2147483647s

load service

sudo launchctl load /Library/LaunchDaemons/com.startup.script.plist

Ref:

切换server

linux

sudo wg-quick down /path/to/wireguard/wg0.conf; sudo wg-quick up /path/to/wireguard/wg0.conf;

mac

sudo wg-quick down /path/to/wireguard/wg0.conf; sudo wg-quick up /path/to/wireguard/wg0.conf;

如果旧的 server 还在运行,因为旧的 server 还在 不断的和 client (e.g. mac) 握手通讯,client 的 wg 会以为 server 还是旧的 server,因此 sudo wg 会显示新 server ip 之后,又切换回旧 server 的 ip 。 正确做法是关闭旧 server 的 wg 服务,从而顺利切换新的 server。

server

sudo systemctl enable wg-quick@wg0.service

add a new peer

sudo systemctl restart wg-quick@wg0