<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Nas on blog.iankulin.com</title><link>https://blog.iankulin.com/tags/nas/</link><description>Recent content in Nas on blog.iankulin.com</description><generator>Hugo</generator><language>en-AU</language><lastBuildDate>Tue, 04 Apr 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.iankulin.com/tags/nas/index.xml" rel="self" type="application/rss+xml"/><item><title>RAID Rescue</title><link>https://blog.iankulin.com/raid-rescue/</link><pubDate>Tue, 04 Apr 2023 00:00:00 +0000</pubDate><guid>https://blog.iankulin.com/raid-rescue/</guid><description>&lt;p&gt;I&amp;rsquo;m in the process of shuffling disks around as I move towards my 3-2-1 storage arrangements. I thought after my extensive rsync adventures I&amp;rsquo;d mirrored everything everywhere, but then realised, with a sinking (no pun) feeling, after I&amp;rsquo;d repurposed a drive out of the 2 drive Synology as a USB caddy drive and wiped it, that I&amp;rsquo;d forgotten my audio book directory. All my rsync fiddling around had been on the video subdirectory of the media folder, not the whole media directory that included my audiobooks.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s not the end of the world if I&amp;rsquo;d wiped them, I&amp;rsquo;ve just been working through downloading them from Audible and de-drming, so I could do that again in the few days I&amp;rsquo;ve got left till my subscription cancellation date comes around. That was a painful and slow process, so I don&amp;rsquo;t really want to.&lt;/p&gt;
&lt;p&gt;I still had one of the RAID drives that hadn&amp;rsquo;t been wiped, so in theory it should have a full copy of the data, and if I put it back in the Synology by itself it should work. That would be the same situation as if one drive in the RAID pool had died completely.&lt;/p&gt;
&lt;p&gt;A few screws, and a drive swap later and I&amp;rsquo;m looking at this:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-03-31-at-4.35.40-pm-copy.jpg" alt=""&gt;&lt;/p&gt;
&lt;p&gt;There must be a tiny bit of storage in the Synology, so it knows I&amp;rsquo;ve been fiddling around. I hit &lt;em&gt;Recover&lt;/em&gt;, and it did the ten minute thing that I assume is it downloading and installing the new DSM.&lt;/p&gt;
&lt;p&gt;During this process, it started beeping in a plaintive way. I couldn&amp;rsquo;t access with the old Tailscale address, so I fired up the IP address to the web interface, logged in with the old credentials and was greeted with this:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-03-31-at-4.08.58-pm.png" alt=""&gt;&lt;/p&gt;
&lt;p&gt;It was not happy working in the degraded state, but the files were all still there, I was able to mount it to the other NAS and copy my files out. A success. The Tailscale package was still installed, so perhaps that business at the beginning was not really a new install of DSM, but some sort of checking.&lt;/p&gt;
&lt;p&gt;This was a good experience, it is worthwhile to test these scenarios, and I&amp;rsquo;m reassured to discover the audible beeping when the RAID pool was degraded. At the moment while I get everything sorted I&amp;rsquo;m in the web interfaces a lot, but the dream is this learning and setup time comes to an end and I just consume my self-hosted services without much manual intervention. In that scenario, some un-ignorable beeping when the NAS needs attention is a good thing.&lt;/p&gt;</description></item><item><title>NAS Storage Calculations</title><link>https://blog.iankulin.com/nas-storage-calculations/</link><pubDate>Sat, 11 Mar 2023 00:00:00 +0000</pubDate><guid>https://blog.iankulin.com/nas-storage-calculations/</guid><description>&lt;p&gt;I&amp;rsquo;ve been really happy with my two bay Synology NAS - a DS216j. The Synology&amp;rsquo;s seem to have great reputation for just pushing on. Mine is loaded up with two 8TB Seagate Barracudas in RAID 1 leaving me with a one drive failure redundancy.&lt;/p&gt;
&lt;p&gt;I guess a more hard-core host-er than me would be building their own array and using Unraid or ZFS or something. I&amp;rsquo;m pretty comfortable with the Synology off the shelf system; it&amp;rsquo;s a good match for my (low) level of expertise, and more robust than my previous storage system of a USB external drive.&lt;/p&gt;
&lt;p&gt;As I start to move real world applications out of the cloud and on to self-hosting, I need to be serious about availability and data security. The general standard for this in the self-hosting community seems to be three versions of data:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;production version&lt;/li&gt;
&lt;li&gt;local backup&lt;/li&gt;
&lt;li&gt;remote backup&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I feel like the local and remote backups don&amp;rsquo;t &lt;em&gt;have&lt;/em&gt; to be NAS - a large enough external drive might be a reasonable cost saving. I would like the local backup to be able to be swapped into production though, so even if it was an external USB drive and would provide a degraded service, it should be able to be used to maintain services.&lt;/p&gt;
&lt;p&gt;A few days ago, there was an 8 bay, hot swappable Synology on eBay that got me a bit excited thinking about running different pools with a variety of RAIDs or just packing it with low cost smaller HDDs. Luckily I didn&amp;rsquo;t win it, but it triggered me to think about exactly what I need and what the trade-offs are.&lt;/p&gt;
&lt;h3 id="drive-quality"&gt;Drive Quality&lt;/h3&gt;
&lt;p&gt;The drives I&amp;rsquo;ve got in my NAS are second-hand, brand name non-NAS drives. They had just under 9000 hours on them, and the company selling them had hundreds of identical drives. From this, I&amp;rsquo;m assuming they came out of a data centre who replace drives at the one year mark.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s possible to buy &amp;ldquo;NAS&amp;rdquo; drives (and also &amp;ldquo;surveillance&amp;rdquo; drives) which are sold for uses where they are in use 24/7. They cost more.&lt;/p&gt;
&lt;p&gt;Is it possible these two types of drives (and perhaps even the USB external drives) are all the same drives, just marketed differently? Well, it&amp;rsquo;s possible. But it&amp;rsquo;s also possible they are mechanically identical, but have been sent to different market segments based on their initial test results.&lt;/p&gt;
&lt;h3 id="raid"&gt;RAID&lt;/h3&gt;
&lt;p&gt;RAID is a way of combining physical disks into one logical volume, usually in a way that reduces the capacity but allows for a drive failure without data loss. There&amp;rsquo;s several different &amp;rsquo;levels&amp;rsquo; of RAID. My current setup is RAID1 - I have two 8TB disks which present to the system as a single 8TB disk, but if one drive fails, I still have access to all of my data. If you have more than a couple of disks, RAID5 is a better option - if you had 3 x 8TB drives, you&amp;rsquo;d end up with 16TB usable space, and still be able to tolerate one drive failure. If you&amp;rsquo;re super cautious, RAID6 will allow two drive failures before you&amp;rsquo;re in danger. Of course this comes at a cost, if we had a 4x 8TB drive setup, there&amp;rsquo;d only be 16TB available, but any two of the drives could die without stopping the system.&lt;/p&gt;
&lt;h3 id="scoping-out-the-options"&gt;Scoping out the options&lt;/h3&gt;
&lt;p&gt;I&amp;rsquo;ve decided I need about 12TB - I currently have about 3TB of media locally and 0.5TB of general data on my laptop, that&amp;rsquo;s backed up to an external drive about weekly, along with about 20GB in DropBox. The bottom Dropbox plan is about AUD190 for 2TB, and I&amp;rsquo;m only using a fraction of it, so as part of my self-hosting that will get canned. 12TB seems like a lot of headroom from 4TB which is about where I&amp;rsquo;m sitting. I&amp;rsquo;d like to offer a couple of TB to whichever relative ends up hosting my remote backup. And finally it&amp;rsquo;s a multiple of 6TB which is a common ex-enterprise second hand drive size on ebay, so I know I can get year old ones for about $100&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll run through the thinking of each of the options I&amp;rsquo;ve considered.&lt;/p&gt;
&lt;h3 id="ds412"&gt;DS412+&lt;/h3&gt;
&lt;p&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-03-10-at-5.14.28-pm.jpg" alt=""&gt;&lt;/p&gt;
&lt;p&gt;I had a couple of Synologys with more bays than this in my eBay watchlist, but as you add drives, you add power consumption and heat, so I think realistically at the 12TB point, 4 bays is the most you could justify. There&amp;rsquo;s a bit of a price step up as well when you go to five bays and leave the serious home user segment of the market.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s worth mentioning how the Synology model numbers work in the DS range. My existing unit is a DS216j. The 2 is for two bays and it&amp;rsquo;s 2016 model. So the DS412+ is from 2012 and has four bays. The &amp;lsquo;j&amp;rsquo; on mine denotes its a mouse-power CPU - in this case a Marvell Armada 385 - some sort of low power ARM. The DS412+ is rocking a bigger mouse - the Intel Atom D2700, and it has a bit more RAM.&lt;/p&gt;
&lt;p&gt;The processor is not a big deal to me. Some folk host a lot of apps - media servers etc on their NAS. I&amp;rsquo;m not planning to do that. As long as it can run Tailscale in a container (which the &amp;lsquo;j&amp;rsquo; models can) we&amp;rsquo;re good to go.&lt;/p&gt;
&lt;p&gt;My theory with drive quality is that the lower the quality of the drive, the higher level RAID I need. So If I scope this unit out with the $100 used, non-NAS drives, I can install four disks as RAID6, have two fail on the same day, and still be operational.&lt;/p&gt;
&lt;p&gt;This second-hand (about ten years old) unit was on &amp;ldquo;buy now&amp;rdquo; for $416, the four year old drives adds $440 making it $856 unit - around $71/TB. The quoted power draw is 44W which works out at 3.7W/TB - the highest of everything I considered.&lt;/p&gt;
&lt;h3 id="ds420j"&gt;DS420j&lt;/h3&gt;
&lt;p&gt;Thinking about likely points of failure with the eleven year old NAS (if I used the DS412j) made me wonder if a unit failure might be higher on the probability list than a second-hand drive failure. The answer is who knows? - probably both events are quite unlikely. However I have some redundancy built in to the drives, but a single point of failure in the NAS unit. It made me wonder what a new 4 bay Synology costs, and the answer is not much more.&lt;/p&gt;
&lt;img src="https://blog.iankulin.com/images/27459.jpg" width="229" alt=""&gt;
&lt;p&gt;This DS420j is again 4 bays, and like the older 4 nay unit it&amp;rsquo;s hot-swapable. This means that in the event of a drive failure, you can leave the NAS running, remove the faulty drive and insert a new one. The unit will then (slowly) rebuild the RAID array, but while you are removing a drive and rebuilding the RAID the system is still fully operational.&lt;/p&gt;
&lt;p&gt;Listed at $439, that works out to $880 total if I used the same second-hand 6TB drives as in the calculation above. So with my RAID 6 (two drive failures can be tolerated without losing data) the cost per TB is $73 - only a couple more than in the first example.&lt;/p&gt;
&lt;p&gt;Apart from the peace of mind of running a newer unit, there&amp;rsquo;s a big difference in power consumption. The DS420j uses 44W, this one is 22W with all the drives spinning, or if you allow them to hibernate as low as 8W. So the max power burn is half at 1.8W per TB&lt;/p&gt;
&lt;h3 id="trading-raid"&gt;Trading RAID&lt;/h3&gt;
&lt;p&gt;RAID 6 - where I&amp;rsquo;m installing 4 x 6TB drives, and only ending up with 12TB of usable space is very conservative - and I was doing that because I was using the second hand drives. What if I bought cheap, but still brand name HDDs, but only three of them and configured as RAID 5 so I&amp;rsquo;d still get 12TB of usable disk, and a single drive can fail without affecting my data?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2023-03-10-at-5.40.03-pm.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-03-10-at-5.40.03-pm.png" width="239" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There are no three bay Synologys, so I&amp;rsquo;d use the same NAS as above - the DS420j. I can buy three Seagate Skyhawk 6TB disks for $660, so the total comes to $1100 or $92/TB - quite a bit more than four of the older drives in RAID6. With less drives spinning, we can probably assume a total power consumption of around 15W - 1.25W/TB&lt;/p&gt;
&lt;h3 id="even-less-disks"&gt;Even less disks&lt;/h3&gt;
&lt;p&gt;What if we reduce the number of disks even further? If we double the drive capacity to 12TB we could run 2 x 12TB drives as RAID1, have a smaller NAS, save some power, and still have a single drive fail with no data loss. We might want to go to an even higher quality of drive, perhaps one of the ones rated for NAS use - The cheapest new brand name 12TB NAS drive on eBay was a Seagate IronWolf. Two of those costs $756. The two bay DS220j NAS only adds $241 for a total of $997 - $83/TB. Power looks great at 1.1W/TB.&lt;/p&gt;
&lt;p&gt;These smaller NAS&amp;rsquo;s are not hot-swappable. You have to power down the NAS to replace a drive. This is not as cool as just clicking a button and sliding a drive out while all your services are still up, but it&amp;rsquo;s not really a significant factor in my decision making.&lt;/p&gt;
&lt;h3 id="disk-singular"&gt;Disk singular&lt;/h3&gt;
&lt;p&gt;I wouldn&amp;rsquo;t do this for my production storage, but it&amp;rsquo;s worth mentioning the single disk NAS. You&amp;rsquo;d want the best quality of drive possible, and probably schedule to swap it out after three years or so. A Synology single drive NAS with a NAS rated drive is a big step up in quality and convenience from an external USB drive. With that same IronWolf 12TB drive and a DS120j you&amp;rsquo;d be out of pocket $578 or $48/TB, and power is down to 0.83W/TB.&lt;/p&gt;
&lt;h3 id="ye-olde-usb-drive"&gt;Ye Olde USB Drive&lt;/h3&gt;
&lt;p&gt;I&amp;rsquo;ve not had a USB drive failure, but mine generally live a happy life powered down in a cool dry drawer until they are fished out for a backup session. Just by way of a comparison to the options above, a WD &amp;ldquo;Elements&amp;rdquo; USB drive costs the same as the single disk NAS at $580 ($48/TB) but the power is down at 0.67W/TB. The cheaper Seagate &amp;ldquo;One Touch Desktop Hub&amp;rdquo; drive works out at $35/TB and 0.83W/TB&lt;/p&gt;
&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="has-text-align-center" data-align="center"&gt;&lt;strong&gt;NAS&lt;/strong&gt;&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;&lt;strong&gt;Disks&lt;/strong&gt;&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;&lt;strong&gt;$/TB&lt;/strong&gt;&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;&lt;strong&gt;W/TB&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="has-text-align-center" data-align="center"&gt;DS412+&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;4 x 6TB used&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;$856&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;71&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;3.7&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="has-text-align-center" data-align="center"&gt;DS420j&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;4 x 6TB used&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;$880&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;73&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;1.8&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="has-text-align-center" data-align="center"&gt;DS420j&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;3 x 6TB new&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;$1,100&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;92&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;1.25&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="has-text-align-center" data-align="center"&gt;DS220j&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;2 x 12TB NAS&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;$997&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;83&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;1.1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="has-text-align-center" data-align="center"&gt;DS120j&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;1 x 12TB NAS&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;$578&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;48&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;0.83&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="has-text-align-center" data-align="center"&gt;WD Elements&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;1 x 12TB USB&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;$580&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;48&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;0.67&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="has-text-align-center" data-align="center"&gt;Seagate&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;1 x 12TB USB&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;$423&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;35&lt;/td&gt;&lt;td class="has-text-align-center" data-align="center"&gt;0.83&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Clearly out of the first two options, you&amp;rsquo;d choose the second. $2 extra per TB of storage is easily worth it to start with a new NAS compared with an eleven year old one. After that the price per TB doesn&amp;rsquo;t go down till you hit the single drive devices.&lt;/p&gt;
&lt;p&gt;Someone else may well start with different assumptions that I have made here, especially in the way I&amp;rsquo;ve decided to increase the drive quality as I&amp;rsquo;ve reduced the redundancy. For instance, you may be happy with a couple of second hand 12TB drives in a DS220j at $54/TB instead of rooting for new NAS drives. This would be along the lines of my original purchase of a DS216j and two 8TB second hand drives for $58/TB.&lt;/p&gt;
&lt;h2 id="the-plan"&gt;The Plan&lt;/h2&gt;
&lt;p&gt;Based on all this, I went with option two - the new DS420j and four old drives in a RAID6. It turned out a bit cheaper since there was a discount code for the NAS, and the price per drive was a touch less when buying four.&lt;/p&gt;
&lt;p&gt;For a local backup, I&amp;rsquo;ll use a single second hand 12TB drive in a DS120j, and for the remote, mainly because I want to share some storage with the home owner, and I feel that has to be on RAID, I&amp;rsquo;ll buy a pair of 14TB second hand drives to put in the DS216j for the remote, so I can open up a 2TB pool for them to use as a local backup for laptops or what have you.&lt;/p&gt;</description></item><item><title>Problems mounting network share at boot</title><link>https://blog.iankulin.com/problems-mounting-network-share-at-boot/</link><pubDate>Wed, 01 Mar 2023 00:00:00 +0000</pubDate><guid>https://blog.iankulin.com/problems-mounting-network-share-at-boot/</guid><description>&lt;p&gt;I had Jellyfin working nicely in an LXC container in Proxmox, but could not get Tailscale working in the container. Since this is going to be an important part of accessing my media away from home, I decided it was probably worth the extra bulk to run JellyFin in a VM.&lt;/p&gt;
&lt;p&gt;Following &lt;a href="https://blog.iankulin.com/accessing-a-synology-nas-from-linux/"&gt;my own instructions&lt;/a&gt;, I had the mount command in the /etc/fstab file so it would persist across reboots. It looked a bit like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;//192.168.100.25/media /mnt/media cifs username=jelly,password=jellypass,uid=1000,gid=115,file_mode=0660,dir_mode=07
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The problem I had was that this was not mounting the NAS at boot time, but if I reran it with &lt;code&gt;mount -a&lt;/code&gt; it worked perfectly. A likely cause for this problem is that the network interface is not properly up at the time the mount is being tried.&lt;/p&gt;
&lt;p&gt;I found a few different suggestions for this, but the one that worked for me and I liked the most is from the first answer in &lt;a href="https://askubuntu.com/questions/43363/how-to-auto-mount-using-sshfs/1242516#1242516"&gt;this StackExchange question&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;//192.168.100.25/media /mnt/media cifs username=jelly,password=jellypass,noauto,x-systemd.automount,_netdev,uid=1000,gid=115,file_mode=0660,dir_mode=07
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;From that answer, the explanation for these is:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;noauto&lt;/code&gt; will stop the no-brainer actions like forcibly mounting whatsoever at booting regardless if the network is up or not.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;x-systemd.automount&lt;/code&gt; is the smart daemon that knows when to mount.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;_netdev&lt;/code&gt; tag will also identify that it uses network devices, thus it will wait until the network is up.​​​​​​&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;I had tried &lt;code&gt;_netdev&lt;/code&gt; by itself, but that wasn&amp;rsquo;t enough magic. The three together was.&lt;/p&gt;</description></item><item><title>Accessing a Synology NAS from Linux</title><link>https://blog.iankulin.com/accessing-a-synology-nas-from-linux/</link><pubDate>Mon, 20 Feb 2023 00:00:00 +0000</pubDate><guid>https://blog.iankulin.com/accessing-a-synology-nas-from-linux/</guid><description>&lt;img src="https://blog.iankulin.com/images/img_4154x.jpg" width="1000" alt=""&gt;
&lt;p&gt;I picked up a Synology DS216j NAS from eBay to use for storage for the rapidly growing home lab. The eventual plan is that as well as my VM backups, it will host the media library, and eventually (when this has all proved itself reasonably bullet-proof) my current DropBox contents. That won&amp;rsquo;t all fit on the 2x2TB drives that the DS216j came with, and I have a pair of 8TBs on hand, but I wanted to set it up and checked it all worked.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-02-18-at-3.15.25-pm.jpg" alt=""&gt;&lt;/p&gt;
&lt;p&gt;Configuration of the NAS was a &amp;lsquo;follow the prompts&amp;rsquo; exercise for the most part. The Synology OS is a Linux port called DSM, but it&amp;rsquo;s intended to be an appliance so all the interactions are through the web client. I&amp;rsquo;m using RAID 1 since the plan is that the production segment of the homelab will all be high-ish available. There&amp;rsquo;s a few options to install extras (such as Tailscale), but these little &amp;lsquo;j&amp;rsquo; models don&amp;rsquo;t run an x86 processor, so no docker etc.&lt;/p&gt;
&lt;p&gt;Once I&amp;rsquo;d got through all of that, I created a share in &amp;lsquo;File Station&amp;rsquo; and copied a couple of files in. By default, Samba shares are on (with the name WORKGROUP - so I guess this is aimed at making it simple for Windows users) but NFS are not. I know nothing about NFS, so this suits me for the moment. Additionally, my &lt;a href="https://en.wikipedia.org/wiki/WD_TV"&gt;WD-TV&lt;/a&gt; shares it&amp;rsquo;s attached USB drive using Samba, so I&amp;rsquo;m used to accessing it from the MacBook. Let&amp;rsquo;s try the NAS from the MacBook:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2023-02-18-at-3.23.38-pm.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-02-18-at-3.23.38-pm.png" width="512" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It asked for the login details, then I was in. Could not have been much easier.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2023-02-18-at-3.28.55-pm.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-02-18-at-3.28.55-pm.png" width="800" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="accessing-from-linux"&gt;Accessing from Linux&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;m planning on running Jellyfin in an LCX container. So I&amp;rsquo;ll set that up for this test too. I stood it up with the Debian server .iso in Proxmox and specified it should be a &amp;lsquo;privileged&amp;rsquo; container, and in the Proxmox options for the LXC ticked &amp;lsquo;SMB/CIFS&amp;rsquo;. This process is not just for Synology - it will work to mount any samba share on a network to your Linux machine.&lt;/p&gt;
&lt;p&gt;We need to make an empty directory to mount to:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /mnt/media
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then edit (I use nano) the file &lt;code&gt;/etc/fstab&lt;/code&gt; to include:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;//192.168.100.25/media /mnt/media cifs username=jelly,password=jellypass,uid=1000,gid=1000,file_mode=0660,dir_mode=07
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;etc/fstab&lt;/code&gt; runs at startup, and if the shares are available (cautionary note about booting up your lab after a power outage) it will set them up. There&amp;rsquo;s a fair bit going on in the command, perhaps we should pull it apart:&lt;/p&gt;
&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;//192.168.100.25/media /mnt/media&lt;/code&gt;&lt;/td&gt;&lt;td&gt;The first directory is the share, the second is the empty directory on this machine we are mounting the share to.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;username=jelly, password=jellypass&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Our credentials needed to log into the share. Actually I used my root credentials, but obviously a good idea would be to make a user on the NAT for this specific purpose with only access to the share they need to operate.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;uid=1000, gid=1000&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Okay, we're about to enter the Linux zone... These numbers are a &lt;a href="https://medium.com/@gggauravgandhi/uid-user-identifier-and-gid-group-identifier-in-linux-121ea68bf510"&gt;Linux user id and a group ownership id&lt;/a&gt; that Linux assigns to resources - you know, for &lt;code&gt;chown&lt;/code&gt; and stuff like that. If you type in &lt;code&gt;id&lt;/code&gt; at the CLI you can see your numbers. For some reason code examples often use 1000 for both, and things seem to work so I don't worry about it.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;file_mode=0660, dir_mode=07&lt;/code&gt;&lt;/td&gt;&lt;td&gt;More Linux permission stuff. Used in combination with the previous two parameters, and &lt;a href="http://file_mode=0660,dir_mode=07"&gt;will probably cause me problems later&lt;/a&gt;.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Note that a couple of other posts on the internet about mounting samba shares thought I&amp;rsquo;d have to do one or both of these commands to install extra samba goodness:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt install smbclient
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt install cifs-utils
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But it turns out I didn&amp;rsquo;t. I suspect that was something to do with ticking the box for SMB/CIFS when I was creating the LXC container in Proxmox.&lt;/p&gt;
&lt;p&gt;Once you&amp;rsquo;ve saved that command in &lt;code&gt;/etc/fstab&lt;/code&gt;, reload the mounts with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mount -a
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If there&amp;rsquo;s no errors, you are probably right to go. Have a look at your mount point to see your shared files.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-02-18-at-4.59.09-pm.png" alt=""&gt;&lt;/p&gt;
&lt;p&gt;Since the mount command is in the /etc/fstab file, this mount will be durable - as long as the share is available, it will be mounted every time this machine starts.&lt;/p&gt;</description></item></channel></rss>