Misc Setup
An assortments of things I set up on my Pi to prepare it for operation.
This post is a part of my Homelab Series. See the index here.
Define Static IP
Figure out pi’s current IP address:
hostname -I
Open the relevant configuration file:
sudo nano /boot/firmware/cmdline.txt
Add the IP you want at the end. Doesn’t need to be the one you found above.
ip=192.168.1.132
SSH without Password
Generate keys on machine that you will be SSH’ing from:
ssh-keygen -t rsa
Copy keys to pi:
cat ~/.ssh/id_rsa.pub | ssh [USERNAME]@[PI IP ADDRESS] "cat >> ~/.ssh/authorized_keys"
Disable Wi-fi
Open the relevant configuration file:
sudo nano /boot/firmware/cmdline.txt
Add at the end of the first (and only) line:
dtoverlay=disable-wifi
Mount External Hard Drive
Find your drive. It should be at the very bottom, named most likely /dev/sdaN.
sudo fdisk -l
Find UUID and TYPE of your disk:
sudo blkid /dev/sda2
Create a folder where the drive will be mounted. You can pick any name, I went for ‘media’.
sudo mkdir /mnt/media
Add drive info to the scary auto-mounting configuration file:
sudo nano /etc/fstab
Add a new line at the end and paste the following and replace [UUID], [PATH] and [TYPE] with your drive’s properties:
UUID=[UUID] [PATH] [TYPE] defaults,uid=1000,gid=1000,users,auto,nofail,noatime 0 0
Restart the service, unmount, re-mount the drive and reboot to check if everything works:
sudo umount /dev/sdaN
systemctl daemon-reload
sudo mount -a
sudo reboot
Fix Permissions
I think I did this to get transmission to write to the external drive.
sudo su
find /mnt/media -type d -exec chmod 755 {} \;
find /mnt/media -type f -exec chmod 644 {} \;
Samba Share for Easy File Management
Install Samba:
sudo apt install samba samba-common-bin
Edit the configuration file:
sudo nano /etc/samba/smb.conf
Find and customize the following lines. Make sure to replace path
with the path where the drive you want to share is mounted. I set up three shares:
[media]
path = /mnt/media
writeable = yes
browseable = yes
public = yes
[pe8er]
path = /home/pe8er/
writeable = yes
browseable = yes
public = yes
[ssd-sandisk]
path = /mnt/ssd-sandisk
writeable = yes
browseable = yes
public = yes
Set up password for your user:
sudo smbpasswd -a $USER
Restart the service to get it going:
sudo systemctl restart smbd