Categories
linux

linux 硬盘管理常用命令

dd

硬盘复制用命令 镜像复制命令

例子

sudo dd if=openwrt-image.img of=/dev/mmcblk0 bs=4M status=progress
复制当前目录下 openwrt-image.img 镜像  到/dev/mmcblk0 的硬盘

sudo dd if=/dev/mmcblk1 of=/dev/mmcblk0 bs=4M status=progress
将/dev/mmcblk1整个硬盘复制到/dev/mmcblk0  /dev/mmcblk0容量大于/dev/mmcblk1

sudo dd if=/dev/zero of=/dev/mmcblk0 bs=4M status=progress
清空控盘内容(全写0)

fdisk

管理查看硬盘分区信息

例子

sudo fdisk /dev/mmcblk0  
然后会进入硬盘命令行子命令交互空间

df

查看硬盘占用情况

df ./
展示当前目录所在硬盘分区占用情况

df -h
展示系统硬盘分区占用情况  包括挂载点信息

mount

挂载分区到某个挂载点

sudo mount /dev/mmcblk0p2 /mnt
其实一般当自动插入sd卡 或者USB就会自动挂载到这里
但是要改变挂载方式(可读可写) 就要先卸载在挂载

sudo mount -o rw /dev/mmcblk0p2 /mnt
增加-o rw 即为可读可写

umount

卸载分区

sudo umount /dev/mmcblk0p2

ln

这个命令可以为文件夹和文件设置硬链接和软连接

个人更加推崇软连接(硬链接是硬盘级别内部的连接 不能跨硬盘,软连接可以)

ln -s /path/to/source /path/to/destination

/etc/fstab

这个文件用来设置文件系统自动挂载

sudo blkid
列出系统所有分区的uuid

/etc/fstab 添加一行

UUID=1234-5678 /mnt ntfs rw 0 0

UUID=1234-5678:替换为你在步骤 1 中获取的 UUID。
/mnt:替换为你创建的挂载点。
ntfs:替换为你的文件系统类型(例如 ext4、ntfs 等)。
rw:默认挂载选项,包括 rw(读写)、suid、dev、exec、auto、nouser 和 async。
0 0:表示不进行备份和不进行文件系统检查。

Categories
K8S

K3S PVC local drive SD卡扩容

默认node 实体机器 PVC文件夹

/var/lib/kubelet/pods/<pod-uid>/volumes/kubernetes.io~csi/<pvc-name>/mount

可以通过 yaml 改变路径

apiVersion: v1
kind: PersistentVolume
metadata:
  name: example-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  local:
    path: /mnt/data
  nodeAffinity:
    required:
      nodeSelectorTerms:
        - matchExpressions:
            - key: kubernetes.io/hostname
              operator: In
              values:
                - your-node-name

通过 spec.local.path 设置指定路径

Categories
K8S

K3s 初始化

curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh

或者用我的 脚本install-agent 来安装

http://gitea.robinluo.top/robin/robin-k8s-yaml-script/src/branch/master/192.168.0.34

Categories
go

wxapkg 小程序源码反编译工具

我的fork link

https://github.com/RobinLJB/wxapkg

https://gitee.com/robinljb/wxapkg.git

http://gitea.robinluo.top/robin/wxapkg.git

基于go的微信小程序 反编译工具

有空可以自己尝试源码编译

PC 微信小程序目录

C:\Users\15699\Documents\WeChat Files\Applet\wxd7114bed517d1b84

Categories
K8S

安装Nexus3 后 部署docker仓库

  1. 导航到“仓库”部分。
  2. 点击“创建仓库”按钮,选择“docker (proxy)”或“docker (hosted)”类型。
  3. 根据你选择的类型配置仓库。
  4. 选择“docker (hosted)”,则可以管理本地Docker镜像。

具体配置页面截图

开启http服务 多开通8082 作为docker 仓库服务端口(only http) 内置的https 会有证书问题

nexus 添加 docker 账号密码校验 Realms (可以允许docker login)

Categories
K8S

K3S 安装 nexus3

amd64 拉取 sonatype/nexus

arm64 拉取 klo2k/nexus3

镜像默认开放8081 挂载目录/nexus-data

默认 admin密码 在容器内部 cat nexus-data/admin.password

Categories
K8S

K3S 常用命令

K3S token

NAME:
   k3s token - Manage bootstrap tokens

USAGE:
   k3s token command [command options] [arguments...]

COMMANDS:
   create    Create bootstrap tokens on the server
   delete    Delete bootstrap tokens on the server
   generate  Generate and print a bootstrap token, but do not create it on the server
   list      List bootstrap tokens on the server

OPTIONS:
   --help, -h  show help
Categories
openwrt

openwrt 包管理系统

opkg 是 openwrt 的包管理系统 对标与 APT 在ubuntu\debian

opkg 配置文件 /etc/opkg.conf

Categories
docker K8S

K3S kubectl 常用命令

查看log    sudo k3s kubectl logs -f -n kubernetes-dashboard kubernetes-dashboard-758765f476-x8rc7

应用 yaml  sudo k3s kubectl apply -f XXX.yaml

查看所有资源 sudo k3s kubectl get all --all-name-spaces

删除命名空间 sudo k3s kubectl delete ns  XXXXX

进入容器命令行 sudo k3s kubectl exec -it nexus-deployment-87b59d446-ht7p4 -n nexus - /bin/bash

创建命名空间 sudo k3s kubectl create namespace logging
Categories
docker K8S

K3S containerd mirror 设置 与 常用命令

列出镜像 sudo k3s ctr i list

删除本地镜像 sudo k3s ctr i rm registry.cn-hangzhou.aliyuncs.com/robinluo/robinluo:v2.0.4

拉取镜像 sudo k3s ctr i pull registry.cn-hangzhou.aliyuncs.com/robinluo/robinluo:v2.0.4 –plain-http

–plain-http 可指定使用 http拉取镜像

ctr -n k8s.io images pull –platform linux/amd64 my-image:my-tag

镜像打tag sudo k3s ctr i tag registry.cn-hangzhou.aliyuncs.com/robinluo/robinluo:v2.0.4 new tag

导入docker 导出的镜像 ctr i import image.tar

设置mirror

/etc/rancher/k3s/registries.yaml

mirrors:
  "docker.io":
    endpoint:
      - "https://registry.cn-hangzhou.aliyuncs.com"
mirrors:
  "my-registry.com":
    endpoint:
      - "https://my-registry.com"
configs:
  "my-registry.com":
    auth:
      username: user
      password: password

另一种设置containerd mirror方法

K3s 将会在/var/lib/rancher/k3s/agent/etc/containerd/config.toml中为 containerd 生成 config.toml。[ 建议不要直接对 containerd 的配置文件进行修改,格式十分的严格 ]

如果要对这个文件进行高级设置,你可以在同一目录中创建另一个名为 config.toml.tmpl 的文件,此文件将会代替默认设置。

config.toml.tmpl将被视为 Go 模板文件,并且config.Node结构被传递给模板。此模板示例介绍了如何使用结构来自定义配置文件

   [plugins."io.containerd.grpc.v1.cri".registry]
      [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
          [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
          endpoint = ["https://------.mirror.aliyuncs.com", "https://registry-1.docker.io"]

补充ctr 命令分为 i image 镜像 c container 容器 t task 任务(进程)

我们可以分别用 task 命令和 container 命令取停止和启动一个容器实例