Skip to main content

· One min read

方法四

  1. 保持未连接网络
  2. 在连接网络界面按 <Shift> + <F10>
  3. 命令行输入 oobe\bypassnro.cmd
  4. 选择 我没有Internet连接
  5. 选择继续执行受限设置

· 2 min read

find partition for /

findmnt -nosource /

/dev/sda3

split disk and partition number

growpart /dev/sda 3

resize2fs

resize2fs /dev/sda3

Automatically expand partiton mounted /

1. write go code

package main

import (
"os"
"os/exec"
"strings"
)

func main() {
if os.Geteuid() != 0 {
// fmt.Println("This script must be run as root")
os.Exit(1)
}

// Identify the device that / is mounted on
out, err := exec.Command("df", "/").Output()
if err != nil {
// fmt.Println("Error running df command:", err)
os.Exit(1)
}

// Parse the output to get the device
lines := strings.Split(string(out), "\n")
if len(lines) < 2 {
// fmt.Println("Unexpected output from df command")
os.Exit(1)
}

fields := strings.Fields(lines[1])
if len(fields) < 1 {
// fmt.Println("Unexpected output from df command")
os.Exit(1)
}

device := fields[0]
// fmt.Println("Device:", device)

// Extract the base device and partition number
var baseDevice, partNum string
if strings.HasPrefix(device, "/dev/mapper/") {
baseDevice = strings.TrimSuffix(device, "1")
partNum = "1"
} else {
baseDevice = strings.TrimRightFunc(device, func(r rune) bool {
return r >= '0' && r <= '9'
})
partNum = strings.TrimPrefix(device, baseDevice)

}

// Grow the partition
if err := exec.Command("growpart", baseDevice, partNum).Run(); err != nil {
// fmt.Println("Error running growpart command:", err)
os.Exit(1)
}

// Resize the filesystem
if err := exec.Command("resize2fs", device).Run(); err != nil {
// fmt.Println("Error running resize2fs command:", err)
os.Exit(1)
}
}

2. build

go mod init expand_disk
go mod tidy

GOOS=linux GOARCH=amd64 go build .

3. write system service expand_disk.service

[Unit]
Description=Expand disk partition mounted on /
After=initrd-usr-fs.target

[Service]
ExecStart=/usr/local/bin/expand_disk

[Install]
WantedBy=multi-user.target

4. enable service

  • Install to system
sudo cp expand_disk.service /usr/lib/system/systemd/
  • Enable system
sudo systemctl enable expand_disk

· One min read
  1. set netplan configuration
for inter in $(ls /sys/class/net); do
if [[ $inter != 'lo' ]]; then
cat << EOF > /etc/netplan/99-$inter.yaml
network:
ethernets:
$inter:
dhc4: true
version: 2
renderer: networkd
EOF
ip link set dev $inter up
fi
done
  1. apply configurations
netplan apply
  1. check IP status
ip a

Set network config on boot

  1. combine script as a shell /etc/netplan/gen_netplan_config.sh
#!/bin/env bash

umask 377

for inter in $(ls /sys/class/net); do
if [[ $inter != 'lo' ]] && [[ ! -e /etc/netplan/99-$inter.yaml ]]; then
cat << EOF > /etc/netplan/99-$inter.yaml
network:
ethernets:
$inter:
dhcp4: true
version: 2
renderer: networkd
EOF
ip link set dev $inter up
fi¡™™¡
done
netplan apply
  1. write /usr/lib/systemd/system/wait-netplan-dhcp.service3
[Unit]
Description=Generate DHCP networking DHCP demo for netplan
Before=network-online.target

[Service]
ExecStart=/etc/netplan/gen_netplan_config.sh

[Install]
WantedBy=multi-user.target
  1. start and enable
systemctl start wait-netplan-dhcp
systemctl enable wait-netplan-dhcp

· One min read

Runsudo systemctl edit getty@tty1.service

[Service]
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin myusername %I $TERM
Type=idle

· One min read
sudo rm -rf /var/cache/snapd/

sudo apt autoremove --purge snapd gnome-software-plugin-snap

rm -fr ~/snap

sudo apt-mark hold snapd

· 2 min read
  1. create/edit user docker configuration:
sudo vim /etc/docker/daemon.json
  1. set up proxy
{
"proxies": {
"http-proxy": "http://proxy.example.com:80",
"https-proxy": "https://proxy.example.com:443",
"no-proxy": "*.test.example.com,.example.org"
}
}
  • This is a full example of the allowed configuration options on Linux:
{
"allow-nondistributable-artifacts": [],
"api-cors-header": "",
"authorization-plugins": [],
"bip": "",
"bridge": "",
"cgroup-parent": "",
"containerd": "/run/containerd/containerd.sock",
"containerd-namespace": "docker",
"containerd-plugin-namespace": "docker-plugins",
"data-root": "",
"debug": true,
"default-address-pools": [{
"base": "172.30.0.0/16",
"size": 24
},
{
"base": "172.31.0.0/16",
"size": 24
}
],
"default-cgroupns-mode": "private",
"default-gateway": "",
"default-gateway-v6": "",
"default-network-opts": {},
"default-runtime": "runc",
"default-shm-size": "64M",
"default-ulimits": {
"nofile": {
"Hard": 64000,
"Name": "nofile",
"Soft": 64000
}
},
"dns": [],
"dns-opts": [],
"dns-search": [],
"exec-opts": [],
"exec-root": "",
"experimental": false,
"features": {},
"fixed-cidr": "",
"fixed-cidr-v6": "",
"group": "",
"hosts": [],
"proxies": {
"http-proxy": "http://proxy.example.com:80",
"https-proxy": "https://proxy.example.com:443",
"no-proxy": "*.test.example.com,.example.org",
},
"icc": false,
"init": false,
"init-path": "/usr/libexec/docker-init",
"insecure-registries": [],
"ip": "0.0.0.0",
"ip-forward": false,
"ip-masq": false,
"iptables": false,
"ip6tables": false,
"ipv6": false,
"labels": [],
"live-restore": true,
"log-driver": "json-file",
"log-level": "",
"log-opts": {
"cache-disabled": "false",
"cache-max-file": "5",
"cache-max-size": "20m",
"cache-compress": "true",
"env": "os,customer",
"labels": "somelabel",
"max-file": "5",
"max-size": "10m"
},
"max-concurrent-downloads": 3,
"max-concurrent-uploads": 5,
"max-download-attempts": 5,
"mtu": 0,
"no-new-privileges": false,
"node-generic-resources": [
"NVIDIA-GPU=UUID1",
"NVIDIA-GPU=UUID2"
],
"oom-score-adjust": 0,
"pidfile": "",
"raw-logs": false,
"registry-mirrors": [],
"runtimes": {
"cc-runtime": {
"path": "/usr/bin/cc-runtime"
},
"custom": {
"path": "/usr/local/bin/my-runc-replacement",
"runtimeArgs": [
"--debug"
]
}
},
"seccomp-profile": "",
"selinux-enabled": false,
"shutdown-timeout": 15,
"storage-driver": "",
"storage-opts": [],
"swarm-default-advertise-addr": "",
"tls": true,
"tlscacert": "",
"tlscert": "",
"tlskey": "",
"tlsverify": true,
"userland-proxy": false,
"userland-proxy-path": "/usr/libexec/docker-proxy",
"userns-remap": ""
}

· One min read
  • report message
Traceback (most recent call last):
File "requests\compat.py", line 11, in <module>
ModuleNotFoundError: No module named 'chardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "minarca_client\main.py", line 15, in <module>
from minarca_client.core import (
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "minarca_client\core\__init__.py", line 23, in <module>
import requests
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "requests\__init__.py", line 45, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "requests\exceptions.py", line 9, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "requests\compat.py", line 13, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "charset_normalizer\__init__.py", line 24, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "charset_normalizer\api.py", line 5, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "charset_normalizer\cd.py", line 9, in <module>
ModuleNotFoundError: No module named 'charset_normalizer.md__mypyc'
  • resolution
pyinstaller --hiddenimport charset_normalizer.md__mypyc