Rock64 Webserver / NAS project
#7
Ones the webserver was up and running I started installing / configuring my NAS part of my Rock64 project.

1)      First, I started by installing 1 HDD to the rock64 over USB 3.0 with the USB3.0 to SATA cable from the web shop here. ( https://www.pine64.org/?product=usb-3-0-...-with-uasp )
To confirm the drive was recognized I used following command
Code:
$ lsblk
In my case the drive was connected as /dev/sda
To get more info about the device and the current partitions I used
Code:
$ sudo fdisk -l /dev/sda
To use the disk I first had to reparation the disk with fdisk
Code:
$ sudo fdisk /dev/sda
Once in this “tool” I made following selections

Code:
m --> To show the full menu
g --> To create a new and empty GPT partition table
n --> To make a new partition
1 --> To give the partition number
enter --> To choose the default first sector
enter --> To choose the default last sector
w --> To save the changes and exit

After this I still needed to format the partition and choose a filesystem I have chosen for ext4
Code:
$ sudo mkfs.ext4 /dev/sda1
To confirm I used following command
Code:
$ sudo lsblk -fs
 

2)      Before I could use the disk it still needed to be mounted, first I made a folder to mount the disk on
Code:
$ sudo mkdir /media/hdd0
Once the directory is made I could mount the partition to it
Code:
$ sudo mount /dev/sda1 /media/hdd0
To confirm the partition was mounted I used following command
Code:
$ lsblk
After this I still needed to change the permissions to my rock64 instead of my root user
Code:
$ sudo chown -R rock64:rock64 /media/hdd0/
After this I could make directory’s and files in the disk
 

Used resource for 1 and 2 https://forum.pine64.org/showthread.php?tid=4925
 

3)      Because I want to use the disk as a NAS I needed to share the folder, since I have mostely windows and android machines in my home network I used SMB
First of all I installed SAMAB on the Rock64
Code:
$ sudo apt-get install samba
After installing I made a user in samba
Code:
$ sudo smbpasswd -a rock64
Once the user was made I needed to choose a password, after that I added following code to the /etc/samba/smb.conf file
Code:
$ sudo nano /etc/samba/smb.conf
// Added following code to the bottom of the file
[hdd0]
path = /media/hdd0
available = yes
valid users = rock64
read only = no
browsable = yes
public = yes
writable = yes
I saved and exited the file and restarted the smbd service
Code:
$ sudo service smbd restart
Because im running UFW I also needed to allow samba in UFW with following command
Code:
$ sudo ufw allow samba
After that I could access my share on my windows machine Big Grin
 

Used resource for 3 https://www.howtogeek.com/176471/how-to-...and-linux/
 

4)      After a few days I decide to add my second disk to the rock and make a software raid, I shutdown the rock and unplugged the first disk, plugged in a usb3.0 hub and connected the previous disk and the second disk to the hub. Once rebooted I noticed my first disk was now under /dev/sdb and the last connected disk was under /dev/sda.
So now I wanted to make a RAID1 but I didn’t want to lose my data on the previous disk.
First of all I partitioned the newly added disk
Code:
$ sudo fdisk /dev/sda
Once in this “tool” I made following selections

Code:
m --> To show the full menu
g --> To create a new and empty GPT partition table
n --> To make a new partition
1 --> To give the partition number
enter --> To choose the default first sector
enter --> To choose the default last sector
w --> To save the changes and exit
To make the software raid in linux I used MDADM, so I installed this
Code:
$ sudo apt-get install mdadm
Once installed I created a RAID1 with the last added disk and a “missing” disk
Code:
$ sudo mdadm --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sda1 missing
After this I still needed to format the partition and choose a filesystem I have chosen for ext4
Code:
$ sudo mkfs.ext4 /dev/md0
Before I could use the RAID it still needed to be mounted, first I made a folder to mount the RAID on
Code:
$ sudo mkdir /media/raid
Once the directory is made I could mount the partition to it
Code:
$ sudo mount /dev/md0 /media/raid
To confirm the partition was mounted I used following command
Code:
$ lsblk
After this I still needed to change the permissions to my rock64 user instead of my root user
Code:
$ sudo chown -R rock64:rock64 /media/raid/
Now I needed to copy al the files from my hdd0 to my raid
Code:
$ sudo cp -a /media/hdd0/  /media/raid/
Once this was don I could reparation my hdd0 again
Code:
$ sudo fdisk /dev/sdb
Once in this “tool” I made following selections
Code:
m --> To show the full menu
g --> To create a new and empty GPT partition table
n --> To make a new partition
1 --> To give the partition number
enter --> To choose the default first sector
enter --> To choose the default last sector
w --> To save the changes and exit
Once the disk was again clean I could add it to my raid
Code:
$ sudo mdadm /dev/md0 --add /dev/sdb1
To follow the process of the disk syncing I used
Code:
$ watch  cat /proc/mdstat
And after a few hours my disk where synced and I had a software RAID1
The only thing I needed to extra was change the /etc/samba/smb.conf file
Code:
$ sudo nano /etc/samba/smb.conf
// Added following code to the bottom of the file
[raid]
path = /media/raid
available = yes
valid users = rock64
read only = no
browsable = yes
public = yes
writable = yes
I saved and exited the file and restarted the smbd service
Code:
$ sudo service smbd restart
 

Used resource for 4 https://unix.stackexchange.com/questions/281654/convert-a-non-boot-single-hdd-to-raid-1-without-deleting-it
 

5)      The disks I used in my rock64 came from an old Readynas 102, now I had the idea to use this readynas as a backup for my Rock. First I installed sshfs
Code:
$ sudo apt-get install sshfs
Because I don’t want to use my password every time I would connect to my backupserver I made a ssh-key

Code:
$ sudo ssh-keygen -t rsa
when asked for a passphrase I leaved it empty, now the ssh key file is made I copied it to my backup server
Code:
$ sudo ssh-copy-id -I ~/.ssh/id_rsa.pub root@192.168.178.32
Before I could use the backupserver it still needed to be mounted, first I made a folder to mount the backupserver on
Code:
$ sudo mkdir /media/backup
Once the directory is made I could mount the sshfs to it
Code:
$ sudo sshfs root@192.168.178.32:/data/Backup /media/backup/
To confirm the partition was mounted I used following command
Code:
$ sudo df -h
After that my backup server was mounted and I could access it from inside my rock and copy files to it under the root user
 

Used resource for 5 https://www.cyberciti.biz/faq/how-to-mou...-on-linux/
 

6)      I also wanted an off-site backup in the cloud, since my cloud service only support webdav I needed to configure it as a davfs, first of all I installed davfs2
Code:
$ sudo apt-get install davfs2
To make sure I could use webdav i ranned
Code:
$ sudo dpkg-reconfigure davfs2
And answerd “YES” after that I added root and rock64 to the group
Code:
$ sudo usermod -a -G davfs2 root
$ sudo usermod -a -G davfs2 rock64
Because I don’t want to use my password every time I would connect to my cloud I saved my credentials in the file ~/.davfs2/secrets
Code:
$ sudo nano ~/.davfs2/secrets
// Added following code to the bottom of the file
#Stack by transIP
https://mikedhoore.stackstorage.com/remote.php/webdav mikedhoore MyPass
To make sure the file haves the right permissions I did
Code:
$ sudo chmod 600 /etc/davfs2/secrets
$ sudo chown root:root /etc/davfs2/secrets
Before I could use the cloud it still needed to be mounted, first I made a folder to mount the cloud on
Code:
$ sudo mkdir /media/stack
Once the directory is made I could mount the davfs to it
Code:
$ sudo mount -t davfs https://mikedhoore.stackstorage.com/remote.php/webdav/ /media/stack
To confirm the partition was mounted I used following command
Code:
$ sudo df -h
After that my backup server was mounted and I could access it from inside my rock and copy files to it.
 

Used resource for 6 https://ajclarkson.co.uk/blog/auto-mount...pberry-pi/ and https://wiki.archlinux.org/index.php/Davfs2
 

7)      After a reboot the made mounts from raid, backup and stack disappeared so I needed to save them in /etc/fstab
Code:
$ sudo nano /etc/fstab
// Added following code to the bottom of the file
UUID=f995d3c4-c9e3-48bc-a021-e099200308f6 /media/raid ext4 defaults 0 0

root@192.168.178.32:/data/Backup /media/backup fuse.sshfs delay_connect,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/rock64/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000 0 0
 
https://mikedhoore.stackstorage.com/remote.php/webdav/ /media/stack davfs x-systemd.requires=network.target,auto,nouser 0 0
To find the UUID of md0 I used
Code:
$ lsblk
To mount the webdav I still always have to give following code to get mounted after a reboot
Code:
$ sudo mount -a
 

Used resource for 7 https://www.howtogeek.com/howto/38125/ht...s-it-work/
 

8)      Since I only want to back up the files that are changed I used rsync to back up from my rock to my backup server and cloud so I stared by installing rsync.

Code:
$ sudo apt-get install rsync
Since I also don’t want to backup manually I enter following command in the crontab
Code:
$ sudo crontab -e
// Added following code to the bottom of the file
#Rsync every hour from raid(sda1 + sdb1 = md0) to backup(sshfs)
10 * * * * rsync -avzh /media/raid/ /media/backup/ >> /var/log/Mike/rsyncBackup.log
#Rsync every day from raid(sda1 + sdb1 = md0) to Stack cloud
0 3 * * * rsync -avzh /media/raid/ /media/stack/BACKUP_NAS/ >> /var/log/Mike/rsyncStack.log
So now my rock backups every hour to my backup server and once a day to my cloud also the results are written in .log files
 

Used resources for 8 https://www.tecmint.com/rsync-local-remo...-commands/ and https://kvz.io/blog/2007/07/29/schedule-...g-crontab/
 

 
After all this I now have a working NAS that I can access in my home network over SMB, it also backups on premises and off premises in the cloud.
  Reply


Messages In This Thread
Rock64 Webserver / NAS project - by mikedhoore - 03-21-2018, 09:59 AM
RE: Rock64 Webserver / NAS project - by tllim - 04-02-2018, 09:44 PM
RE: Rock64 Webserver / NAS project - by mikedhoore - 04-21-2018, 07:09 AM
RE: Rock64 Webserver / NAS project - by tazthecat - 07-19-2018, 05:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Are HW design files available for ROCK64? irenek 3 4,800 12-11-2023, 09:31 PM
Last Post: tllim
  Rock64 is unreliable after 3 years of service - power problem? ReleaseTheGeese 0 338 11-23-2023, 05:05 AM
Last Post: ReleaseTheGeese
  Rock64 PoE compatbility with Pi4 Hatt recent Single Board Computer offering from PINE kharak 1 1,076 04-26-2023, 11:38 PM
Last Post: tllim
  Case for the rock64 that supports the POE hat. o1CRiMSON1o 0 628 03-21-2023, 03:48 PM
Last Post: o1CRiMSON1o
Brick Rock64 usb2.0 Power Control Floating GPIO Tutorial Files & Notes MarkHaysHarris777 6 13,247 01-15-2023, 10:36 AM
Last Post: ds00
  rock64 totally brick dakobg 2 1,755 11-07-2022, 05:45 PM
Last Post: olivercfc
  3D-Printable Button Pegs for the ROCK64 Aluminium Case CounterPillow 2 3,537 08-04-2022, 01:31 AM
Last Post: Vicky Weimann PhD
  Where can I find the ROCK64 POE HAT Zoz 2 2,635 06-08-2022, 12:44 AM
Last Post: Zoz
Smile wooden case for ROCK64 killor 13 16,562 03-04-2022, 06:56 AM
Last Post: killor
  1wire DS18b20 on Rock64? mypineme 6 7,064 09-28-2021, 03:07 PM
Last Post: TRS-80

Forum Jump:


Users browsing this thread: 1 Guest(s)