NAS With UbuntuServer20.04
本文最后更新于 424 天前,其中的信息可能已经有所发展或是发生改变。

读取群晖Basic存储池硬盘:

群晖官方方法:
 
sudo apt-get update
sudo apt-get install -y mdadm lvm2
sudo mdadm -Asf && vgchange -ay
若提示:
mdadm: no arrays found in config file or automatically
可重新生成mdadm.conf
sudo rm /etc/mdadm/mdadm.conf
update-initramfs  -u

 

添加新硬盘

使用fdisk查看分区

sudo fdisk -l

使用fdisk创建新分区

sudo fdisk /dev/sdb

使用parted查看分区

sudo parted -l

使用parted创建分区

sudo parted /dev/sdb

创建gpt分区表

mklabel gpt

格式化分区

mkpart primary ext4 1MB 4000G

查看分区UUID

sudo blkid

填写挂载配置文件

sudo nano /etc/fstab

/etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/ubuntu-vg/ubuntu-lv during curtin installation
/dev/disk/by-id/dm-uuid-LVM-RDSM2lgt5dtXsLobmfXZ0GdjUC9czcWtH3GDW8cuqyQ2157yc7UTeiwfitBdcnSf / ext4 defaults 0 1
# /boot was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/61791f4c-e116-4fb0-b326-32a3319039bb /boot ext4 defaults 0 1
# /boot/efi was on /dev/sda1 during curtin installation
/dev/disk/by-uuid/B5BC-9F72 /boot/efi vfat defaults 0 1
/swap.img       none    swap    sw      0       0
UUID=440583d3-bd52-4740-9cff-f9f48a2f9508 /HDDs/HGST3000 ext4     defaults       0 0
UUID=f2be3c34-00c7-408e-bf09-7c2ba0b83ea1 /HDDs/ST500a   ext4     defaults       0 0
UUID=d21b95fa-0c7c-40a2-b6f4-bf9be2b6176b /HDDs/ST500b   ext4     defaults       0 0
UUID=9aff0c78-8043-45bf-83f2-0ff2717606fd /HDDs/WD4000   ext4     defaults       0 0

 

 

文件共享

Samba:

配置文件: /etc/samba/smb.conf
[global]
    workgroup = WORKGROUP
    server string = %h server (Samba, Ubuntu)
    log file = /var/log/samba/log.%m
    max log size = 1000
    logging = file
    panic action = /usr/share/samba/panic-action %d

[HGST3000]
    comment = HGST3000
    path = /HDDs/HGST3000
    read only = no
    browsable = yes
    valid users = harson
    
[ST500a]
    comment = ST500a
    path = /HDDs/ST500a
    read only = no
    browsable = yes
    valid users = harson
    
[ST500b]
    comment = ST500b
    path = /HDDs/ST500b
    read only = no
    browsable = yes
    valid users = harson

[WD4000]
    comment = WD4000
    path = /HDDs/WD4000
    read only = no
    browsable = yes
    valid users = harson
Samba添加和当前系统同名用户后可以同步密码
sudo smbpasswd -a harson

webdav server with Nginx:

安装带扩展的Nginx
sudo apt -y install nginx nginx-extras libnginx-mod-http-dav-ext libnginx-mod-http-auth-pam
创建如下文件
sudo nano /etc/nginx/conf.d/webdav.conf
配置文件内容如下
server
{
    listen 9999 ssl http2;
    client_max_body_size 20M;
    ssl_certificate    /home/harson/webdav/pem/fullchain.pem;
    ssl_certificate_key    /home/harson/webdav/pem/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;

    location /
    {
        dav_methods PUT DELETE MKCOL COPY MOVE;
        dav_ext_methods PROPFIND OPTIONS;
        dav_access group:rw all:r;
        root /HDDs;
        auth_basic "Authorized Users Only";
        auth_basic_user_file /home/harson/webdav/authorize.conf;
    }

    access_log  /home/harson/webdav/logs/webdav.log;
    error_log  /home/harson/webdav/logs/webdav.error.log;
}
重载Nginx
sudo nginx -s reload

ftps

sudo apt install vsftpd
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
sudo cp /etc/vsftpd.conf  /etc/vsftpd.conf_default
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo nano /etc/vsftpd.conf
vsftpd.conf
# Example config file /etc/vsftpd.conf
# Run standalone?  vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=NO
#
listen_ipv6=YES
#
# Allow anonymous FTP? (Disabled by default).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# If enabled, vsftpd will display directory listings with the time
# in  your  local  time  zone.  The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#xferlog_file=/var/log/vsftpd.log
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# This option should be the name of a directory which is empty.  Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd

#FTP root dirctory
local_root=/HDDs/
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/home/harson/webdav/pem/fullchain.pem
rsa_private_key_file=/home/harson/webdav/pem/privkey.pem
ssl_enable=YES
#
#Some Android client do not support ssl reuse 
require_ssl_reuse=NO
#
# Uncomment this to indicate that vsftpd use a utf8 filesystem.
utf8_filesystem=YES
	

 

sudo systemctl restart vsftpd.service

硬件状况查看

 sudo apt install lm-sensors hddtemp
查看CPU等传感器温度

sensors
查看硬盘温度

sudo hddtemp /dev/sdc

查看硬盘S.M.A.R.T

smartctl -a <device>
smartctl -l error <device>
上一篇
下一篇