Skip to main content

Raspberry Pi Setup Guide with DietPi

This guide will help you set up your Raspberry Pi using the DietPi operating system, including the installation of various useful software and configurations.

One-Time Setup to Get Started

  1. Download DietPi: Visit the official DietPi website to download the latest image.

  2. WiFi Configuration:

    • Enable WiFi in dietpi.txt by adding the following line:
      AUTO_SETUP_NET_WIFI_ENABLED=1
    • Configure your WiFi details in dietpi-wifi.txt.
  3. Boot Raspberry Pi:

    • Unmount USB/SD from your computer.
    • Insert the USB/SD into your Raspberry Pi.
    • Power on the Raspberry Pi and let it complete its initial setup.

Software Installation

Install the following essential software packages:

  • LXDE
  • OpenSSH
  • Fail2Ban
  • Deluge
  • RealVNC
  • Samba Server

Starting the Desktop Environment

To access the desktop environment, you can run:

startx

To set up auto-login to the desktop, use the following command and follow the prompts:

AUTO_SETUP_AUTOSTART_LOGIN_USER=root

VNC Configuration

Configure VNC with the following steps:

  1. Change your VNC password:

    vncpasswd
  2. Update VNC session resolution and desktop session in /boot/dietpi.txt:

    SOFTWARE_VNCSERVER_WIDTH=1280
    SOFTWARE_VNCSERVER_HEIGHT=720
    SOFTWARE_VNCSERVER_DEPTH=16
    SOFTWARE_VNCSERVER_DISPLAY_INDEX=0
    SOFTWARE_VNCSERVER_SHARE_DESKTOP=1
  3. Restart the VNC server:

    systemctl restart vncserver

VNC Issue without HDMI Cable

To resolve VNC issues when not using an HDMI cable, add the following lines to /boot/config.txt:

hdmi_force_hotplug = 1
hdmi_group = 2
framebuffer_width = 1280
framebuffer_height = 720
hdmi_mode = 4
hdmi_mode = 16 # Choose your preferred resolution (16 is for 1080p)
# dtoverlay=vc4-kms-v3d # Disable this for headless VNC

Setting Up Samba Server Password

Set a Samba password for the user 'dietpi':

smbpasswd -a dietpi

Restart Samba services:

systemctl restart nmbd smbd

Samba Sharing Configuration

Edit the Samba configuration file:

sudo nano /etc/samba/smb.conf

Add the following configuration for a shared directory:

[dietpi]
comment = DietPi Share
path = /mnt/dietpi_userdata
browseable = yes
directory mask = 0777
create mask = 0777
valid users = dietpi root
writeable = yes
public = no
max connections = 2

To access this shared directory, use the following address:

smb://192.168.1.xxx/

Deluge Issue

If you encounter issues with Deluge, you can reset the web UI password by removing the configuration file:

rm ~/.config/deluge/webui06.conf

NordVPN Configuration

For NordVPN setup, refer to the list of NordVPN commands. Here's a quick overview:

nordvpn login
# Follow the browser-based authentication process
# Copy the 'Continue' link and return to the command line
nordvpn login --callback "link"
nordvpn whitelist add subnet 192.168.0.0/16
nordvpn whitelist add port 22
nordvpn set killswitch on
nordvpn set autoconnect on sg

Energy Consumption Command

Turn OFF HDMI output

    sudo /opt/vc/bin/tvservice -o

Turn ON HDMI output

    sudo /opt/vc/bin/tvservice -p

Turn OFF USB chip

    echo '1-1' |sudo tee /sys/bus/usb/drivers/usb/unbind

Turn ON USB chip

    echo '1-1' |sudo tee /sys/bus/usb/drivers/usb/bind