西维蜀黍

【FreeBSD】Jail 管理

管理 Jail Instance

$ iocage list
+------+---------+-------+--------------+---------------+
| JID  |  NAME   | STATE |   RELEASE    |      IP4      |
+======+=========+=======+==============+===============+
| 1    | SWJail  | up    | 12.2-RELEASE | 192.168.18.70 |
+------+---------+-------+--------------+---------------+
| None | SWJail2 | down  | 12.2-RELEASE | DHCP          |
+------+---------+-------+--------------+---------------+
| None | SWJail3 | down  | 12.2-RELEASE | 192.168.18.71 |
+------+---------+-------+--------------+---------------+
  ...


【FreeBSD】安装 Aquantia AQtion 10G 网卡驱动

Knowledge

If the driver for the NIC is not present in GENERIC, but a driver is available, the driver will need to be loaded before the NIC can be configured and used. This may be accomplished in one of two ways:

  • The easiest way is to load a kernel module for the NIC using kldload(8). To also automatically load the driver at boot time, add the appropriate line to /boot/loader.conf. Not all NIC drivers are available as modules.
  • Alternatively, statically compile support for the NIC into a custom kernel. Refer to /usr/src/sys/conf/NOTES, /usr/src/sys/*arch*/conf/NOTES and the manual page of the driver to determine which line to add to the custom kernel configuration file. For more information about recompiling the kernel, refer to Chapter 8, Configuring the FreeBSD Kernel. If the NIC was detected at boot, the kernel does not need to be recompiled.
  ...


【FreeBSD】FreeBSD 管理

Operation

Check FreeBSD Version

# Display the FreeBSD version and patch level of the installed system
$ freebsd-version

# Get information about the system including FreeBSD version
$ uname -mrs
  ...


【NAS】TrueNAS 折腾

Install TrueNAS

https://www.truenas.com/docs/hub/initial-setup/install/firsttimeinstall/#hardware-requirements

https://www.youtube.com/watch?v=iaIezpQsaOE&t=989s

Init OS

  • 设置时区:System - Genral
  • 设置TrueNAS的名字:Network - Global Configuration

给 SMB 增加一个 User,因为不能用 root 登录 SMB。

  ...


【Golang】包加载(Package Initialization)

Package Initialization 包括两部分

  • 变量初始化
  • init() functions

变量初始化

  ...


【Golang】内置函数 - init()

init()

init() 函数的主要特点:

  • init() 函数先于 main函数自动执行,不能被其他函数调用;
  • init() 函数没有输入参数、返回值;
  • 一个包可以有多个 init() 函数,他们的执行顺序以每个文件作为单位,按照他们所在的文件的 lexical file name order,
  • 一个包中的一个源文件可以有多个 init() 函数,这点比较特殊;
  • 同一个包的 init() 执行顺序,Golang没有明确定义,编程时要注意程序不要依赖这个执行顺序。
  • 不同包的 init() 函数按照包导入的依赖关系决定执行顺序。

  ...


【Linux】命令 - kill

kill

Sends a signal to a process, usually related to stopping the process.

All signals except for SIGKILL and SIGSTOP can be intercepted by the process to perform a clean exit.

  ...


【Linux】命令 - su/sudo

sudo(Superuser Do)

  • 功能: sudo 允许用户以另一个用户(通常是超级用户 root)的权限来执行单个命令。sudo 是一个临时授权工具,它不需要用户知道 root 的密码,而是使用当前用户的密码来进行身份验证。
  • 用途: sudo 主要用于执行需要管理员权限的单个命令。例如,系统管理员可以为特定用户授予使用 sudo 的权限,使他们能够在不直接访问 root 账户的情况下执行特定的管理任务。
  ...


【Linux】命令 - telnet

telnet

  ...


【Linux】操作 - 查看进程的 stdout

Approach 1 - readlink

  • 1: STROUT
  • 2: STRERR

文件描述符 1(STDOUT)/proc/[$PID]/fd/,内核将此文件表示为指向文件描述符(FD)重定向到的文件的符号链接。

$ readlink -f /proc/[pid]/fd/[index]
/tmp/file
  ...