Blogs
pve 安装 immortalwrt
immortalwrt firmware selector, pve 安装下载 squashfs-combined-efi. squashfs: 一种只读的文件系统,每次修改: actually a copy of it is being copied to the second (JFFS2) partition combined: 带引导分区文件 combined-efi: 支持 efi 启动 1. 安装 # 上传到 pve 任意目录 gzip -d immortalwrt-xxx # 查看已有虚拟机配置: qm config <vmid> # ~~net0 待启动 immortalwrt 基本设置完成后再设置~~ # 创建空白虚拟机(无磁盘) qm create 201 --name opw-immort-2305.4 \ --ostype l26 --scsihw virtio-scsi-single \ --cpu x86-64-v2-AES --cores 2 --memory 2048 \ --net0 virtio,bridge=vmbr0,firewall=1 \ --net1 virtio,bridge=vmbr1,firewall=1 \ --net2 virtio,bridge=vmbr2,firewall=1 \ --boot order=scsi0 # 导入磁盘, 此命令成功后会输出 `Successfully imported disk as 'unused0:local-lvm:vm-201-disk-0'`, 记录 local-lvm:vm-201-disk-0 后续命令使用 qm importdisk 201 immortalwrt-xxx.img local-lvm # 磁盘连接到虚拟机的 SCSI 控制器, 并设置大小 qm set 201 --scsi0 local-lvm:vm-201-disk-0,iothread=1,size=1024M 2. 配置 配置备份与还原: 系统 > 备份与升级
2024/06/16
ssh jump & port forwarding
References: SSH from A through B to C, using private key on B A Visual Guide to SSH Tunnels: Local and Remote Port Forwarding man/SSHD_CONFIG.5 ssh jump use self key situation: ssh ssh A ------> B ------> C ^ ^ using A's using A's ssh key ssh key Access C from A by: ssh -J B C
2024/04/28
WSL2 安装 ArchLinux
wsl2: wsl --install --no-distribution; wsl --set-default-version 2 推荐浏览: wsl 检查可用容量 wsl vhdx 定位 wsl-config ArchL Wiki ArchL Wiki pacman 安装 ArchLinux 基本安装 官网文档: Install Arch Linux on WSL 以 import 的方式安装: wsl --import Arch "D:\wsl\arch" "D:\downloads\archlinux.wsl" --version 2 wsl -l -v wsl --manage Arch --set-sparse true wsl --setdefault Arch wsl2 config windows 下的 ~/.wslconfig 和 子系统下的 /etc/wsl.conf 可配置项部分不是完全相同的!!!
2024/04/09
PVE 首页添加温度
pve 首页添加温度 1. 依赖配置 # 安装依赖 apt install lm-sensors # 检测可用传感器 sensors-detect # 测试 -j 参数表示 json 输出 sensors -j 2. 修改源码 vi 编辑按键不对解决: nano /etc/vim/vimrc.tiny 将 set compatible 改为 set nocompatible
2023/09/23
go 杂项
http.Response.Body 注意 Body 字段的注释: The default HTTP client’s Transport may not reuse HTTP/1.x “keep-alive” TCP connections if the Body is not read to completion and closed. 为了连接复用,需要读取和关闭 body,如果实际不用 body 时可使用 io.Copy(io.Discard, resp.Body) 使用 strace 查看连接情况: strace -qqfe connect ./read_body 2>&1 | grep -E '\(80\)|doRequest' In [1]: %%writefile /tmp/read_body.go // go build -o read_body main.go package main import ( "fmt" "io" "net/http" ) func doRequest(closeBody, readBody bool) { resp, err := http.Get(`http://httpbin.org/get`) if err != nil { panic(err) } defer resp.Body.Close() if readBody { io.Copy(io.Discard, resp.Body) } fmt.Printf("doRequest done, closeBody=%v, readBody=%v\n", closeBody, readBody) } func main() { doRequest(true, true) doRequest(false, true) doRequest(true, true) doRequest(true, true) doRequest(true, false) doRequest(true, true) } Out[1]: Cell contents written to "/tmp/read_body.go". In [2]: !cd /tmp; go build -o read_body read_body.go !cd /tmp; strace -qqfe connect ./read_body 2>&1 | grep -E '\(80\)|doRequest' // 可以看到有两次 `connect(5, {sa_family=AF_INET...`, 第二发生在 `doRequest(true, false)` 的下一个请求, 即其没有释放连接 Out[2]: [pid 33511] connect(5, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("198.18.1.217")}, 16) = -1 EINPROGRESS (Operation now in progress) doRequest done, closeBody=true, readBody=true doRequest done, closeBody=false, readBody=true doRequest done, closeBody=true, readBody=true doRequest done, closeBody=true, readBody=true doRequest done, closeBody=true, readBody=false [pid 33511] connect(5, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("198.18.1.217")}, 16) = -1 EINPROGRESS (Operation now in progress) doRequest done, closeBody=true, readBody=true json.Marshal 结构体内部匿名字段实现了 json.Marshaler(方法: MarshalJSON() ([]byte, error)), 则会直接调此 MarshalJSON 而忽略结构体. 源码:
2023/04/15
go 字符串
相关文档: spec#Rune_literals spec#String_literals spec#String_types blog/strings In [1]: import ( ic "github.com/WAY29/icecream-go/icecream" "os" ) func init() { ic.ConfigurePrefix("\u001B[37mic| \u001B[0m") ic.ConfigureOutputFunction(os.Stdout) ic.ConfigureArgNameFormatterFunc(func(name string) string { return "\u001B[36m" + name + "\u001B[0m" }) } 0. 关于 rune 标识 Unicode 码点(code point) 的整数值, 其类型声明为: type rune = int32 是 int32 的别名。
2023/04/09
rclone快速上手
doc: https://rclone.org/docs/ # 开启命令行提示, oh-my-zsh 不要 compinit 相关 rclone genautocomplete zsh # 如果提示 /zsh/vendor-completions 不存在,可以放到家目录下: acdef_path="${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/rclone" mkdir -p "$acdef_path" rclone genautocomplete zsh "$acdef_path/_rclone" # 然后添加 rclone 到 .zshrc 的 plugins 列表里 plugin=(... rclone) 0. config rclone config paths rclone config show 命令行交互式创建配置:
2023/04/02
lf 快速上手
常用命令快捷键 搜索和查找 ignorecase 忽略大小写 搜索 globsearch (false) 是否支持 glob pattern incsearch (false) 是否增量搜索, 即每次按下字符都搜索. 增量模式下 cmd-enter 确认, cmd-escape 取消(光标位置会回滚回去) 查找 anchorfind (true) 是否只查找第一个字符 findlen (1) 查找长度, 默认是 1, 即只能输入 1 个字符来查找 常用命令 cmds 查看定义的命令 maps 查看快捷键(包括内置的) 常用快捷键 q 退出 y 复制(没有选择文件时使用当前文件) d 剪贴(没有选择文件时使用当前文件) p 粘贴 复制/剪贴 的文件 c 清除 复制/剪贴 e 编辑 i 预览 m 保存当前目录到书签, 其会提示输入一个字符来命名 ' 选择要加载的书签 <space> 切换文件的选择状态 gg 跳转到顶部 G 跳转到底部 # 搜索相关 / 搜索 ? 反向搜索, 结果的上下顺序颠倒 n 移动到下一个 N 移动到上一个 # 查找相关 (findlen) f 查找 F 反向查找, 结果的上下顺序颠倒 ; 移动到下一个 , 移动到上一个 配置概要 lf/doc
2023/03/08
python 依赖包离线
1. conda 离线 1.1 离线创建虚拟环境 复制 base 环境: conda create --clone base --prefix $HOME/.conda/envs/YOUR_ENV_NAME 1.2 离线 py 包 1.2.1 依赖简单的 py 包 离线依赖较少的 py 包。 下载: 官网下载: https://repo.anaconda.com/pkgs/, 在这里找到自己需要的 channel 以及操作系统版本。
2021/02/27