In my previous post, I had successfully installed the Debian Jessie image and was I able to SSH onto the box. The remaining work was to clean up as suggested by Ewald and also to update to the latest available kernel, 4.19. Having done this I found out that there were a few things that needed fixing before I could use the My Book Live (MBL) for my backups.
Basic configuration
If you remember, I still had the WD MBL in pieces on my desk, so I plugged the MBL HDD back into my PC. Then I followed the instructions provided by Ewald in his instructions: https://github.com/ewaldc/My-Book-Live/tree/master/debian/debian%208%20(Jessie)#how-to-install-with-ext4-
Warning: the commands could be break your PC if you forget to cd
to mount point first! For example:
cd /mount/andy/<UID for HDD>
For the rest of this section, the commands work if you have changed to the root of the mounted WD MBL HDD.
First, I set up a static address for the server by editing the the etc/network/interfaces
file to look like this:
# interfaces(5) file used by ifup(8) and ifdown(8) #allow-hotplug lo iface lo inet loopback #iface eth0 inet dhcp iface eth0 inet static address 192.168.1.203 netmask 255.255.255.0 gateway 192.168.1.1 allow-hotplug eth0 #auto eth0
Then I changed the etc/exports
file to use the correct sub-net.
To change the host name, added the new host name ‘mbl’ to /etc/hosts
so it looks like this:
127.0.0.1 localhost mbl
Then I replaced the host name in etc/hostname
.
Debian Jessie is no longer supported so set apt
to use the archive. Comment out all lines in etc/apt/sources.list
except for the line:
deb http://archive.debian.org/debian jessie main contrib non-free
Finally, the users ewald
,tea
and share
need to be removed. Delete all user files
sudo rm -rf home/ewald
Edit etc/passwd
to remove the users by deleting the lines starting with ewald
,tea
and share
. Edit etc/group
to remove the line starting with share
and then remove ewald
and tea
from all other groups.
That was all that I could do from the convenience of my host PC so it was time to test all my changes and then complete the setup of my WD MBL.
Setting up
Having logged in as root using SSH, the first thing to do was to replace the root SSH key:
rm /etc/ssh/ssh_host* dpkg-reconfigure openssh-server
Then I added me as a sudo
user.
adduser andy adduser andy sudo
Having done that, I rebooted, SSH’d in as me and then started setting up the WD MBL the way I wanted it.
DNS problems
The first thing I did was to try to install vim
as it is my preferred command line editor. However, the apt install
command didn’t work with what looked like a network problem. The network connection was OK as I was using SSH, so I tried the command:
$ ping google.com ping: unknown host google.com
This showed that the DNS server not being found. Verified using:
nslookup google.com ;; connection timed out; no servers could be reached
There are several ways to add DNS servers and, after some trial and error, I found that changing /etc/resolv.conf
to look like this worked.
nameserver 8.8.8.8 nameserver 8.8.4.4
You can use other DNS servers but these values are great for testing as they are easy to remember. Re-testing with nslookup
succeeded so I then changed the DNS servers to those recommended by my ISP.
Finally, I was able to install vim
so I could then move on to the next problem.
Date and time
While I was sorting out the DNS problems, I found out that the system time and date was reset after each boot to some time in 2018. This was easy to temporarily fix using the command date
but I wanted this server to be able to reboot without manual intervention so I needed to get the time and date to update automatically.
My immediate thought was to use the ntpd
daemon. I checked to see if it was running using:
$ sudo systemctl status ntp ● ntp.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead)
As ntpd
was not running, I googled for how to start it up and this is when I found out about systemd-timesyncd
. This is basically a cut down version of the full ntpd
that is integrated into systemd
that is only used to synchronise the local system time with the time from NTP servers. So I used the following commands:
$ sudo systemctl start systemd-timesyncd $ sudo systemctl enable systemd-timesyncd Created symlink from /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service to /lib/systemd/system/systemd-timesyncd.service.
The status of the daemon can be found using:
$ sudo systemctl status systemd-timesyncd ● systemd-timesyncd.service - Network Time Synchronization Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; disabled) Active: active (running) since Fri 2019-07-19 10:34:23 UTC; 6s ago Docs: man:systemd-timesyncd.service(8) Main PID: 1487 (systemd-timesyn) Status: "Idle." CGroup: /system.slice/systemd-timesyncd.service └─1487 /lib/systemd/systemd-timesyncd
And the time and date can be checked using:
$ timedatectl Local time: Fri 2019-07-19 15:25:13 BST Universal time: Fri 2019-07-19 14:25:13 UTC RTC time: n/a Time zone: Etc/UTC (UTC, +0000) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a
As you can see, the time zone was set incorrectly to Etc/UTC
, so I had to find out how to set it. The man pages proved useful: https://manpages.debian.org/jessie/systemd/timedatectl.1.en.html
First, I listed the time zones:
$ timedatectl list-timezones
From the huge list that you get, I selected my time zone Europe/London
and set the time zone like this:
$ sudo timedatectl set-timezone Europe/London
Then I checked the date and time again and everything was working:
$ timedatectl Local time: Fri 2019-07-19 15:48:13 BST Universal time: Fri 2019-07-19 14:48:13 UTC RTC time: n/a Time zone: Europe/London (BST, +0100) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2019-03-31 00:59:59 GMT Sun 2019-03-31 02:00:00 BST Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2019-10-27 01:59:59 BST Sun 2019-10-27 01:00:00 GMT
Upgrading the kernel
With the benefit of hindsight, I should probably have upgraded the kernel soon after installing the Debian Jessie image. However, it worked first time so all was well.
Download the new kernel files from: https://github.com/ewaldc/My-Book-Live/blob/master/kernel/precompiled/linux-4.19.33.tgz. On my main PC, I mounted the NFS share from my WD MBL and copied the file linux-4.19.33.tgz
to the NFS share (located at /nfs
).
Using SSH on to the WD MBL, copy all the files needed for the existing kernel into a new directory just in case it all goes horribly wrong.
cd boot sudo mkdir 4.9.99 cd 4.9.99 sudo cp ../apollo3g.dtb . sudo cp ../boot.scr . sudo cp ../uImage .
Now unpack the archive file into a new directory.
cd /boot sudo mkdir 4.19.33 sudo tar xf /nfs/linux-4.19.33.tgz sudo mv boot/* . sudo rm boot ls apollo3g.dtb uImage_4.19.33+x
All that needs to be done now is to overwrite the old kernel image with the new one.
cd /boot sudo cp 4.19.33/uImage_4.19.33+x .
I then rebooted and it all just worked. Great!
One of the main reasons for updating the kernel is to ensure that the server is reasonably secure. Ewald has also patched this kernel to improve throughput on the hard disk and the improvement is noticeable when transferring large amounts of data. Well worth doing.
Enable mDNS
The final thing I decided to do was allow SSH access using mDNS. This would allow me to access the MBL this command:
ssh andy@mbl.local
This is “a good thing” as I can still access the server if I decide to change the IP address and I also wanted to try this out having never set it up before.
I installed the following:
sudo apt-get install avahi-daemon avahi-discover libnss-mdns
Then created the file /etc/avahi/services/ssh.service
with the contents:
<?xml version="1.0" standalone='no'?><!--*-nxml-*--> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_ssh._tcp</type> <port>22</port> </service> </service-group>
I tried the SSH command and it just worked.
My WD MBL has been working as my backup server for about a month now and, hopefully, I shouldn’t have to touch it again for a few years.