NAS installation using an ODROID-HC4 and armbian.
To be able to boot clean Armbian mainline based u-boot / kernel experiences, you need to remove incompatible Petitboot loader that is shipped with the board. From the Petitboot, go for “Exit to shell” and these commands to remove the Petitboot:
# flash_eraseall /dev/mtd0
# flash_eraseall /dev/mtd1
# flash_eraseall /dev/mtd2
# flash_eraseall /dev/mtd3
This will make your SPI flash memory empty and would start from SD on next boot.
From the documentation:
- Download the OS build from the product page (I went with the Armbian Bullseye version).
- Put the OS on an SD card using balenaEtcher (just download the exe for a single use, also the AUR is broken).
- Put the SD card in the odroid and boot.
- Set root pwd, shell and first user.
Still from the same documentation
nmcli con mod "Wired connection 1"
ipv4.addresses "HOST_IP_ADDRESS"
ipv4.gateway "IP_GATEWAY"
ipv4.dns "DNS_SERVER(S)"
ipv4.dns-search "DOMAIN_NAME"
ipv4.method "manual"
Note: I did not change the dns (maybe I should ?), otherwise I used:
HOST_IP_ADDRESS: 192.168.11.7/24
IP_GATEWAY: 192.168.11.1
Install exFAT packages:
apt install exfat-utils exfat-fuse
Note: exFAT because fat32 has a 4.2GB file size limit, and NTFS doesn't have a super good support on linux.
fdisk /dev/sda
mkfs.exfat /dev/sda1 -n NAS_PUBLIC
mkdir /storage
mkdir /storage/nas_public
mount /dev/sda1 /storage/nas_public
Then modify the fstab so that they are mounted on boot:
# /dev/sdb1 LABEL=NAS_PRIVATE
UUID=2C47-2044 /storage/nas_private exfat defaults,rw,noatime,uid=1000,gid=1000 0 0
# /dev/sda1 LABEL=NAS_PUBLIC
UUID=29FD-8E5A /storage/nas_public exfat defaults,rw,noatime,uid=998,gid=998 0 0
Note: Here 1000 is the uid of user "hoel" who is the only one allow to access the private nas, and 998 is the uid of "samba-public", used to access the public NAS.
A detailed tutorial can be found here.
apt update
apt ugrade
apt install samba
Check that it was installed properly with:
samba -V
systemctl status smbd
Add a samba-public user for the public drive, and register the "hoel" user for the private drive:
sudo useradd -rs /bin/false samba-public
sudo chown samba-public /storage/nas_public
sudo chmod u+rwx /storage/nas_public
sudo smbpasswd hoel
The workgroup is WORKGROUP by default, no need to change it.
Add this at the end of the file
[PublicNAS]
path = /storage/nas_public
available = yes
browsable = yes
public = yes
writable = yes
force user = samba-public
[PrivateNAS]
path = /storage/nas_private
available = yes
browsable = yes
public = no
writable = yes
valid users = hoel
Check that the config is correct:
testparm
Restart the samba server:
systemctl restart smbd
systemctl status smbd
Optional: Can check that it works fine locally with:
apt install smbclient
smbclient -L localhost
sudo mount -t cifs //<server_ip>/<share_name> <mountpoint>
Uses S.M.A.R.T. and hdparm, they should already be installed.
To see what your drive support: sudo hdparm -I /dev/sda.
To see how fast a drive delivers data: sudo hdparm -t /dev/sda.
To make a drive to spin-down after 15min of inactivity: hdparm -B 254 -S 242 /dev/sda.
To spin down a drive immediately: hdparm -y /dev/sda
After checking that the disk spins down properly, make the change persistent using a udev rule. (You can wait and look at the drive himself (heat, noise) or use smartctl -i -n standby /dev/sda)
Systems with multiple hard drives can apply the rule in a flexible way according to some criteria. For example, to allow all rotational drives to spin down after 15min:
In /etc/udev/rules.d/69-hdparm.rules:
ACTION=="add|change", KERNEL=="sd[a-z]", ATTRS{queue/rotational}=="1", RUN+="/usr/bin/hdparm -B 254 -S 242 /dev/%k"
Worth trying if hdparm doesn't work, also has nice options.
sudo systemctl start hd-idle.service
sudo systemctl enable hd-idle.service
sudo systemctl status hd-idle.service
sudo hd-idle -i 0 -a /dev/sda -i 1200 -l /var/log/hd_idle.log
