基本信息与硬件配置
Unraid 是基于 Linux slackware 的RAID系统,作为nas服务器能够随便添加硬盘,支持硬盘无访问自动休眠,同时有现成的很多plugin支持, 支持docker, 也支持 vm 虚拟机。
个人使用下来的感觉系统安装、使用都比较方便,可定制化程度高(只要会玩linux那套)。
个人用来跑unraid的硬件大部分从某二手平台上买的,在2020年初时候配齐的,除硬盘外的价格大概在1K出头。
CPU 是 E3-1265L v3 4核8线程,内存条 是三星的 8Gx2 , 这样能开两个虚拟机也不卡。
主板是 铭瑄MS-H81IL FS ,购买的时候没注意板上网卡最大带宽才100M,后面又自己补了个 AX88179 的 USB3.0 千兆网卡。
机箱选择了双盘位的暴风酷播云二代,是由万由代工的,外壳摸起来很有分量。
散热因为机箱空间有限,选择了高31mm的大镰刀S950M,配合机箱尾部的风扇,正常工作时CPU温度稳定在50℃,硬盘温度稳定在40℃左右。
2 重启恢复配置
参考插件的做法,可以将修改后的配置文件先拷贝到 /boot 目录下,这个目录实际就是U盘目录,每次重启时,都会从这个目录加载整个系统核配置到内存中运行。
Unraid 系统的启动脚本目录位于 /boot/config/go ,较为简单的回复配置可以在该文件后添加shell脚本。
我当前使用的整个恢复配置项目:
https://github.com/yibiner/custom.script
对于项目中的一些文件说明:
-
commfunc.sh 公共函数文件。包含一些日志输出函数。
-
updateconfig.sh 将一些配置(ssh,oh-my-zsh)保存到U盘中
-
setohmyzsh.sh 恢复oh-my-zsh配置
-
setssh.sh 恢复ssh 的配置
使用也比较简单:
1、直接将项目clone到 /boot/config下
2、在 /boot/config/go 文件中最后添加
cp -r /boot/config/custom.scripts /tmp
bash /tmp/custom.scripts/startall.sh
3、重启
3 Oh My Zsh 安装配置
-
先安装zsh
-
-
在 APPS 中搜索并安装 Nerd Pack
-
在 SETTINGS -> Nerd Pack 中安装 zsh
-
-
命令行运行下面两条中的任一命令安装oh-my-zsh
# curl 安装
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# wget 安装
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
-
执行脚本 bash /tmp/updateconfig.sh,将当前的设置和文件保存到U盘中
# 项目 custom.scripts(https://github.com/yibiner/custom.script) 中 恢复oh-my-zsh
$ cat setohmyzsh.sh
#!/bin/bash
# 将 oh-my-zsh 解压到目录
if [ ! -d /root/.oh-my-zsh ] ; then
tar -zxvf oh-my-zsh.tar.gz -C /root
fi
# 将配置文件拷贝回目录
cp $BASE_PATH/.bash* /root
cp $BASE_PATH/.zsh* /root
4 SSH 配置:密钥登录、关闭密码登录
-
命令行下运行
ssh-keygen -t rsa -C "your_email@example.com"
生成密钥对 -
将
~/.ssh/id_rsa.pub
添加到 Unraid 的~/.ssh/authorized_keys
中,如果没有 .ssh 目录和 authorized_keys 文件,自己新建即可,需要注意 authorized_keys 文件权限为 644。 -
关闭密码登录。
/etc/ssh/sshd_config
将PasswordAuthentication yes
改成PasswordAuthentication no
, 重启sshd后生效 -
执行脚本 bash /tmp/updateconfig.sh,将当前的设置和文件保存到U盘中
# 项目 custom.scripts (https://github.com/yibiner/custom.script) 中 恢复ssh,将配置文件覆盖原有的配置后,重启服务
$ cat setssh.sh
#!/usr/bin/bash
# 从boot中恢复ssh文件
ssh_start()
{
# no-op if already running
if [ -f /var/run/sshd.pid ]; then
#echo "SSH already running"
#sleep 1
return
fi
echo "Starting SSH..."
sleep 1
/usr/sbin/sshd
echo "... OK"
sleep 1
}
ssh_stop()
{
# no-op if already running
if [ ! -f /var/run/sshd.pid ]; then
#echo "SSH already stopped"
#sleep 1
return
fi
echo "Stopping SSH..."
sleep 1
killall sshd
echo "... OK"
sleep 1
}
ssh_restart() {
if [ -r /var/run/sshd.pid ]; then
echo "Restarting parent listener process only. To kill every sshd process, you must use stop"
sleep 3
kill `cat /var/run/sshd.pid`
else
echo "Warning: there does not appear to be a parent instance of sshd running."
sleep 3
exit 1
fi
sleep 1
ssh_start
}
if [ -d "/root/.ssh" ]; then
cp $BASE_PATH/.ssh/* /root/.ssh/
fi
if [ ! -d "/root/.ssh" ]; then
cp -r $BASE_PATH/.ssh /root
fi
chmod 644 /root/.ssh/id_rsa.pub
chmod 644 /root/.ssh/authorized_keys
cp $BASE_PATH/sshd_config /etc/ssh/sshd_config
暂无评论内容