Setting up trout (Debian home server)
Setting up my Debian home server.
File System
-
I keep /home in a seperate partition of the SSD so it was partitioned as follows:
(parted) print all Model: ATA ST2000LM007-1R81 (scsi) Disk /dev/sda: 2000GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 2000GB 2000GB ext4 Model: Samsung SSD 970 EVO Plus 500GB (nvme) Disk /dev/nvme0n1: 500GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 538MB 537MB fat32 boot, esp 2 538MB 151GB 150GB ext4 3 151GB 451GB 300GB ext4 4 451GB 500GB 49.6GB linux-swap(v1) swap
- Create LUKS Volume
We are going to use /dev/sda1 with encryption so:
$ sudo apt install cryptsetup $ sudo cryptsetup luksFormat /dev/sda1 $ sudo cryptsetup luksOpen /dev/sda1 img3 $ sudo mkfs.ext4 /dev/mapper/img3 $ sudo cryptsetup luksClose /dev/mapper/img3
- Mount LUKS Volume.
Use
sudo blkid
to identify /dev/sda UUID and create the following shell script:#!/bin/bash sudo cryptsetup luksOpen /dev/disk/by-uuid/XXXXXXXX-843f-42c9-af34-b5cb43f73d00 img3 sudo mount /dev/mapper/img3 /srv
If you aren’t using encryption you can just directly mount the disk by adding the below to /etc/fstab:
UUID=XXXXXXXX-463c-4ae6-827a-368ab73cad88 /srv ext4 defaults 0 1
Then mount disk:
sudo mount -a
- Install samba
$ sudo apt install samba -y
In /etc/samba/samba.conf add:
[troutshare] path = /samba writeable = yes browsable = yes read only = no guest ok = no
$ sudo systemctl restart smbd
-
Install ssh
sudo apt install openssh-server
. Usessh-copy-id user@machine
to copy public key over. - To mount cod (mountcod script):
$ sudo apt-get install cifs-utils time $ sudo mount.cifs //cod.local/cod-share /srv/coddisk -o username=phwl
Mounting others (mountall script)
#!/bin/bash # /srv/troutdisk echo "Mounting trout" sudo cryptsetup luksOpen /dev/disk/by-uuid/f3bacd55-843f-42c9-af34-b5cb43f73d00 troutdisk sudo mount /dev/mapper/troutdisk /srv/troutdisk # /srv/coddifsk echo "Mounting cod (samba)" ./mountcod # /srv/wddisk EXTDISK=/dev/disk/by-uuid/5b5ac122-f46a-4307-8bfd-463bc9ca818a if test -f "$EXTDISK"; then echo "Mounting wddisk" sudo cryptsetup luksOpen $EXTDISK wddisk sudo mount /dev/mapper/wddisk /srv/wddisk fi
Backups
- Set up backup cron job using
crontab -e
0 5 * * * /srv/troutdisk/scripts/backup-to-cod >/tmp/cronjob.out
the script itself is
#!/bin/bash function teval() { echo "-- $*" eval "/usr/bin/time -v $*" } echo "** Running $0" date teval 'find /srv/troutdisk -print > /srv/troutdisk/data/media/gen/WD3.index' teval 'rsync -avh --delete --progress /srv/troutdisk/ cod.local:/srv/coddisk/ima ge/3' teval 'ssh cod.local rsync -avh --delete --progress /srv/coddisk/ /srv/carpdisk' date
System
- Disable suspend
/etc/systemd/sleep.conf
with the following options[Sleep] AllowSuspend=no AllowHibernation=no AllowSuspendThenHibernate=no AllowHybridSleep=no