Init a RPi3B+ (and boot from USB HDD)¶
records…
Hardware¶
- RPi3B+ x1
- TF 16G x1
- USB HDD 1T x1
- USB Keyboard x1
- USB Mouse x1
System Image¶
Switch to: Boot from USB HDD¶
- Write the image to TF card.
- Add
program_usb_boot_mode=1
to filecmdline.txt
- Insert the TF card, power on for about 60 seconds, power off, remove the TF
- Write the image to USB HDD
- Adjust partitions, by
DiskGenius
, on win10:- 0: keep the
boot
, do not edit it - 2: adjust
rootfs
to32GB
, and move it to the end, end, end - 1: create an
ext4
partition, with the rest all spaces, nameddata
- 0: keep the
Configurations¶
- Boot to
Raspbian desktop
, follow the guide, then reboot - Terminal:
- sudo apt update
- sudo apt upgrade
- Pi Configuration
- rename
- switch boot to CLI, will disable auto login at the same time
- enable SSH
- reboot
Mount partition #1¶
Append one line to /etc/fstab
, before it, make sure /dev/sda3
is correct:
/dev/sda3 /data ext4 defaults 1 1
Reboot
Change /data owner to pi¶
$ sudo chown pi /data
Don’t allow kworker eats CPU¶
System will check TF slot every 500ms(green led blinks), during it is blank, that will eat your CPU time.
ref: | https://github.com/raspberrypi/linux/issues/2567 |
---|
Check CPU usage:
$ top
top - 07:43:51 up 7:55, 1 user, load average: 0.33, 0.29, 0.28
Tasks: 100 total, 2 running, 57 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.1 us, 1.3 sy, 0.0 ni, 98.6 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1000180 total, 771736 free, 59604 used, 168840 buff/cache
KiB Swap: 102396 total, 102396 free, 0 used. 876512 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
29 root 20 0 0 0 0 R 8.9 0.0 44:15.23 kworker/0:1
1670 pi 20 0 8128 3288 2764 R 1.0 0.3 0:01.59 top
...
If kworker eats 8-13% CPU, append one line to /boot/config.txt
:
# With no TF card
dtoverlay=sdtweak,poll_once
Reboot, OKay.
hd-idle¶
To protect the HDD, suspend when idle.
ref: | http://www.mkitby.com/2016/05/15/raspberry-pi-nas-manage-hdd-power/ |
---|
Check support:
$ cat /proc/diskstats
1 0 ram0 0 0 0 0 0 0 0 0 0 0 0
1 1 ram1 0 0 0 0 0 0 0 0 0 0 0
1 2 ram2 0 0 0 0 0 0 0 0 0 0 0
1 3 ram3 0 0 0 0 0 0 0 0 0 0 0
1 4 ram4 0 0 0 0 0 0 0 0 0 0 0
1 5 ram5 0 0 0 0 0 0 0 0 0 0 0
1 6 ram6 0 0 0 0 0 0 0 0 0 0 0
1 7 ram7 0 0 0 0 0 0 0 0 0 0 0
1 8 ram8 0 0 0 0 0 0 0 0 0 0 0
1 9 ram9 0 0 0 0 0 0 0 0 0 0 0
1 10 ram10 0 0 0 0 0 0 0 0 0 0 0
1 11 ram11 0 0 0 0 0 0 0 0 0 0 0
1 12 ram12 0 0 0 0 0 0 0 0 0 0 0
1 13 ram13 0 0 0 0 0 0 0 0 0 0 0
1 14 ram14 0 0 0 0 0 0 0 0 0 0 0
1 15 ram15 0 0 0 0 0 0 0 0 0 0 0
7 0 loop0 0 0 0 0 0 0 0 0 0 0 0
7 1 loop1 0 0 0 0 0 0 0 0 0 0 0
7 2 loop2 0 0 0 0 0 0 0 0 0 0 0
7 3 loop3 0 0 0 0 0 0 0 0 0 0 0
7 4 loop4 0 0 0 0 0 0 0 0 0 0 0
7 5 loop5 0 0 0 0 0 0 0 0 0 0 0
7 6 loop6 0 0 0 0 0 0 0 0 0 0 0
7 7 loop7 0 0 0 0 0 0 0 0 0 0 0
8 0 sda 17021 1174 1520519 302550 51991 7860 10477700 1732050 0 237770 2034780
8 1 sda1 146 199 4589 1050 3 0 4 10 0 770 1060
8 2 sda2 16756 923 1507888 299660 5031 7169 344976 359560 0 79220 659400
8 3 sda3 95 52 6994 1660 45719 691 10132720 1371990 0 163900 1373650
Install dependencies:
$ sudo apt install build-essential fakeroot debhelper -y
Download:
$ wget http://sourceforge.net/projects/hd-idle/files/hd-idle-1.05.tgz
Unzip and cd in:
$ tar -xvf hd-idle-1.05.tgz && cd hd-idle
Install:
$ sudo dpkg-buildpackage -rfakeroot
$ sudo dpkg -i ../hd-idle_*.deb
Check for support:
$ sudo hd-idle -i 0 -a sda -i 300 -d
probing sda: reads: 1520519, writes: 10949452
^C
Ctrl + C
to break.
Edit conf:
$ sudo nano /etc/default/hd-idle
Modify:
START_HD_IDLE=true
Append for idle, after 600
seconds:
HD_IDLE_OPTS="-i 0 -a sda -i 600"
Restart the service:
$ sudo service hd-idle restart