Monday, December 18, 2017

Raspberry Pi Server: SVN Upgrade

My original plan was to upgrade my Raspberry Pi server to a new Pi 3, and use the original Pi 1 B+ for the Retro Pie. I've since backtracked for various reasons and put the Retro Pie SD card into the new Pi 3. So now my original server is back on the Pi 1 B+. The server had been working great except it was running out of disk space (only had a 4 GB SD Card).

Fairly simple to solve, I'll just use an external USB drive for storage! I plugged in a 32 GB USB drive, and now I needed to move my repository.

First I needed a folder to act as my reference location when I wanted to access the USB drive. It doesn't matter too much where, I went with: /media/usb

Created the folder with: sudo mkdir /media/usb
Set the ownership of the folder with: sudo chown pi /media/usb
Set the permissions of the folder with: sudo chmod 0777 /media/usb


After plugging in the USB device, I needed to know the device UUID by typing: sudo blkid


Then I needed to edit /etc/fstab for it to automount on boot: sudo nano /etc/fstab


For my new mount, I went with:
UUID=390A1652      /media/usb      vfat    uid=pi,gid=pi,umask=0000,sync,auto,nosuid,rw,nouser,nofail 0 0


As an alternative, I could specify to automount any USB drive that is plugged in as /dev/sda1. That seemed risky to me though as my current drive could change and the new drive could connect as /dev/sda1. That new drive wouldn't necessarily be vfat.

If I had wanted to mount any USB drive, the line would have read:
/dev/sda1        /media/usb      vfat    uid=pi,gid=pi,umask=0000,sync,auto,nosuid,rw,nouser,nofail 0 0

Lots of options and opinions on this:
uid & gid are my username; some references suggest entering the numeric value. You can check your account's id by typing: id -u and id -g. Turned out my pi user was 1000.
umask=0000 is the equivalent of chmod 0777 (everyone has read/write access).
sync has input and output be synchronously.
auto instructs the drive to mount automatically at bootup.
nosuid I don't understand, but one reference says: Block the operation of suid, and sgid bits.
rw to mount the drive with read-write access.
nouser permits only root to mount the filesystem.
nofail causes startup to not wait 90 seconds / error out if it fails to find the drive.

And finally reboot the Pi via: sudo reboot

The next task was to move my existing SVN repository to the external drive...

I stopped Apache which is used for SVN: sudo /etc/init.d/apache2 stop


I copied the repository over: cp -r repos /media/usb


Then I modified the Apache configuration to point to the new location of the SVN repository. The config file is located in /etc/apache2/mods-available, file dav_svn.conf: sudo nano /etc/apache2/mods-available/dav_svn.conf


My SVNParentPath was /home/pi/repos, I changed it to /media/usb/repos


Apache actually needs ownership of the repository folder, so I changed ownership to www-data: sudo chown -R www-data:www-data /media/usb/repos


And finally, restart Apache: sudo /etc/init.d/apache2 restart


I did a full restart to make sure everything came back up, and it did! So my SVN repository now has 32 GB to play with; far better than the few hundred MB from before.


The above instructions were mostly just for my reference in case I need to do this or similar again in the future, but I hope it can be of help to others!


Monday, December 11, 2017

Retro Pie

I've been playing some classic games on my laptop with emulators, but it's just not the same as on the T.V.. I had some time over the Thanksgiving holiday to do something about it. I've read many other sites using Retro Pie and decided to go with that.

I'm reusing my original Pi B+, but its existing 4 GB SD Card was inadequate for the task. So I picked up a new 16 GB card...



Downloaded Retro Pie off the website... Their instructions were fantastic: https://retropie.org.uk/docs/First-Installation/




Then got Win32 Disk Imager...


And used it to write the image to my SD card...


On the left is my existing Pi in its case, and on the right is the "Super Tinytendo" case I bought off Amazon for $20. The build quality on the Tinytendo is great. (From the reviews, it sounds like their first versions with rough 3-D prints. The one I bought however was injection modeled and of very high quality.) 


4 screws underneath to open the case...


And the Pi fits perfectly inside...


The power light in front is functional; the instructions were very simple and spelled out in the Tinytendo manual. The Power and Reset buttons are unfortunately not functional. It'd be interesting to make them so though.


I ended up overclocking my Pi B+ so it could handle SNES games better (more on that below). So out of precaution I added a heat sync from Adafruit over the CPU.


First boot!


RetroPie only shows emulators for the corresponding games it finds. So at first boot no emulators are shown; you have to load them up. ROMs can be added via USB, SFTP, or Samba share. Since I'm primarily a Windows user (uhg), I went the Samba route. The Samba Share was super easy to access and copy ROMs to. Just type \\retropie in file explorer and you're there!


After a reboot the appropriate emulators showed up!


Some of the SNES games were running a bit slow, so I decided to try overclocking. You can access the Raspberry Pi config options through the Retro Pie menu.


Selected the overclock option...


And set the overclock to Medium. The games are working reasonably well at this level so I'm hoping this will suffice.


I'm using two Logitech Gamepads for the controllers. They have a good layout for both NES and SNES systems (among others), but they also have a few additional buttons not used by those earlier consoles. I'm using the rear-most left button as my hotkey button. If I push hotkey + rear left then it loads my last save state; hotkey + rear right saves my current state, and hotkey + start quits the current game.


The Pi rounds up a nice collection for entertainment - Switch (newest) on the left, N64 (the best) in the middle, and NES/SNES (the classic) on the right.