Showing posts with label NAS. Show all posts
Showing posts with label NAS. Show all posts

Tuesday, January 9, 2024

Samba from Raspberry Pi - Rejected an insecure guest logon [Solved]

This post is about troubleshooting connectivity issues to Raspberry Pi when accessing an SMB shared path.

Context

The aim is to expose a NAS from Raspberry Pi using Samba. It should be accessible only with authentication. The good thing in Windows is that it disables the anonymous access by default¹.
For authenticating there is a user created in Raspberry Pi. Below is the design.

Problem

When accessing SMB share from Windows 10 machine, it error out with

"\\raspberrypi.lan is not accessible. You might not have permission to use this network resource. Contact the administrator of this server to find out if you have access permissions.

You can't access this shared folder because your organization's security policies block unauthenticated guest access. These policies help protect your PC from unsafe or malicious devices on the network."

The event viewer shows the below.

Rejected an insecure guest logon.

User name: <user name>

Server name: \raspberrypi

Guidance:

This event indicates that the server attempted to log the user on as an unauthenticated guest and was denied by the client. Guest logons do not support standard security features such as signing and encryption. As a result, guest logons are vulnerable to man-in-the-middle attacks that can expose sensitive data on the network. Windows disables insecure guest logons by default. Microsoft does not recommend enabling insecure guest logons.

Analysis

It says the attempt is made as an unauthenticated user. But the dialog box for login was present and entered the username and password.

Root cause

The credentials were wrong. When the password was wrong, instead of telling wrong user name or password, it fall back to unauthenticated anonymous user access and that is rejected.

Why it takes that fall back?

It is bacause of a setting in Samba. The setting name is "map to guest". The default value is 'Never'² but the value was somehow different.

Solution / Fix

Make sure the smb.conf has "map to guest user" = 'never', if we want to enforce only authenticated users accessing the share. May be we can leave it as the default value is 'never'.

More more details refer Ansible scripts³ in previous post in this blog.

Happy debugging...

References

Tuesday, December 12, 2023

Setting up home NAS - Part 7 - Automate using Ansible

This is the continuation of the "Setting up home NAS" series. Better read the below posts to get context.
Setting up home NAS - Part 7 - Automate using Ansible

Introduction

Previous posts have manual instructions to set up the Raspberry Pi to function as a NAS and Plex media server. As we all know manual steps are error-prone and difficult to replicate. This post is about automating the deployment and manual configuration steps.

Architecture

There are different approaches to automating the machine configuration and software deployment.

The easy way is to simply write scripts and get them executed in the target machine itself. Here target is Raspberry Pi and Ansible supports this method and lets us install it on Raspberry Pi.

Secondly, agent-based¹ where we first manually install an agent software that polls the central repository of configuration. In case there are any changes, it will apply those to the host machine where it is running.

Another way is the opposite of agent-based. A controller machine pushes the changes to the target machine using some remoting technology. Here the target is Raspberry Pi


Here we are using an agentless method using a tool called Red Hat Ansible². Ansible is a well-known tool in IT automation workflows.

SSH to Pi with keys 

Since there is no agent to listen in, the controller machine needs to use a way to remote into the target machine to be configured. Ansible uses SSH³ to do the same.

The default way is to run the Ansible scripts and it will ask for login details. For Raspberry to set up that is fine. But there are ways to avoid it by using the SSH public-private key pairs.

There are clearly documented ways to establish a passwordless login to RasPi⁴ using SSH keys. But there are chances of things going wrong and troubleshooting SSH keys to authenticate should be a separate post on its own.

Installing Ansible

It requires Python to be installed. The installation of Ansible is straightforward and well documented⁵.

Source code

Enough theory. Since it involves scripts that can be enhanced later, it is better to keep in a source control repository. Below is the source code repo link to GitHub.

https://github.com/joymon/ansible-raspberry-home-nas-plex

The readme.md is pretty much updated.

One thing pending is the setting up of the user password that is used to access the shared path from Raspberry.

It will be added soon and updates will be pushed to the same repo. 

Ansible in Windows v/s Linux

One drawback is that Ansible is not very compatible with Windows as a controller. So we have to use the WSL2 feature of Windows to manage the target Raspberry Pi.

Reference

Tuesday, December 5, 2023

Setting up home NAS - Part 6 - Raspberry Pi as Plex Media Server

This is the continuation of the "Setting up home NAS" series. Better read the below posts to get context.
Setting up home NAS - Part 6 - Raspberry Pi as Media Server using Plex (This post)

Introduction

This post discuss how to enable Plex media server on Raspberry Pi and use within home network.

Approach

At high level we have to do the below steps
  • Enable Plex package sources and install Plex
  • Browse to http://raspberrypi:32400/web and associate with our Plex account
  • Configure the Plex to include our media folders
Let's start.

Enable Plex package sources and install Plex

Below goes the Linux commands to do the same. It needs to be run on Raspberry.

sudo apt-get update
sudo apt-get upgrade
# Enable the package install over https
sudo apt-get install apt-transport-https
# Adding the Plex GPG key
sudo curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
# Add the Plex package sources to the apt.
# It basically creats a file with the deb ...
sudo echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
# We’re going to update our package list and install from the newly added repository.
sudo apt-get update
sudo apt-get install plexmediaserver

Added some comments to understand. In case of queries, please add comments. Once Plex is installed we need to configure.

Browse and associate with Plex Account

First naviate to http://raspberrypi:32400/web . The port 32400 is the default port for Plex. Please make sure the protocol prefix is http not https. It will load the screen as follows.


Note that the URL changed from our RaspberryPi host name to app.plex.tv after some redirects. Click on sign-in and use approprate method. Once signed in, it will redirect back to the page as shows below.

At this point our local RaspberryPi hosted Plex is connected to the credential we provided.


This is simply saying how it works. Once you click on got it. It asks for the Plex pass.


It we can, better support them by buying the pass. Yes, it supports totally free mode as well. We can click on close button to skip payment. Up on closing it will take to server setup.

We can see it can expose our media accissible from internet. In order to do that we need a router that is supporting UPnP or NAT-PMP feature. Also the port forwarding to 32400 ¹. This tutorial is moving forward to restrct access only with the home network, not internet. In case we change our mind, it can enable later as well.

The next step is to add our media folders to the Plex.

Click on the add library 

This tutorial is adding an audio library of type Music.
The library name will be Music. Click next.
Click on 'Browse for Media Folder' to get the media folder selection screen.

Browse the folders or enter the path to our folder containing audio files. This is the path in Raspberry. The path in the screenshot is where the external hard drive is mounted that contains files. Click on the "Add" button and will land on the next screen.
Click on the add library to add finish adding folder to Plex.

The same task of adding folder(s) can be done after completing the initial setup also. Click on Next.

At last we are done by clicking the "Done" button. It is time to navigate to the Plex that we setup. Browse to http://raspberrypi:32400/web and we will reach the screen as below. 
Again please note the Url protocol is http not the secure https.
What ever content we are seeing in our home page is free to watch from Plex. They change over time. These are not from our Raspberry Pi server. In order to see the personal contents hosted on Raspberry Pi, click the More button.
Here comes our personal content. Remember we created the Music library during the setup, that is what visible here.

Now it is time to access it via the Plex web site. Naviagate to https://app.plex.tv in the browser.
We can see our personal contents added to Raspberry Plex server here as well. Even the web site is app.plex.tv, it is able to get data from Raspberry due to the connection we established between our Plex credentials and the Plex server during the setup.

In case there are issues like secure connection issue as shown above, we need to wait till the DNS is propagated. Plex is using some documented magic² to retrieve the contents from Raspberry Pi to their web site and apps through our home network.
Since it is magic sometimes it won't work due to specifics of settings in our network such as router configuration. If all works fine, we can browse https://app.plex.tv and view the contents. Also, it works with the other  Plex app supported media players such as smart TVs, mobiles etc...

Configure to include our media folders

If we need to add other folders to Plex, mouse over the name of server (here it is Raspberrypi) use the + button and point to the right media folders in Raspberry Pi.

Media organization

Note that when we add the folder, Plex has to do indexing behind the scene to a database³. Depending on the storage speed and Raspberry specs, indexing time varies. After indexing only the media files will start showing up in the UI.
When we add new media files or remove, we need to run scanning⁴ again to update the Plex index.

If there is more interest, have a look at the below references. Have fun with Plex.

References

Tuesday, November 7, 2023

Raspberry Pi - Fixing NAS (via SMB) slowness

This is a continuation of the Home NAS series, especially on how to increase the speed. The NAS is set up on a Raspberry Pi 4 B model. One of the older posts was debugging of NAS slowness and it concluded that the WiFi-5 is the bottleneck. Either Raspberry needs to be connected via cable or needs to use WiFi-6. Since the WiFi-6 is not natively supported by the RasPi the only option left was to connect via wire but it requires cabling through walls which is really a high effort. The cable-based internet connection is on the main level and the data center is upstairs. The data center here refers to a small rack where RasPi,2 external hard disks, and another laptop are sitting and running without GUI.

Move to 5G home internet

Fortunately or unfortunately the coaxial cable-based internet provider Xfinity increased their pricing which triggered the search for better options. Very quickly it landed on 5G home internet providers. Cheaper in price, ultra-fast connection in my area, is portable, has a WiFi-6 router built-in, etc...

Why T-Mobile?

There is no affection towards them also please note that I am not affiliated with T-Mobile in any way also this post is not sponsored by them. It is cheaper and one of my friends has it and has given good feedback. Also, it has 2 ethernet ports which seems normal in any modem-router combo.

Speed tests

As usual, I checked the speed using the same iperf3 tool before installing the 5G gateway. This is important as our previous test results may not be true now.

Yes, it is still slow. This will give a max of 10 MB/s only when copying files from NAS.

New setup

The RasPi also the client machine connected via wire and the readings are below.

Wow definitely higher than expected. It is time to copy a file and check the speed.
Yes, it is faster. This concluded that the SMB or anything in the RasPi or OS was not the problem. The network was the problem.

The Wi-Fi 6 test

Lastly, the Wi-Fi 6 test was also performed.

It is given great performance but not to the expected level. Anyway, the Wi-Fi was kind of free. It is wise to invest in a Wi-Fi 7 router when it arrives at an affordable cost after standards are finalized.

The table below is for reference.

RasPi NetworkDestination Networkiperf3 reading
Wi-Fi 5Wi-Fi580 Mbits/sec
WiredWired771 Mbits/sec
WiredWi-Fi6394 Mbits/sec

Bonus screenshot below that shows the internet speed test.

Tuesday, August 1, 2023

Raspberry Pi - Why my NAS (via SMB) is slow

Problem

As seen below, when I want to move files to and from my NAS, I DIYed. It was a little better before I moved to the new house.

Specs

  • Raspberry Pi 4 4GB is hosting the NAS
  • Both RasPi and client Windows machines are in WiFi 5 (In the old 1BHK apartment all were nearby and used LAN cable)
  • RasPi is hosting another service such as Plex.
  • Seagate Backup Plus 8TB HDD (not SSD) connected to usb3
  • HDD uses NTFS file system than Linux native etx4
  • Uses SMB3 protocol
There are many guesses or options people are talking about on the internet, from converting NTFS to ext4 to buying a dedicated NAS device, etc...Let us go the scientific debugging route.

Hypotheses

Slow HDD access

There is a bottleneck in the connection between HDD and the RasPi.

Testing

There is a utility called hdparam in Linux to test the connectivity. Below goes the result.

Status

Rejected as it is showing better numbers.

Slow network connection

Due to the WiFi 5, it is slow in communicating between machines

Testing

There is a utility called iperf3 to test the network speed.

iperf3 to local network
iperf3 test to a public server

Result

The hypothesis is true that connectivity is the bottleneck. Either upgrade to use WiFi 6 which RasPi 4 doesn't support out of the box as well as most of my machines.

Next steps

Have some way to connect the RasPi and possible machines via ethernet cable. The wiring may be required.

Tuesday, March 22, 2022

Setting up home NAS - Part 5 - e-mailing rsync report

This is the continuation of the "Setting up home NAS" series. Better read the below posts to get context.

Setting up home NAS - Part 5 - e-mailing rsync report (This post)

Introduction

In the previous post, we saw how a RaspberryPi can be used to build locally redundant NAS. We used rsync command to copy folders and files from the primary hard disk to the secondary. There was no way to monitor whether it works every day. This post is to explain a monitoring mechanism that is nothing but sending a summary mail at end of every sync operation daily.

Approach

The high-level solution goes as follows
  • Have the rsync commands output logs to a folder
  • Merge the individual rsync reports into a single file by taking only what we need. This is what we are going to email every day. Not the raw rsync output.
  • Send the report using the appropriate email provider. 

Prepare the report

This includes the generation and formatting of rsync report

rsync to output logs

The rsync command that we saw in the previous post needs to be modified a little bit as follows

rsync /media/usbseagate1tbc/media/ /mnt/router/media/ -av --progress --delete --out-format="%t %f %''b" >> "/var/log/j3dnas/$(date +%F)/Media.log" 2>&1

This means the output of rsync will be saved to a dated folder with the required format. The path needs to be changed as per our setup. 

The rsync command has a lot of options to choose the log format. Experiment with those to tune the format.

create directory if not exist

In case the directory named with the current date is not there, create it as follows.

mkdir "/var/log/j3dnas/$(date +%F)" -p

Merge rsync logs with grep

If there are multiple folders we are syncing it will produce multiple log files. Those can be merged using the below simple grep command.

grep "$(date +%Y/%m/%d)\|deleting\|error\|failed" --no-filename /var/log/j3dnas/$(date +%F)/*.log >> "/var/log/j3dnas/$(date +%F)/status.txt"

grep has many options similar to rsync. Explore to tune the merge output. Before appending the logs add the subject line. The mailing libraries will take the first line as the subject of the mail.

echo -e "Subject: J3D Family NAS rsync status $(date +%F)\r\n" >> "/var/log/j3dnas/$(date +%F)/status.txt"

The merged status.txt file is what we will be sending in the email.

Sending eMail

Choosing mail provider

Gmail comes to our mind when we think about mails. We can use it to send mails here. It uses 587 port. Based on our experience it can be any mail provider. The main point to consider is they support SMTP to send mails.

Once the service provider is decided, create a new email account or use any existing account that is already in use to send these types of notifications. 

Mailing library

Next, we need to decide on what email library/command to be used. Personally, I started with ssmtp but later I found that ssmtp won't work in the latest Raspberry Pi. Finally ended up with msmtp. More on how to send mail from RasPi using msmtp can be found here. The credentials need to be stored in the /etc/msmtprc file.

In case there are issues in using the plain password of the email account, use the app password method of Google to send the email.

cat /var/log/j3dnas/$(date +%F)/status.txt | msmtp  --debug --from=default -t joymon@gmail.com

The command to send mail will be like the above.

Final script

The final script will look something like the below.

#!/bin/bash

mkdir "/var/log/j3dnas/$(date +%F)" -p

# rsync and log output to datewise folder

rsync /media/usbseagate1tbc/users/ /mnt/router/users/ -av --progress --delete --out-format="%t %f %''b" >> "/var/log/j3dnas/$(date +%F)/users.log" 2>&1

rsync /media/usbseagate1tbc/Media/ /mnt/router/Media/ -av --progress --delete --out-format="%t %f %''b" >> "/var/log/j3dnas/media_$(date +%F)/Media.log" 2>&1

# Push the email subject and modified file list to the status file

echo "Subject: J3D NAS Sync Status $(date +%F)" > "/var/log/j3dnas/$(date +%F)/status.txt"

grep "$(date +%Y/%m/%d)\|deleting" /var/log/j3dnas/$(date +%F)/*.log >> "/var/log/j3dnas/$(date +%F)/status.txt"

# Send mail

cat status.txt | msmtp  --debug --from=default -t joymon@gmail.com

Tuesday, July 13, 2021

Setting up home NAS - Part 4 - Raspberry Pi to build locally redundant NAS for home

This is the 5th post in the "Setting up home NAS" series. Below are the previous posts. It is not required to read previous posts to understand this. But that gives some background on this series.

Introduction

I was running below model for the home NAS system. My main contributor is the video category. My DJI Osmo Pocket produces high-bitrate videos. Also the RAWs.
  • Primary
    • A router attached USB drive working as NAS. \\192.168.1.1\share. It is of 1TB capacity
    • Sync the files to my personal computer that has a 500GB drive. So effectively getting only 500GB which are backed up. SyncToy is working fine for on-demand sync
  • Secondary (after publishing to YouTube)
    • Combine all the raw videos to single and upload to YouTube in private visibility
    • One back up to another external disk that has 2TB.
    • That means during editing time, 2 copies are in the router attached USB drive and personal laptop. After publishing, one uploaded to YouTube and the other copy in the different 2 TB hard disk.
As the COVID-19 pandemic slowed down and places got opened, I got chances to visit more places. Meaning more files to primary storage. One trip brings close to 10Gigs. The 500GB limit is almost reached its 3/4th capacity.

Problem

All my previous posts were explaining a problem and a solution. Every time a new problem. This time it is again going to reach the capacity and I had to do something to increase NAS storage space. As always I need two copies of files to be kept. Not an enterprise-grade NAS.

Requirement

This time I did some requirement engineering. Its nothing but looking at the past on how much data I was generating and forecasted how much more I would be in 

Below are some facts I could see
  • After I bought DJI Osmo Pocket there are a lot of videos coming out from trips
  • One trip produce 10GB on average
  • There are around 1.5 trips avg we are making per month. ~15GB
  • We shoot some videos at home as well. 2.5-3 GB
  • Adding the above + a buffer of 2GB ~ 20GB per month ~ 240GB/year ~ 1200GB/ 1.2TB for 5 years
    • Buffer is required for technical video downloads and anything which may come on our way.
  • There have to be 2 copies resulting in 2,400 GBs. But once published one backup is in YouTube itself with visibility private. So the final requirement is 1.8TB
There can be 2 systems similar to what I have now. Once published the videos can be moved to secondary.

Options

Is it time to think big or just add more drives? My YouTube channels are still in it's infancy. No hope to get monetized in the near future. The google ads revenue from Blogs is just enough to renew the https://joymononline.in site.

If I spend more and I lose interest in YouTubing, there will be trips but just photos coming out from those. Photos can easily be stored in 2 places by using Google Photos and one hard drive.

Currently, I have one more 1TB internal hard disk which is taken from the personal laptop when it was upgraded to SSD. Total of 1 TB hard disks x2, 2 TB hard disk x 1, and 500 GB on a personal laptop.
Below are the options I could find 
  1. RaspberryPi 4 or a similar low-powered device. Connect 1 TB hard drives to it and use as primary. Secondary continue as it
  2. Dedicated NAS device.
  3. Build a server machine by sourcing refurbished parts.
  4. Store in the cloud. OneDrive/Google drive etc...
If the budget is not a constraint, I would be going with the cloud option only. 

Solution

Finally decided to go with RaspberryPi 4. Below are the rationale
  • Its low power
  • It can be used for something else
    • If I lose interest in Youtubing which reduces the data generation.
    • If the OneDrive or Google Drive drastically reduce their price for me to afford for 2TB.
    • If our total family income increases and gets more budget to tech things cloud storage would be affordable. Yes, we do some family budgeting on the expenses. It is a big topic on its own
  • I am already planning to learn Linux and would like to learn the shell way. Why don't I learn with my own problems?
  • To advance my career, I would like to learn more about enterprise IT concerns. Dealing with my own problems would be a good starting point
  • Obviously, my requirement of 1.8TB for the next 5 years can be satisfied with this setup. The only problem would be the slow publishing of videos which causes more videos to stay in primary storage which has only 1TB capacity.
The architecture would be similar to what I am using now
  • Primary storage
    • 1TB connected to RPi, expose as \\SMB shared path
    • Backup 1TB attached to the router. 
    • Daily sync RPi connected the drive to the router attached one
    • We will be seeing why can't I just connect 2 HDDs to RPi 4 which has 2 USB 3 ports
  • Secondary
    • Same setup as of now

Home NAS using Raspberry Pi

Finally, we are discussing the business. Let us see what are the decisions, steps and issues faced.

Decisions

There are some decisions to be made

Size of RPi

The RPi 4 comes in different sizes based on the RAM. Many users say it requires only 2 GB to run as NAS. 8GB would definitely be overkill. So settled on 4GB RPi

Powered USB Hub

This is more electrical than setting up something. The very basic is any electrical equipment needs a power source. When we connect the hard disk to RasPi via a USB port, the power source of the HDD is RasPi. If RasPi cannot provide enough power to the HDD, it cannot function normally. We know the voltage is 5V but that is not all. We need to understand the maximum Watt requirement of HDD during its operation. Rotational Disk-based HDD requires the highest power to start spinning up. RasPi should be able to give that power though it may require less power during operation. In order to connect the dots, we need to consider the current as well which is measured in Amperes often noted in devices using either A or Amps or mA (milli Amps). Below is the relation that we learned in school.

W = VA

or

W=V*A (just for developers)

If one device specify W and V and another device specify V and A we can kind of do this calculation to see whether they match up 

Specs

It's time to read specs that nobody likes. RasPi specs say all 4 USB devices can together draw 1.2A of current. We know the voltage is 5V. So the max Power that can be given out through all the USB ports is 1.2 * 5V = 6W

In my case, I have 2.5" a laptop drive which has a requirement of 1.2Amps during spin up and an operational requirement of .8Amps. Meaning I can connect only one HDD to the RasPi directly at a time without an external power source. If I need to connect both the HDDs to RasPi, I would require a USB hub that has its own power source. Or buy another external HDD that is powered by a separate adapter.

This is the reason why I had to still connect my backup HDD of primary storage to the router. The router has enough power to drive HDD.

RPi OS

There are many operating systems available for RasPi. Even we can have Windows using its IoT Core edition. But decided to go with Raspberry Pi OS (Rasbian) as that is targeted to this device.

HDD FileSytem

Prefer to go with NTFS than Linux native Ext format. The main reason is in case RasPi fails I can connect the HDDs to my personal windows laptop. Planning to slowly migrate to Linux by starting with USB Linux installation with persistence storage.

Sync method

Our aim is to have one HDD connected to RasPi and another HDD to router and sync them. One more decision to be made is how to sync these 2 HDDs. There are 2 options I could find though they are not for solving the same issue and mutually exclusive.

  • RAID

There are already articles available on how to set up. Here is one good article on the same. I don't recommend this approach as this is mirroring. As soon as we do a change, it's replicated. No way to get the old copy in case we accidentally delete something.

  • RSYNC

This is a utility command which can sync 2 folders. The command has to execute to get the sync to happen. We can schedule easily during off-hours. Since it's home use, any time starting at 1 AM is fine. But the time depends on how your family members use the system.

There are disadvantages as well. If we copy something in the morning then in the afternoon primary hard disk failed. We lose the data as the sync happens only the next day at 1 AM. Also, if we accidentally delete something and we recognize it next week, there is no way to retrieve it.

I decided to go with this approach. Below is the link
https://www.howtogeek.com/139433/how-to-turn-a-raspberry-pi-into-a-low-power-network-storage-device/

Steps to get NAS up and running from RPi

These steps are mainly based on the article above in the RSYNC section. But there are some additional steps. Only the deviations and issues faced are documented rest of this article. Better to read the above article before reading further.

Let us start with something, not in that article.

Setting time zone

When we set up for the first time, the timezone would be the UK hence the time. If the location is not in the UK, it is better to change the time zone. Changing the timezone will update the time accordingly. I am not adding the step here as it's simply obtained by google.

Mount points

The tutorial mentioned above already has an instruction to install the NTFS driver. That has to be done before mounting the NTFS formatted drives. 

There are 2 mountings to be done. 

First mounting the USB drive connected to RasPi. To check the USB drive detected or not, use the below command

Tuesday, June 15, 2021

What is .fuse_hiddenXXX in Linux

Recently I set up a NAS based on Raspberry Pi. Every day at 1 AM, it replicates files from one external hard disk to another. It uses 'rsync' command to perform the task. The output of  'rsync' command is saved into a file that later emailed to me. 

It was going good. But nowadays I started seeing the below messages in the email suspecting some kind of failure.

deleting temp/2021/.fuse_hidden000de458000000dd

deleting temp/2021/.fuse_hidden000de453000000de

When I navigated to the location I was not able to see those files. After spending some time googling, I came to answer.  It is happening due to access conflicts and nothing to be worried about.

This seems a well-known thing in the Linux world but new to some like me who are entering Linux from Windows.


Tuesday, September 15, 2020

Setting up home NAS - Part 3 - Dealing with duplicates

This is the fourth post on Setting up home NAS. Below are the other posts on this series

Introduction

This post is not directly related to NAS (Network Attached Storage). If you are looking for NAS related stuff, you may stop reading from here onwards.
As mentioned in the previous post, my current set-up is.
  • A router attached USB drive working as NAS. \\192.168.1.1\share. It is of 1TB capacity
  • Sync the files to my personal computer that has 500GB drive. So effectively getting only 500GB which is backed up. SyncToy is working fine for on-demand sync
  • When I complete editing the video files, render and publish to YouTube, I move files out from the above setup. Combine all the raw videos to single and upload to YouTube in private visibility as well as back up to another external disk that has 2TB.
  • That means during editing time, 2 copies are in router attached USB drive and laptop. After publishing, one uploaded to YouTube and other copy in the different 2 TB hard disk.
This setup is throttled at 500GB. If I am able to process videos in a timely fashion and move to the second system of storage this will work. Else need to find some other mechanism to have a storage mechanism with backup. As we are seeing its not enterprise-level data storage. At least we don't lose data on single hard disk failure. 

Problem

When we set up NAS for home the main files stored will be media files such as photos, audio, and video files. They come from different sources such as multiple cameras, social media. The last post was about organizing media. That will show some duplicates and help us to remove them. But when the same file may come from different family and friends groups if there are mutual members. Though they are less compared to the file size from DJI Osmo Pocket and RAW files, they constitute a lot in the long run.
The solution that I am using is below.

Solution

This time, I am not writing any PowerShell program to deal with duplicates. There is a tool out there that is doing the job for me. 
Its name is AllDup, its free and working fast at least to my expectation. It supports the comparison of images as well as videos. There is an option to preview before we delete it. Plus a lot of options to control search behavior. Below is a screenshot showing different options.
If there is any better solution, please comment.

Tuesday, September 8, 2020

Setting up home NAS - Part 2 - PowerShell arrange media date bases files into YYYY\MM\DD folders

This is the third post in "Setting up home NAS". Other posts below

Setting up home NAS - Part 2 - PowerShell arrange media date bases files into YYYY\MM\DD folders (This post)

Background

This post is more about organizing and managing media files. Not about NAS specifically though this post is filed under the 'NAS' tag. As of writing this post, below is my setup and  I am happy
  • A router attached USB drive working as NAS. \\192.168.1.1\share. It is 1TB in size.
  • Sync the photos to my personal computer that has 500GB drive. SyncToy is working fine for on-demand sync
If you have a defined way and tools to organize the files, please skip this post.

Problem

One of the problems we are facing is the files from a variety of sources. We may have more than one camera, photos from social media such as WhatsApp, scanned old photos, etc...If we just label folders by event name or /oldphotos, /old1phots and /old2photos etc...it would be difficult in the future. So a better way is to arrange in folders based on the date taken
If we regularly move photos from all sources to our NAS device, it is easy we know what is the date and easily create and move to the right folders.
But, if we do it once in a month or two, it is difficult to put the files to the right folder.

Solution

There are GUI tools such as PhotoMove, Photos2Folders, or use IrfanView to move based on date. Even there is a command-line Exif tool to move the images bases on the modified date. But my media includes not only images, but it also has videos and audio files. Also, I may require a similar mechanism for other purposes in the future.

PowerShell to rescue

It may seem like overkill to write program to move files based on date. But I ended up coding PowerShell routine to do the same. Below goes the code. It's in gist

Friday, May 22, 2020

Setting up home NAS - Part 0 - RAID v/s Backup rsync v/s Raspberry Pi v/s Cloud Storage for Youtuber in the year 2020

Background

Regardless we do YouTubing or not, we would be generating a lot of digital assets mainly in the form of media. Mostly from cameras, social media services such as WhatsApp, etc...It is our valuable data and we need to protect it.

Regardless we like or not the failures are inevitable. Hardware will fail one day. As professionals, our goal should be to recover fast. If our assets are some accounts and budgets in excel files, resume, and occasional photos, its easy. One copy in the personal working machine, one copy in flash or external drive, and maybe one in free cloud storage. The problem starts when we cross the normal limit of free cloud storage and regular flash drives. This happens soon when we start YouTubing.

This post is about securing our home and personal media files.

Please note this is not at the enterprise level or when we become a YouTube star. Just a beginner level to make sure the files are not lost in small disasters.

Cost

There is no free option like using open-source software once we cross the 15 GB limit. As of writing this, GDrive offers 15 Gigs free which is the max free option available in the public cloud offerings. There is a wiki page comparing the public cloud storage options.

Oh, wait. There are other options as well on the internet.

Google Photos

Unlimited storage but the quality gets reduced and limits applied. As of writing this post, the limits are
  1. 16 MP, 75MB photos
  2. 1080p, 100GB videos
Google may change it later.

Baidu

Chinese internet Giant offered 2 TB free storage. That can be an option to be tried. Since we trust all the made in China hardware, why can't software service? Chinese language in their site should not be a problem as long as Google translate is there to help.

Options

If we shoot in better cameras that produce files > 100 GB and 4K and don't trust Chinese hosting which may have its own delay to servers, let us come back to home NAS options.

Cloud

Though this is not a home NAS, this cloud storage is an option if
  1. The cost is not a barrier
  2. Like to bear the cost monthly than a single investment.
  3. There are no concerns about storing the media at remote locations
  4. Have a good internet connection. 
As of now, the cost-effective solution among cloud providers seems Microsoft One Drive for 1 TB storage. It now has an online-only option called OneDrive Files on-demand. Once the upload to the cloud is done, we can clear the local storage. But when we navigate the folder, we can see files with a different icon. Whenever an application or user accesses the file, OneDrive client will download it. This helps us to save a lot of space in the hard drive of personal machines. 
Very simple option to have cloud grade features such as redundancy and backup. No need to do research on high availability, disaster recovery, etc...

RAID

This is a technology word and we need to do something to get it working. There is some theory to be understood before choosing. Wikipedia helps with it. For a beginner YouTuber, the RAID 1 would be enough. One more choice to be made is hardware v/s software RAID. Software RAID has some additional configuration.

For beginners, instead of buying a dedicated RAID device, it may be better to buy a refurbished workstation desktop with hardware RAID support. This way we get a workstation machine, mostly the refurbished workstation computers come with a graphics card, ECC RAM, etc...HP Z440 is a good machine to choose from. 

Please note that this is an on-premise solution unless we back it up to some cloud storage. On-premise means it can handle only small failures such as hard disks. If the premise is under disaster such as flooding, fires, etc, we may lose data.

Raspberry Pi 4+ 

The RP 4 onwards, it has 2 USB 3.1 ports. Simply connect 2 drives and use software RAID or backup using rsync to replicate files. Really a low power solution.

RP 4 with Software RAID 1

We can use software mdadm for RAID and samba for exposing the network share.

RP 4 with 'rsync'

If the RAID seems complicated, we can even set up scheduled rsync command to sync 2 drives. Note that RAID and back-up are not alternatives to one another. They can be used together also.

Cost Comparison

Below is a cost comparison. It is in gist which can be forked to customize


What I ended up using

The USB 3.1 port on my router. Sync from my local machine to the drive connected to the router. Below are my rationales
  1. The size is around 300 GB. One copy stored home laptop and the other in router attached USB are good till reaching 500 GB.
  2. Once completed, I normally merge the row video files and upload them into YouTube as private.
As seen in the image, it works till 1TB anyway. There is only 1 USB port so one copy to be kept inside the working machine. SyncToy is used to sync folders. I am using the GUI version, syncing starts manually and works fine. Not sure the command line exists.
However, I did order Raspberry Pi 4 (4GB) as the next step. RPI can be repurposed once that reaches its limit as NAS.

References

Tuesday, April 28, 2020

Setting up home NAS - Part 1 - Scientific debugging to get USB drive visible as \\share in network

Introduction

One of the previous posts was about scientific debugging and a template for debugging notes. The scientific approach really shines when we have to pause and resume the debugging. 
This is one live example where it is applied not necessarily in code debugging but fixing an issue with the home router

The requirement was to set up a home NAS. There are many ways to make it. A detailed post on home NAS would be coming in the future as part 2. One way is to set up a poor man's NAS like system is by connecting a USB drive to the home router if the router supports it. Nothing fancy. No high availability. Just a backup mechanism.

This post is to discuss one problem faced during the setup. 
After connecting the USB drive, the corresponding share is not getting visible to Win 10 machines.

Debugging a router problem would not be interesting to the readers of this blog as the majority are developers. But this gives a good example of how to follow scientific debugging which guarantees an output.

Solutions in internet

Optimum is the internet connection provider here but their connection guide doesn't have anything on it. Then checked the D-Link DIR-868L router page. That also not talking about any specific than marketing works. Then read the support page of the router. It has some more details including how to connect USB. But there is no special step mentioned. Just connect a USB drive and navigate to \\Router IP

Scientific debugging

Since its lockdown and debugging with kids (5 and 2 years) is extremely difficult as continuous troubleshooting is not at all possible. So I decided to follow the scientific debugging using the template created earlier. It is in gist and embedded below.