ZFS on FreeBSD

# 开启root的ssh登录
sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
service sshd restart
# 更新pkg,安装常用软件包
pkg update -y
pkg install bash vim rsync mtr nmap sudo smartmontools htop net-snmp iperf3 zip unzip bash-completion
# 切换shell为bash
chsh -s /usr/local/bin/bash
# ipmitool
pkg install ipmitool
sysrc smbus_load="YES"
sysrc ipmi_load="YES"
# load module
kldload ipmi.ko smbus.ko
# check
kldstat
 
# 让vim更接近linux的vim
cat > /root/.vimrc <<'EOF'
syntax on
set bs=2
set hls
EOF
 
cat >> /etc/profile <<'EOF'
export EDITOR=vim
alias ll='ls -lh --color=auto'
#man color
export LESS_TERMCAP_mb=$(printf '\e[01;31m') # enter blinking mode - red
export LESS_TERMCAP_md=$(printf '\e[01;35m') # enter double-bright mode - bold, magenta
export LESS_TERMCAP_me=$(printf '\e[0m') # turn off all appearance modes (mb, md, so, us)
export LESS_TERMCAP_se=$(printf '\e[0m') # leave standout mode
export LESS_TERMCAP_so=$(printf '\e[01;33m') # enter standout mode - yellow
export LESS_TERMCAP_ue=$(printf '\e[0m') # leave underline mode
export LESS_TERMCAP_us=$(printf '\e[04;36m') # enter underline mode - cyan
EOF
 
source /etc/profile
 
# 创建用户mrco
pw group add mrco -g 1000
pw useradd mrco -m -u 1000 -G mrco
id mrco
visudo
mrco ALL=(ALL:ALL) NOPASSWD:ALL
 
# 关闭root ssh登录
sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
service sshd restart
 
zpool import -f tank
zpool list
zpool status -v tank
zdb | grep ashift
 
cat >> /etc/sysctl.conf <<'EOF'
vfs.zfs.arc_max=25769803776
EOF
 
# 安装samba
pkg search samba
pkg install samba48-4.8.2
 
# 限定ARC
# https://manuth.life/limit-amount-ram-used-cache-freebsd/
cat >> /etc/sysctl.conf <<'EOF'
kern.maxfiles=25600
kern.maxfilesperproc=16384
net.inet.tcp.sendspace=65536
net.inet.tcp.recvspace=65536
EOF
# 开机自启动
/etc/rc.conf:
sysrc samba_server_enable="YES"
sysrc nmbd_enable="YES"
sysrc winbindd_enable="YES"
 
/usr/local/etc/smb4.conf
service samba_server start
service samba_server status
 
smbpasswd -a mrco
 
# NFS
http://lychen.pixnet.net/blog/post/22401851-freebsd-nfs-client-server-%E8%A8%AD%E5%AE%9A
 
cat > /etc/exports <<'EOF'
/tank/data  -network 172.17.1.0/24
/tank/share  -network 172.17.1.0/24
/tank/movies  -network 172.17.1.0/24
/tank/share  -network 172.17.1.0/24
/tank/ss  -network 172.17.1.0/24
/tank/t460p  -network 172.17.1.0/24
/tank/downloads  -network 172.17.1.0/24
EOF
 
# enable services
sysrc rpcbind_enable="YES"
sysrc nfs_server_enable="YES"
sysrc mountd_enable="YES"
 
# start services
service rpcbind start
service mountd start
service nfsd start
 
showmount -e 172.17.1.3
 
# collectd
pkg install collectd5
vim /usr/local/etc/collectd.conf
sysrc collectd_enable="YES"
 
https://elatov.github.io/2013/02/monitor-different-systems-with-collectd/
whereis collectd
cd /usr/ports/net-mgmt/collectd5/
sudo make install clean
  • storage/zfs/zfs_on_freebsd.txt
  • 最后更改: 2019/04/16 18:31
  • (外部编辑)