Home Ubuntu Server


Introduction

For years i've dealt with multiple operating systems at once, allowing the benefits of each of them. One issue with having mutliple devices and operating systems is sharing data between the two, especially given the new macbook not haveing any connections except a USB C. I've always wanted to have a personal network attached storage server (NAS) to keep all of my long term data on as well as a buffer between devices to allow for clutter free working and painless data sharing. Once cleaning out one of the rooms at home I came accross my old motherboard, CPU and RAM and thought it would be a good use, continuing tidying I found my old laptop which would be an easy test rig where I don't need to buy a power supply or mess around with peripherals. Straight away I got into looking for home server solutions.

Technical

Given i've used Linux a fair amount and the open source nature I decided to use Ubuntu server as a base using 18.04.4 LTS. After faffing with a USB that simply wasn't happy for a few hours, I changed to a different USB stick and the installation was a couple minute breeze. I chose to setup the device using lan to avoid using network tools i'm not familiar with but used that to install network-manager a tool i'm more familiar with. Unfortunately given the age of my house the only way I could use the server was over a wifi connection, ideally I would keep the server over LAN constantly.

Setup wifi

To download network-manager:

    sudo apt install network-manager

To determine the wifi device:

    nmcli d

To enable the wifi device:

    nmcli r wifi on

To list available networks:

    nmcli d wifi list

Connect the device to the wifi network

    nmcli d wifi connect #SSIDHere# password #passwordHere#

Setup file share

I must admit I thought there would be more to setting up a samba share but it's incredibly easy when you know what you're looking for. The first and most important step is install samba:

    sudo apt install samba

The next most important step is to edit the samba config file at /etc/samba/smb.conf using your editor of choice (Vim is best) adding the line security = user beneath workgroup = HOMESERVER and change the workgroup name to something more well defined for you whilst there.
The next changes are to setup the file you'd like to share changing the values to make more sense for your case especially the file path (It dosn't have to exist yet):

    [share]
        comment = Ubuntu File Server Share
        path = /srv/samba/share
        browsable = yes
        guest ok = yes
        read only = no
        create mask = 0755

If the file does not exist or does not yet have the file rights apply the following directory creation and permissions:

    sudo mkdir -p /srv/samba/share
    sudo chown nobody:nogroup /srv/samba/share/

After setting up the file and configuration, samba service needs to be restarted to take on the changes:

    sudo systemctl restart smbd.service nmbd.service

Guilding Lillies

After that simple process we have a samba server ready to be used and you can usually stop right there. If you're like me and use a laptop or haven't used a samba server on windows before there are a few tiny steps that help make the system work better.

Disabling laptop sleep

Because i'm using a laptop, I don't want to have to keep the lid open to keep the server up. Thankfully with linux we can turn off the lit sleeping. This is done incredibly easily editing the file /etc/systemd/loginid.conf setting handleLidSwitch=ignore making sure to remove the hash at the start and it's that easy.

Enabling SMB on windows

If you've never used samba on windows, you may need to enable the ability to use a samba share. You can easily do this by navigating to control panel > programs > turn windows features on or off and selecting the SMB box. Bear in mind you will need to restart your computer to take effect. After this you should be able to see and connect to samba shares in the network tab.

Finding samba address

If you've now setup the server but have no idea how to connect, you need to find the servers IP address. You can easily find that out by typing:

ifconfig

or

ip

if you prefer.
Then read the address shown under your connection device and that is the connection address you need.