There is an old joke about a camel being a horse designed by a committee. A camel is ugly, and as well as kicking and biting, it spits. However, if you need something to carry a heavy load, across inhospitable terrain with minimum maintenance, a Camel is usually better than a horse.
Linux is a bit like a camel, with the additional problem that the committee likes to keep changing things that work for something that does the same thing but differently, making some things really difficult. For instance, using the instructions to set up an Ubuntu server using instructions written in 2012 can be really annoying. Being spat at by a camel is probably more fun.
However, my office desktop was beginning to irritate me, it was badly setup (by me) in the first place, and it was just painfully slow. I could rebuild it (after all that is what I do) but I was running Windows 10 32 bit on a 64 bit machine, so it really was a case of starting again with a fresh install. I had a rather nice HP all-in-one Touchsmart 520 which a customer had asked me to dispose of, in which I had replaced the old hard drive with a newish 1TB HDD, replaced a noisy system fan with one from another PC of the same range which I was cannibalizing, and put 6GB of ram in (I’ll put some more in when I rescue a 4GB stick from somewhere). I also upgraded the Windows 7 loaded on the machine to Windows 10 (using the upgrade from 2015) and installed yet another copy of my Family copy of Office 365. Transfer all the data and settings from the old desktop to the new, and I was up and running. Cool!
That left a Cooler Master case, with a Gigabyte GA-FA55M-DS2 motherboard with an AMD dual core processor, 4GB of ram, a Thermal Master 420w power supply, a 1TB hard drive and a few extra USB ports, but no windows licence for a 64 bit install. Not a bad spec, but not very modern or useful. What could I do with it? My old cheap NAS drive had become obsolete a few years ago, and its hard drive was parked in the old case, and I had been sharing it over the networks as a NAS drive, and I had a 1TB external drive attached which I was also sharing. The new machine does not have room for another drive inside. nor does permanently attached external drives look good on an all-in-one. It was obvious really – make a new NAS drive. I looked at some of the ready made offerings out there, and either the machine was not up to it (FreeNAS needs 8GB of ram) or they looked so hard to get going, or were not free.
In reality a NAS drive is just a server with some disks and folders shared out, how hard could it be to get Ubuntu to do that?
Step 1. Install 240 GB SSD into machine to run Ubuntu off. These things are so cheap at the moment, silly not to use one.
Step 2. Download Ubuntu Server 20.04, and write the image to a 4GB USB stick I had spare. Yes, it fit!
Download and instructions to create the install media are on this page, along with some guidance for installation.
You need a mouse, keyboard and screen attached for the next couple of steps.
Step 3. Install Ubuntu server onto the SSD. Nothing hard here, just boot from the boot media and follow the instructions. When asked, tick the box that installs the SSH server. Obviously, create a userid and password to enable you to sign on eventually.
Step 4. Reboot the machine, remove the boot media, and boot into ubuntu server using the user id and password you created above. Take a note of the IP address used for this boot, if it is OK, use it for the next step, otherwise choose one you like that is not already used.
Step 5. Set up a static IP address for the new server. This used to be easy, just add a few lines to a file called /etc/network/interfaces – the name is even logical. But not in Ubuntu 20.04.
sudo nano /etc/netplan/00-installer-config.yaml
yep, clever isn’t it!
There won’t be much in there, but where it says dhcp4 : true use the following
dhcp4: no addresses: - 192.168.1.120/22 gateway4: 192.168.1.254 nameservers: addresses: [192.168.1.254]
obviously put in your own ip address and port, gateway and nameserver.
Don’t use tabs instead of leading spaces, and make sure you indent correctly, as shown, otherwise it all throws a wobbly. Save the file, and sudo reboot the machine.
Step 6. Use SSH (Putty or similar on Windows) to connect to the IP address you just specified, and then your userid and password to logon. No need for a screen, mouse or keyboard on the machine if all this worked, and no more working in the garage – log in from and PC around the house!
Everything can now be done from the terminal window open in step 6 if this how your roll, but I like a little GUI with my admin of an Ububtu machine.
Step 7. Install SAMBA to allow access to Windows disks.
sudo apt update sudo apt install sambaI'll cover how this is used in another post.
Its really just as easy as this
sudo sh -c 'echo "deb http://ftp.au.debian.org/debian/ buster main non-free" > /etc/apt/sources.list.d/nonfree.list'
sudo apt update
sudo apt install wget
and then this
wget -qO - http://www.webmin.com/jcameron-key.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://download.webmin.com/download/repository sarge contrib" > /etc/apt/sources.list.d/webmin.list'
sudo apt update
sudo apt install webmin
Maybe a reboot would be good after this.
Step 9. on your windows browser, use https://192.168.1.120:10000 where 192.168.1.120 is changed to your IP address, and 10000 is the port for webmin.
This NAS drive isn’t going to get a lot of use, but is always going to be on. So I would like the hard drives to spin down when not being used. This can be achieved using HDPARM, and I spend many hours trying to get it to work. Unsuccessfully! My hard drives are Western Digital, and these are not very friendly towards power management, so an alternative is required.
hd-idle is an alternative that works with WDC drives and external drives, and is so easy to install.
Step 10. Use
sudo apt-get install hd-idle
Step 11. Set up the timeouts for the disks on your machine by editing the following file
sudo nano /etc/default/hd-idle
Step 12. Add two lines to the end of the file.
HD_IDLE_OPTS="-i 0 -a sdb -i 600 -a sdc -i 600"
the first line has 3 options in quotes.
-i 0 sets a deafult time out to never for all drives – you don’t want to shut down ant drives by mistake.
-a sdb -i 600 this specifies the name of a drive (SDB), and and the spin down delay (600 seconds)
-a sdc -i 600 and this specifies the same for drive SDC
Step 13. start the service when the machine is booted.
sudo systemctl start hd-idle
and check the status of the service at any time with
systemctl status hd-idle.service
That’s it for setting up the server, I will do the use of WEBMin to mount drives, set up shared folders and add the correct permissions in another post.