└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Raspberry Pi 3 Setup 2 | The steps I took get my Raspberry Pi 3 up and running. 3 | 4 | ## Upgrade Jessie 5 | Run the following commands to [upgrade Jessie to Pixel](https://www.raspberrypi.org/blog/introducing-pixel/), which includes Chromium with hardware video support: 6 | ``` 7 | sudo apt-get update 8 | sudo apt-get dist-upgrade 9 | sudo apt-get install -y rpi-chromium-mods 10 | sudo apt-get install -y python-sense-emu python3-sense-emu 11 | sudo apt-get install -y python-sense-emu-doc realvnc-vnc-viewer 12 | ``` 13 | 14 | ## Change Password 15 | Run the following command, then enter the current password and a new password twice to confirm: 16 | ``` 17 | passwd 18 | ``` 19 | 20 | ## Setup SSH 21 | Launch the Raspbery Config: 22 | ``` 23 | sudo raspi-config 24 | ``` 25 | 26 | Go to `9 Advanced Options` then `A4 SSH` and choose ``. 27 | 28 | Open the `/etc/ssh/sshd_config` file and add the following: 29 | ``` 30 | PermitRootLogin no 31 | ClientAliveInterval 30 32 | ClientAliveCountMax 5 33 | ``` 34 | 35 | Then restart the SSH service: 36 | ``` 37 | sudo service ssh restart 38 | ``` 39 | 40 | ## Disable Automatic Desktop Login 41 | Run the configuration command: 42 | ``` 43 | sudo raspi-config 44 | ``` 45 | 46 | Go to `3 Boot Options` then `B3 Desktop` and choose ``. 47 | 48 | ## Setup Display 49 | Ensure the display works nicely over HDMI: 50 | ``` 51 | sudo nano /etc/boot.txt 52 | ``` 53 | 54 | Add the following lines to the bottom of the file: 55 | ``` 56 | hdmi_group=1 57 | hdmi_mode=16 58 | hdmi_ignore_cec_init=1 59 | hdmi_ignore_cec=1 60 | hdmi_drive=2 61 | gpu_mem=128 62 | ``` 63 | 64 | In order to disable HDMI CEC you also need to drop a config file on the recovery partition: 65 | ``` 66 | sudo su 67 | mount /dev/mmcblk0p1 /mnt 68 | echo hdmi_ignore_cec_init=1 >> /mnt/config.txt 69 | umount /mnt 70 | exit 71 | ``` 72 | 73 | Now reboot the system: 74 | ``` 75 | sudo reboot 76 | ```` 77 | 78 | ## Install Kodi 79 | Update repositories and install Kodi packages: 80 | ``` 81 | sudo apt-get update 82 | sudo apt-get install kodi 83 | ``` 84 | 85 | Create a Kodi shortcut on the desktop that boots in standalone mode (avoids blackscreen on exit): 86 | ``` 87 | touch ~/Desktop/kodi-standalone.desktop 88 | nano ~/Desktop/kodi-standalone.desktop 89 | ``` 90 | 91 | Add the following contents to the file: 92 | ``` 93 | [Desktop Entry] 94 | Version=1.0 95 | Name=Kodi 96 | GenericName=Media Center 97 | Comment=Manage and view your media 98 | Exec=kodi-standalone 99 | Icon=kodi 100 | Terminal=false 101 | Type=Application 102 | Categories=AudioVideo;Video;Player;TV; 103 | ``` 104 | 105 | ## Install FAT32, ExFAT and NTFS File System Support 106 | Install the following packages: 107 | ``` 108 | sudo apt-get install exfat-fuse exfat-utils ntfs-3g 109 | ``` 110 | 111 | ## Mount NAS 112 | Ensure the CFIS packages are installed: 113 | ``` 114 | sudo apt-get install cifs-utils 115 | ``` 116 | 117 | Create a credentials file for the username and password: 118 | ``` 119 | touch ~/.smbcredentials 120 | nano ~/.smbcredentials 121 | ``` 122 | 123 | Add the following contents, replacing the username and password: 124 | ``` 125 | username=username 126 | password=password 127 | ``` 128 | 129 | Change the permissions of the credentials file: 130 | ``` 131 | chmod 600 ~/.smbcredentials 132 | ``` 133 | 134 | Make a directory to mount the NAS to: 135 | ``` 136 | sudo mkdir /media/NAS 137 | ``` 138 | 139 | Test you can mount the NAS manually: 140 | ``` 141 | sudo mount -t cifs //192.168.0.x/NAS /media/NAS -o credentials=~/.smbcredentials,vers=1.0 142 | ``` 143 | 144 | Any mounting problems can be found by checking the logs: 145 | ``` 146 | tail -f /var/log/kern.log 147 | ``` 148 | 149 | You can find out your users UID and GID with these commands: 150 | ``` 151 | id -u username 152 | id -g username 153 | ``` 154 | 155 | Alternatively you can just use your username and group instead. 156 | 157 | Now update the `/etc/fstab` file to auto mount the NAS as **read-only**: 158 | ``` 159 | //192.168.0.x/NAS /media/NAS cifs credentials=/home/username/.smbcredentials,_netdev,x-systemd.automount,iocharset=utf8,sec=ntlm,ro 0 0 160 | ``` 161 | 162 | Or for full **read and write** add this to the `/etc/fstab` instead: 163 | ``` 164 | //192.168.0.x/NAS /media/NAS cifs credentials=/home/username/.smbcredentials,_netdev,x-systemd.automount,iocharset=utf8,sec=ntlm,rw 0 0 165 | ``` 166 | 167 | _Note: Update the lines above with your own NAS IP address, mount directory, username, UID and GID accordingly. For devices running older versions of Samba you may need to add `,vers=1.0` after `ro` or `rw` above._ 168 | 169 | Now run this to mount the NAS: 170 | ``` 171 | sudo mount -a 172 | ``` 173 | 174 | Create a handy symlink to the NAS on the desktop: 175 | ``` 176 | sudo ln -s /media/NAS ~/Desktop/NAS 177 | ``` 178 | 179 | ## Mount USB Drive 180 | Find the UUID of the USB drive: 181 | ``` 182 | sudo blkid 183 | ls -l /dev/disk/by-uuid/ 184 | ``` 185 | 186 | The output should look something like the following. Note the _UUID_ value: 187 | ``` 188 | /dev/sda1: LABEL="USB DRIVE" UUID="1234-5678" TYPE="exfat" PARTUUID="ffffffff-01" 189 | ``` 190 | 191 | Make a directory to mount the USB drive to: 192 | ``` 193 | sudo mkdir /media/USB-Drive 194 | ``` 195 | 196 | Test mounting the drive manually to make sure it works: 197 | ``` 198 | sudo mount -t exfat -o uid=pi,gid=pi UUID=1234-5678 /media/USB-Drive 199 | ``` 200 | 201 | Now add the following to the `/etc/fstab` to auto mount the USB drive: 202 | ``` 203 | UUID=1234-5678 /media/USB-Drive exfat defaults,nofail,uid=1000,gid=1000,dmask=000,fmask=111 0 0 204 | ``` 205 | 206 | _Note: Update the line above with your own UUID, mount directory, file system, UID and GID accordingly._ 207 | 208 | Now run this to mount the USB drive: 209 | ``` 210 | sudo mount -a 211 | ``` 212 | 213 | Create a handy symlink to the USB drive on the desktop: 214 | ``` 215 | sudo ln -s /media/USB-Drive ~/Desktop/USB-Drive 216 | ``` 217 | 218 | To repair an exFAT drive on Windows run the following command: 219 | ``` 220 | chkdsk.exe /F Z: 221 | ``` 222 | 223 | _Note: Replace Z: with the relevant drive letter._ 224 | 225 | ## Create EXT4 Drive 226 | 227 | You can format a partition as EXT4: 228 | ``` 229 | mkfs.ext4 /path/to/mount -L YourLabel 230 | ``` 231 | 232 | You can also change the drive label afterwards: 233 | ``` 234 | e2label /path/to/mount YourLabel 235 | ``` 236 | 237 | And you can easily mount it in the `/etc/fstab` as follows: 238 | ``` 239 | UUID=1234-5678 /media/USB-Drive ext4 defaults,auto 0 0 240 | ``` 241 | 242 | ## Backup NAS to USB Drive 243 | First, create a directory to store the backup logs in: 244 | ``` 245 | mkdir ~/Backups 246 | ``` 247 | 248 | Then create an rsync ignore file, this will exclude unneccesary Windows and macOS files from being backed up: 249 | ``` 250 | touch ~/Backups/rsync_excludes.txt 251 | ``` 252 | 253 | And add the following contents: 254 | ``` 255 | $RECYCLE.BIN 256 | $Recycle.Bin 257 | ._* 258 | .AppleDB 259 | .AppleDesktop 260 | .AppleDouble 261 | .com.apple.timemachine.supported 262 | .dbfseventsd 263 | .DocumentRevisions-V100* 264 | .DS_Store 265 | .fseventsd 266 | .PKInstallSandboxManager 267 | .Spotlight* 268 | .SymAV* 269 | .symSchedScanLockxz 270 | .TemporaryItems 271 | .Trash* 272 | .vol 273 | .VolumeIcon.icns 274 | Desktop DB 275 | Desktop DF 276 | hiberfil.sys 277 | lost+found 278 | Network Trash Folder 279 | pagefile.sys 280 | Recycled 281 | RECYCLER 282 | System Volume Information 283 | Temporary Items 284 | Thumbs.d 285 | ``` 286 | 287 | Do a dry run (the `-n` flag) to ensure the correct files are being backed up: 288 | ``` 289 | rsync -rtvun --exclude-from="$HOME/Backups/rsync_excludes.txt" /media/NAS/ /media/USB-Drive/ 290 | ``` 291 | 292 | Next, create a script to handle the backups: 293 | ``` 294 | touch Backups/backup.sh 295 | ``` 296 | 297 | With the following contents: 298 | ``` 299 | #!/bin/bash 300 | 301 | BACKUP_DIR="$HOME/Backups" 302 | BACKUP_LOG="$BACKUP_DIR/nas_backups_`date +'%Y-%m-%d'`.txt" 303 | BACKUP_EXCLUDES="$BACKUP_DIR/rsync_excludes.txt" 304 | BACKUP_LOG_DAYS=7 305 | 306 | /usr/bin/rsync -rtvu --log-file="$BACKUP_LOG" --exclude-from="$BACKUP_EXCLUDES" --delete-after /media/NAS/ /media/USB-Drive/ 307 | find $BACKUP_DIR/nas_backups_*.txt -mtime +$BACKUP_LOG_DAYS -exec rm {} \; 308 | ``` 309 | 310 | Once you're happy it works you can add it to your user's crontab: 311 | ``` 312 | crontab -e 313 | ``` 314 | 315 | Add the following contents to it to run it every night at 1am: 316 | ``` 317 | SHELL=/bin/bash 318 | 319 | 0 1 * * * $HOME/Backups/backup.sh 320 | ``` 321 | 322 | You can add the `--exclude` option to exclude a specific pattern of files or directories, and the `--delete-after` option to ensure files deleted from the target are also removed from the destination. 323 | 324 | You can see the last backup log by viewing the file contents: 325 | ``` 326 | cat ~/Logs/nas_backups_YYYY-MM-DD.txt 327 | ``` 328 | 329 | You can see what environment variables are available in the cron environment by adding the following to your crontab (you'll need to add whatver `* * * * *` you want): 330 | ``` 331 | env >> $HOME/Backups/cron_env.txt 332 | ``` 333 | 334 | You can also ensure any macOS hidden "dotfiles" are deleted by create a `dotfiles.sh` script: 335 | 336 | ``` 337 | touch dotfiles.sh 338 | chmod +x dotfiles.sh 339 | ``` 340 | 341 | And then adding the following contents to it: 342 | ``` 343 | find /media/NAS -not -path "*ExcludeDirectory*" -iname ".*" -type f -exec rm -rf {} \; 344 | ``` 345 | 346 | _Note: The filesystem must be writeable for this to work._ 347 | 348 | You can also add this to the crontab: 349 | ``` 350 | 0 1 * * * $HOME/Backups/dotfiles.sh 351 | ``` 352 | 353 | ## Setup Steam Controller 354 | The following instructions should allow you to use the Steam Controller wirelessly. 355 | 356 | Download and install the Steam Controller Python drivers: 357 | ``` 358 | cd ~/ 359 | git clone https://github.com/ynsta/steamcontroller.git 360 | cd steamcontroller 361 | sudo pip install libusb1 362 | sudo python3.4 setup.py install 363 | ``` 364 | 365 | Now create the file rules file: 366 | ``` 367 | sudo touch /lib/udev/rules.d/99-steam-controller-perms.rules 368 | sudo nano /lib/udev/rules.d/99-steam-controller-perms.rules 369 | ``` 370 | 371 | Then add the following to it: 372 | ``` 373 | # This rule is needed for basic functionality of the controller in 374 | # Steam and keyboard/mouse emulation 375 | SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", MODE="0666" 376 | 377 | # This rule is necessary for gamepad emulation; make sure you 378 | # replace 'pgriffais' with the username of the user that runs Steam 379 | KERNEL=="uinput", MODE="0660", GROUP="group", OPTIONS+="static_node=uinput" 380 | ``` 381 | 382 | _Note: Replace `group` with the group of user (e.g. `pi`)._ 383 | 384 | Now reload udev: 385 | ``` 386 | sudo udevadm control --reload 387 | ``` 388 | 389 | Start the driver and your controller should work: 390 | ``` 391 | sc-desktop.py start 392 | ``` 393 | 394 | To start the driver automatically at the desktop create the file: 395 | ``` 396 | touch ~/.config/autostart/Steam-Controller.desktop 397 | nano ~/.config/autostart/Steam-Controller.desktop 398 | ``` 399 | 400 | Add the following contents to the file: 401 | ``` 402 | [Desktop Entry] 403 | Exec=sc-desktop.py start 404 | ``` 405 | 406 | You can also install an on-screen keyboard: 407 | ``` 408 | sudo apt-get install florence 409 | ``` 410 | 411 | And then create a shortcut to it on the desktop: 412 | ``` 413 | touch ~/Desktop/keyboard.desktop 414 | ``` 415 | 416 | Then add the following contents to the file: 417 | ``` 418 | [Desktop Entry] 419 | Name=Keyboard 420 | Exec=florence 421 | Terminal=false 422 | Type=Application 423 | Icon=florence 424 | ``` 425 | 426 | ## Install Steam Link 427 | ``` 428 | sudo apt update 429 | sudo apt install steamlink 430 | ``` 431 | 432 | ## Install Docker 433 | ``` 434 | curl -fsSL https://get.docker.com | sh 435 | ``` 436 | 437 | ## Install Pi Hole 438 | ``` 439 | curl -sSL https://install.pi-hole.net | bash 440 | ``` 441 | 442 | ### Install DNS over HTTPS 443 | 444 | Follow Pi Hole's official instructions: [https://docs.pi-hole.net/guides/dns-over-https/](https://docs.pi-hole.net/guides/dns-over-https/) 445 | 446 | ## Install Useful Packages 447 | ``` 448 | sudo apt-get install tree screen tmux 449 | ``` 450 | 451 | ## Notes 452 | You can see the icons available for desktop shortcuts in `/usr/share/pixmaps/` 453 | 454 | ## Links 455 | - https://www.raspberrypi.org/documentation/configuration/config-txt.md 456 | - http://raspberrypi.stackexchange.com/questions/6682/stopping-rasppi-raspbmc-from-auto-changing-source-on-tv 457 | - https://www.raspberrypi.org/forums/viewtopic.php?t=100811 458 | - https://mtantawy.com/quick-tip-how-to-update-to-latest-kodi-16-jarvis-on-raspberry-pi/ 459 | - https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=150438 460 | - https://launchpad.net/ubuntu/trusty/+package/firefox 461 | - http://raspberrypi.stackexchange.com/questions/27179/automatic-mounting-of-nas-drive-fails 462 | - http://www.htpcguides.com/properly-mount-usb-storage-raspberry-pi/ 463 | - http://www.miqu.me/blog/2015/01/14/tip-exfat-hdd-with-raspberry-pi/ 464 | - https://github.com/ynsta/steamcontroller 465 | - http://askubuntu.com/questions/686214/how-do-i-get-a-steam-controller-working 466 | - https://www.raspberrypi.org/forums/viewtopic.php?t=18968 467 | - http://www.techrepublic.com/article/five-tips-for-getting-the-most-out-of-a-raspberry-pi-3-as-a-pc/ 468 | - http://raspberrypi.stackexchange.com/questions/44384/how-to-get-chromium-on-raspberry-3/44690 469 | - https://www.raspberrypi.org/blog/introducing-pixel/ 470 | - http://alanwsmith.com/rsync-exclude-list-for-mac-osx 471 | - https://kuttler.eu/en/post/sshfs-transport-endpoint-not-connecte/ 472 | - http://www.omaroid.com/fstab-permission-masks-explained/ 473 | - http://askubuntu.com/questions/429848/dmask-and-fmask-mount-options 474 | - http://askubuntu.com/questions/609003/mount-exfat-warning 475 | - http://blog.marcelotmelo.com/linux/ubuntu/rsync-to-an-exfat-partition/ 476 | - http://stackoverflow.com/questions/2135478/how-to-simulate-the-environment-cron-executes-a-script-with 477 | - https://kwilson.io/blog/format-a-linux-disk-as-ext4-from-the-command-line/ 478 | - http://anonexp.blogspot.co.uk/2013/04/ext4-mount-options-for-ext4-file-system.html 479 | - https://unix.stackexchange.com/questions/114485/fdisk-l-shows-ext3-file-system-as-hpfs-ntfs 480 | - https://gordonlesti.com/mount-ext4-usb-flash-drive-to-raspberry-pi/ 481 | - https://github.com/moby/moby/pull/24815 482 | - https://www.jaredwolff.com/raspberry-pi-setting-your-locale/ 483 | - https://help.ubuntu.com/community/MountWindowsSharesPermanently 484 | - https://serverfault.com/questions/367934/how-do-i-pass-credential-file-to-mount-cifs 485 | - https://www.jeffgeerling.com/blog/2017/mount-raspberry-pi-sd-card-on-mac-read-only-osxfuse-and-ext4fuse 486 | --------------------------------------------------------------------------------