鱼喃

听!布鲁布鲁,大鱼又在那叨叨了

私有云---矿渣蜗牛星际折腾记

我的地盘我做主,跟大鱼一起来捡垃圾吧。

要有一个私有云

种草 NAS 很久了,一是因为网盘的价格还是蛮高的,只能存放下一些热数据,冷数据放在移动硬盘里,有时候想用还得翻出来;另一方面,国外网盘的速度还有有一点慢的。不过因为价格原因,再加上懒,一直没有下手。

有感于最近中美贸易战中各家纷纷站队,愈演愈烈,虽然说国外服务商不大可能针对个人,但是网络质量更加劣化怕是已经在路上了。此外,GitHub自动被收购之后大动作不断,加上授权太粗等原因,让人总感觉哪天会爆个大洞出来,私有仓库隐患很大。(20191218更新:微软看上去又准备推出GitHub国内版了)

于是拔草提上日程。看了看群晖的价格,支持 docker 的都好几千起,普通版本就只能当存储用,可还想跑一些程序。都说群晖是花钱买服务送设备,但是总感觉没有吸引到我的点,这钱略有不值。然后发现了蜗牛星际矿渣,j1900的CPU,4G内存,四盘位,市场价300,用来做NAS再合适不过了,要知道就算是只买硬件也不只这个价。

捡矿渣

深水宝上有不少卖的,其中一家价格高出一截但是改造了风扇,犹豫了一下还是选了这家。毕竟原装风扇这么吵,吵到我自己睡觉还好,万一吵到室友被揍了咋整,室友高高大大的,我可打不过。。。

这家还提供了免费两年的内网穿透服务,不过用别人的服务总觉得不放心,而且自己有现成的,直接忽略。

一共就四款,又分了单网卡多网卡好多种,挑来挑去最有选中了仿万由的B款机箱,颜值最高了。

蜗牛星际机箱对比

经过了漫长的48小时等待,终于拿到手,比想象中要沉多了,尺寸也不小(毕竟是四盘位,再压缩估计就影响散热了)。

拆箱

卖家预装了黑群晖,抱着瞅一瞅的想法先开机看看群晖都有啥功能,然而没有外挂硬盘没法完成初始化。遂放弃,直接重装系统了,装完系统先随便测试一下,emmmm,这硬盘io,快赶得上四大金刚家的钻石盘了,还有CPU,虽说提前知道J1900性能差,但是也没想到差这么多,怪不得刚刚装系统花了那么久。

性能测试

装上docker,想看看4H4G的主机是不是,就随手搭了一个Hadoop集群,然后运行wordcount,然后容器挂了。。。

电源

都说原装的山寨电源不安全,于是又淘了个台达的小1U电源装上了。

硬盘

系统盘

原来的系统盘太烂了,读写慢就不说了,就怕哪天突然挂了我还得再装一次系统,换了一个256G的东芝,速度上去了,不过真心贵啊。

SSD

数据盘

要说贵,还是属硬盘最贵,西数红盘都快上千了,配四块再组raid,啧啧,价格太美不敢想。迫于贫穷,玩不起这一套,而且即便是RAID,也只能降低故障率,还是无法保证数据安全,还是多地备份性价比高一点。

买了一块2T西数蓝盘和一块500G的希捷,前者用来存放数据,后面放临时数据。

新硬盘

格式化硬盘并挂载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fdisk -l

fdisk /dev/sdb

n
p
1
<default>
<default>
p
w

mkfs.ext4 /dev/sdb1

mkdir /data

mount /dev/sdb1 /data

配置开机自动挂载,最后两个0分别表示是否备份和开机检查。一般来说,都没有配置备份,所以关掉就好,至于开机检查,本来就是不停机了,重启机会少,而且硬盘检查还花时间。

1
echo "/dev/sdb1 /data ext4 defaults 0 0" >> /etc/fstab 

一般这么配置就行,如果后面硬盘更换位置的话,把硬盘盘符换成UUID更加适合。

操作系统

用Debian用的最久,所以选了最新的Debian Buster,镜像的话直接在官方下载,也可以用国内速度比较快的源。一般来说,选第一个就行,比如debian-10.2.0-amd64-DVD-1.iso

先找到U盘的盘符,然后弹出,把镜像刻录进去。Macos下用diskutil list列出所有硬盘,Linux下可以用命令fdisk -l来查看。

1
diskutil unmountDisk /dev/disk2

Linux和MacOS下直接用dd命令来刻录光盘即可,Windows下工具就更多了,各种可视化工具,比如UltraISO什么的。

1
sudo dd if=~/Downloads/debian-10.2.0-amd64-DVD-1.iso of=/dev/rdisk2 bs=1m

在分区的时候直接选择自动分区,然后所有的分区都在一起就好了,数据盘另外再加。Automatically partition the free space,在接下来的界面中选择“All files in one partiton。在选择预置服务的时候吧ssh勾上,其他基本都不需要。

初始化

装好系统之后首先更新一下APT,顺便更新软件包。

1
2
apt update
apt upgrade -y

这里需要注意一下,新装的系统没有sudo,而且禁用了root用户,所以需要先连着显示器把速冻装上,并且把新用户加到sudoers列表里,不然后续没法通过ssh管理。

1
sudo apt install -y sudo

启用rootlogin

1
2
3
4
5
vim /etc/ssh/sshd_config

PermitRootLogin yes

systemctl restart ssh

安全起见,这个后续建议关掉。

数据盘初始化

首先使用 fdisk来查看硬盘

1
2
3
4
5
$ sudo fdisk -l | grep 'Disk /dev/sd'
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Disk /dev/sdb: 59.6 GiB, 64023257088 bytes, 125045424 sectors
Disk /dev/sdc: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk /dev/sdd: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors

fdisk 支持2g的分区,更大的分区需要用partd

插拔硬盘盘符会变化,根据大小和类型查看

给数据盘分区

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p #查询现有分区#
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Disk model: KINGSTON SUV500M
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf196b74b

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 468862127 468860080 223.6G 83 Linux

Command (m for help): d #删除已有的分区#
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n #创建新分区#
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p #创建主分区#
Partition number (1-4, default 1): #默认#
First sector (2048-468862127, default 2048): #默认#
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-468862127, default 468862127):

Created a new partition 1 of type 'Linux' and of size 223.6 GiB.
Partition #1 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: y #删除已有的标记#

The signature will be removed by a write command.

Command (m for help): w #执行分区操作,写入分区表#
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

在划分的分区上,建立ext4类型文件系统

1
2
3
4
5
6
7
8
9
10
11
12
13
$ sudo mkfs.ext4 /dev/sda1
mke2fs 1.44.5 (15-Dec-2018)
Discarding device blocks: done
Creating filesystem with 58607510 4k blocks and 14655488 inodes
Filesystem UUID: 15f9e562-9602-4c6a-ad8a-a6dbc00b79ad
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

此时对于每一个分区会生成一个UUID。

查看UUID

1
2
3
4
5
6
7
$ sudo blkid 
/dev/sda1: UUID="15f9e562-9602-4c6a-ad8a-a6dbc00b79ad" TYPE="ext4" PARTUUID="f395b44b-01"
/dev/sdb1: UUID="50A2-2D83" TYPE="vfat" PARTUUID="064c3fdf-8a40-4f22-ae70-454961cb2852"
/dev/sdb2: UUID="259c879d-21ab-4190-bdf1-2cca8ad0a254" TYPE="ext4" PARTUUID="aac7fe0c-a108-4660-8acc-33830fb430cc"
/dev/sdb3: UUID="a9969258-6137-4964-a5ee-7e771e89bf47" TYPE="swap" PARTUUID="a20960cf-dcbb-46dd-9be1-f493aed528fc"
/dev/sdc1: UUID="d70a0f2a-6c7f-4b23-9554-c34120090038" TYPE="ext4" PARTUUID="3f36f79e-01"
/dev/sdd1: UUID="34d87932-0eda-4748-b246-e0ca62549f4b" TYPE="ext4" PARTUUID="7b991bdf-01"

创建挂载点

1
sudo mkdir -p /data

临时挂载

1
2
3
sudo mount /dev/sda1 /data

sudo chmod -R 777 /data

永久挂载

1
2
3
$ sudo vim /etc/fstab
# 添加以下行
UUID=34d87932-0eda-4748-b246-e0ca62549f4b /data ext4 errors=continue 0 0

避免硬盘拔出,无法启动

sudo mount -a 或者重启系统
挂载所有硬盘,如果没有生效的话重启即可。

1
2
3
4
5
6
7
8
9
$ df -hl
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 384M 5.4M 379M 2% /run
/dev/sdb2 55G 1.9G 50G 4% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1.8T 498G 1.3T 29% /data

风扇

原装风扇很吵,需要更换为经营风扇或者是可以调速的。进bios确认是否支持pwm调速,否则换静音风扇+减速线

A双网口,A单网口绿色主板不支持
A单网口黑色主板支持pwm,不支持 WOL

1
sudo apt install -y fancontrol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$ sudo pwmconfig 
# pwmconfig revision $Revision$ ($Date$)
This program will search your sensors for pulse width modulation (pwm)
controls, and test each one to see if it controls a fan on
your motherboard. Note that many motherboards do not have pwm
circuitry installed, even if your sensor chip supports pwm.

We will attempt to briefly stop each fan using the pwm controls.
The program will attempt to restore each fan to full speed
after testing. However, it is ** very important ** that you
physically verify that the fans have been to full speed
after the program has completed.

Found the following devices:
hwmon0 is coretemp
hwmon1 is nct6779
hwmon2 is soc_dts0
hwmon3 is soc_dts1

Found the following PWM controls:
hwmon1/pwm1 current value: 251
hwmon1/pwm2 current value: 74
hwmon1/pwm2 is currently setup for automatic speed control.
In general, automatic mode is preferred over manual mode, as
it is more efficient and it reacts faster. Are you sure that
you want to setup this output for manual control? (n) y
hwmon1/pwm3 current value: 253
hwmon1/pwm4 current value: 254
hwmon1/pwm5 current value: 255

Giving the fans some time to reach full speed...
Found the following fan sensors:
hwmon1/fan1_input current speed: 0 ... skipping!
hwmon1/fan2_input current speed: 1341 RPM
hwmon1/fan3_input current speed: 0 ... skipping!
hwmon1/fan4_input current speed: 0 ... skipping!
hwmon1/fan5_input current speed: 0 ... skipping!

Warning!!! This program will stop your fans, one at a time,
for approximately 5 seconds each!!!
This may cause your processor temperature to rise!!!
If you do not want to do this hit control-C now!!!
Hit return to continue:

Testing pwm control hwmon1/pwm1 ...
hwmon1/fan2_input ... speed was 1341 now 1340
no correlation

No correlations were detected.
There is either no fan connected to the output of hwmon1/pwm1,
or the connected fan has no rpm-signal connected to one of
the tested fan sensors. (Note: not all motherboards have
the pwm outputs connected to the fan connectors,
check out the hardware database on http://www.almico.com/forumindex.php)

Did you see/hear a fan stopping during the above test (n)?y

使用机箱背面下面的 USB 接口做群晖引导U盘,会导致关机后自动开机

长按电源键关机

主板多余一个sata接口

可以结合其配置文件中的控制策略计算合适的风扇转速,最终以PWM波的形式输出至CPU风扇以控制其转速

1
sudo apt install -y lm-sensors

检测

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
sudo sensors-detect

# 全部yes

$ sudo sensors-detect

# sensors-detect revision $Revision$
# Board: AMI Corporation Aptio CRB
# Kernel: 4.19.0-6-amd64 x86_64
# Processor: Intel(R) Celeron(R) CPU J1900 @ 1.99GHz (6/55/9)

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): Module cpuid loaded successfully.
Silicon Integrated Systems SIS5595... No
VIA VT82C686 Integrated Sensors... No
VIA VT8231 Integrated Sensors... No
AMD K8 thermal sensors... No
AMD Family 10h thermal sensors... No
AMD Family 11h thermal sensors... No
AMD Family 12h and 14h thermal sensors... No
AMD Family 15h thermal sensors... No
AMD Family 16h thermal sensors... No
AMD Family 17h thermal sensors... No
AMD Family 15h power sensors... No
AMD Family 16h power sensors... No
Intel digital thermal sensor... Success!
(driver `coretemp')
Intel AMB FB-DIMM thermal sensor... No
Intel 5500/5520/X58 thermal sensor... No
VIA C7 thermal sensor... No
VIA Nano thermal sensor... No

Some Super I/O chips contain embedded sensors. We have to write to
standard I/O ports to probe them. This is usually safe.
Do you want to scan for Super I/O sensors? (YES/no): y
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor/ITE'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/Fintek'... Yes
Found `Nuvoton NCT5532D/NCT6779D Super IO Sensors' Success!
(address 0xa20, driver `nct6775')
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor/ITE'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/Fintek'... No
Trying family `ITE'... No

Some systems (mainly servers) implement IPMI, a set of common interfaces
through which system health data may be retrieved, amongst other things.
We first try to get the information from SMBIOS. If we don't find it
there, we have to read from arbitrary I/O ports to probe for such
interfaces. This is normally safe. Do you want to scan for IPMI
interfaces? (YES/no): y
Probing for `IPMI BMC KCS' at 0xca0... No
Probing for `IPMI BMC SMIC' at 0xca8... No

Some hardware monitoring chips are accessible through the ISA I/O ports.
We have to write to arbitrary I/O ports to probe them. This is usually
safe though. Yes, you do have ISA I/O ports even if you do not have any
ISA slots! Do you want to scan the ISA I/O ports? (yes/NO): y
Probing for `National Semiconductor LM78' at 0x290... No
Probing for `National Semiconductor LM79' at 0x290... No
Probing for `Winbond W83781D' at 0x290... No
Probing for `Winbond W83782D' at 0x290... No

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no): y
Using driver `i2c-i801' for device 0000:00:1f.3: BayTrail (SOC)
Module i2c-dev loaded successfully.

Next adapter: SMBus I801 adapter at f000 (i2c-0)
Do you want to scan it? (yes/NO/selectively): y
Client found at address 0x50
Probing for `Analog Devices ADM1033'... No
Probing for `Analog Devices ADM1034'... No
Probing for `SPD EEPROM'... Yes
(confidence 8, not a hardware monitoring chip)
Probing for `EDID EEPROM'... No

Next adapter: i915 gmbus ssc (i2c-1)
Do you want to scan it? (yes/NO/selectively): y

Next adapter: i915 gmbus vga (i2c-2)
Do you want to scan it? (yes/NO/selectively): y

Next adapter: i915 gmbus panel (i2c-3)
Do you want to scan it? (yes/NO/selectively): y

Next adapter: i915 gmbus dpc (i2c-4)
Do you want to scan it? (yes/NO/selectively): y

Next adapter: i915 gmbus dpb (i2c-5)
Do you want to scan it? (yes/NO/selectively): y

Next adapter: i915 gmbus dpd (i2c-6)
Do you want to scan it? (yes/NO/selectively): y

Next adapter: DPDDC-B (i2c-7)
Do you want to scan it? (yes/NO/selectively): y

Next adapter: DPDDC-C (i2c-8)
Do you want to scan it? (yes/NO/selectively): y


Now follows a summary of the probes I have just done.
Just press ENTER to continue:

Driver `nct6775':
* ISA bus, address 0xa20
Chip `Nuvoton NCT5532D/NCT6779D Super IO Sensors' (confidence: 9)

Driver `coretemp':
* Chip `Intel digital thermal sensor' (confidence: 9)

To load everything that is needed, add this to /etc/modules:
#----cut here----
# Chip drivers
coretemp
nct6775
#----cut here----
If you have some drivers built into your kernel, the list above will
contain too many modules. Skip the appropriate ones!

Do you want to add these lines automatically to /etc/modules? (yes/NO)y
Successful!

Monitoring programs won't work until the needed modules are
loaded. You may want to run '/etc/init.d/kmod start'
to load them.

Unloading i2c-dev... OK
Unloading cpuid... OK

更新设置

1
2
3
4
5
sudo service module-init-tools restart

cat /sys/class/hwmon/hwmon3/pwm1

ls -ahl /sys/class/hwmon/hwmon3/pwm?

硬盘休眠

1
2
3
4
5
6
7
8
9
10
11
$ sudo hdparm -C /dev/sdd
/dev/sdd:
drive state is: active/idle

$ sudo hdparm -Y /dev/sdd
/dev/sdd:
issuing sleep command

newnius@local-nas:~$ sudo hdparm -C /dev/sdd
/dev/sdd:
drive state is: standby
1
2
3
4
5
6
$ vim /etc/hdparm.conf

/dev/sdc {
# 120/12 = 10min
spindown_time = 120
}

硬盘检测

1
sudo apt install -y smartmontools

UPS

山特 TG-BOX600

APC 施耐德 BK650

apcupsd

数据盘

功耗

开机 15w
裸机:12w

+ssd
空闲 1w
活动 2w
休眠 1w

基本休眠没用

加风扇
pwm +1w
满速 +2w

加5400转HDD
空闲 +3w
活跃 +4w
休眠 +1w

加7200转HDD
空闲 +5w
活跃 +6w
休眠 +1w

开机功率 28w
空闲 23w
全盘休眠 14w

测了一下功耗,正常情况下差不多在20w,加了硬盘之后30w左右。看电量统计,一天大概半度电的样子。

功耗

参考

Mac OS制作Ubuntu安装U盘

fstab

关于Linux系统如何挂载数据盘?

linux下磁盘分区、挂载知多少

No “fdisk” command in Debian wheezy

在Debian上搭建家庭NAS备忘录

fdisk – Easy way to manage disk partitions in Linux

linux下控制风扇转速

ubuntu下如何控制风扇速度?

蜗牛星际捡矿渣体验

蜗牛星际矿渣A版单网口扫盲及折腾

风扇挑选

电脑小白硬件系列 篇五:风扇怎么接——各种3pin、4pin、rgb、显卡4pin风扇接口浅析

买椟还珠—蜗牛星际的终极静音、防尘改造

树莓派硬盘自动休眠的方法

蜗牛星际改造
不能关机的问题