Ubuntu home server

2025-01-14
Hardware: 120GB SSD boot disk, 4TB HDD for mass storage, 2TB HDD for backup.

Download Ubuntu LTS server iso, create a bootable USB using Rufus.
boot up using the USB, install Ubuntu server on the SSD, don't install anything on the HDD.
if the HDD is not factory fresh, "format" it using the installation menu.
hostname = server3     (you can name it anything)
optional: configure the server from DHCP to static IP using netplan.

identify the HDD drives:
sudo fdisk -l | grep sd | grep Disk

(next: initialize, create partition, write to hard disk)
sudo gdisk /dev/sdb and/or sudo gdisk /dev/sdc
n to create a new partition, call it partition 1
w to write partition information to the disk
sudo mkfs.ext4 /dev/sdb1  (format the new partition of first HDD)
sudo mkfs.ext4 /dev/sdc1  (format the new partition of second HDD)
sudo mkdir -p /mnt/storge
sudo mkdir -p /mnt/backup
echo '/dev/sdb1 /mnt/storage ext4 defaults 0 2' | sudo tee -a /etc/fstab
echo '/dev/sdc1 /mnt/backup ext4 defaults 0 2' | sudo tee -a /etc/fstab
sudo reboot
(confirm the HDD are mounted as /mnt/storage and /mnt/backup)
lsblk and/or df -h

Install Samba

Installing a wide open Samba server.
Caution: assuming the server is behind a good firewall/router.

sudo mkdir /mnt/storage/docs
cd /mnt/storage/docs
sudo chown -R nobody:nogroup *
sudo chomd -R 777 *
sudo apt update
sudo apt install samba  (be patient,this takes a while)
sudo nano /etc/samba/smb.conf

[global]
  refresh = 1
[docs]
  path =  /mnt/storage/docs
  writable = yes
  public = yes
  create mask = 0777
  directory mask = 0777
  valid users = @smbgroup
 

sudo groupadd smbgroup
sudo usermod -aG smbgroup user_name
sudo smbpasswd -a user_name

sudo systemctl restart smbd
sudo systemctl restart nmbd

Setup daily backup:

sudo nano /usr/local/bin/backup.sh
rsync -av0 --delete /mnt/storage/docs/  /mnt/backup/docs/
sudo chmod +x  /usr/local/bin/backup.sh
sudo crontab -e   (backup daily)
0 0 * * * /usr/local/bin/backup.sh


Windows users, map a network drive to the Samba server:

File Explorer, This PC, Map network drive,  \\server_ip_address\docs
e.g  \\192.169.1.4\docs
when asked, use the username in smb.conf and username's smbpasswd


Windows Explorer tweak


When access files home server using Windows Explorer, warning messages like "These Files Might Be Harmful to Your Computer" appear.
To mitigate that annoying problem:

Press Windows-Key and the R key simultaneously.
In the dialog box, type inetcpl.cpl
click the "Security" tab,
click the "Local Intranet" icon,
click the "Sites" button, click the "Advanced" button.
in the "Add ... Zone" box, type  192.168.1.5   (use your home server's static IP address) then click the "Add" button.
click "Close", click "OK", click "OK"