The Joys of Linux
So you know how you will always have a project that you you will come back to and inevitably something will have broken? Yeah that’s pretty much my relationship with the Raspberry Pi. as a big believer in open source and the community I inevitably every six months say, “I should wipe my OS and move to Linux and become a real Nerd”. Then I always say to myself “Hey you should do a Pi project before you make the jump”. And then I spend 3 days trying to figure out what the hell I did to mess up this piece of hardware that has just been sitting on the shelf for 6 months.
So like I said I pick up this Pi about every 6 months and say that I am going to do something with it and eventually get bogged down at work or I start a new coding class because I don’t like free time and I have always been exceptional at picking up more projects then I have the ability to take breaths. Which ironically I think that is partially the reason why I started “this” project… my blog. It is supposed to be here as documentation, to keep me focused and help my organize my thoughts and goals in a productive manor rather than attempting to grasp at them as they float by in my head.
So my reasoning for getting started again with the Raspberry Pi kind of revolve around the Iot space. In the past couple of years I have become fascinated with this space in technology and its applications within the Transit Technology community. So the purpose of this “for me” is to set up a remote development environment so that I can connect to my Pi without having to set up accessories for it and it allows me to use VSCode or PyCharm without bogging down my Pi.
In this post I am hoping to accomplish a couple of things:
- Document out my frustrations with Linux
- Spell out how to do a fresh install of Raspbian on your Pi
- Connect to your Pi via SSH and Remote Desktop
- Manage your Pi files and write code remotely from your local machine
Things you will need:
- A Raspberry Pi (with sd card)
- A Windows machine that has a way to write to SD cards
- A copy of Raspbian
- A copy of Win32DiskImager
Wipe the damn thing
So like I said this is going to be a complete restart. I just decided that I wanted to do a full wipe of the SD card as I was just having some difficulties working with the install that I had tried to update. This section will cover how to wipe your SD card and reformat using Window Disk Management.
- Connect the SD Card Obviously the first thing that you need to do is get your card setup. Whether that is though a port in your local machine or an dongle just get the SD card connected so that your computer can read it
- In the Windows Menu type “Disk Management” A program will pop-up in the menu bar saying “Create and Format Hard Disk Partitions”. Open that program
- Look for your SD Card When the program loads up look for your SD card listed. If you already have a copy on there it will have a partition called “boot”. If not just make sure it matches the disk name that popped up when you inserted the card.
- Wipe out all of the partitions. When you open up Disk Management you should be able to right-click on each of the partitions that are set up on your SD card. Click ‘Delete Volume’ for each of the partitions so that you can start fresh. At the end you should just have an unformatted partition that takes up the whole disk space.
- Go to the Raspbian Site and download the latest version. For this instance I would just reccomend that you use the full download with recommended software. This will get you setup with the raspbian cli and gui all in one without additional configuration.
- Unzip the files
Write IMG file to SD card
- Download and install a Copy of Win32DiskImager
- Move the IMG file to the SD card.
- Insert the SD Card After inserting the SD Card you should be able to boot up the machine. Connect up a mouse keyboard and monitor to continue with setting up the internet through wifi or LAN connection.
For sanity sake. Go ahead and update everything by opening up terminal on your pi and running.
This is going to take a while. So make sure that you have the time to run. So make sure that you will be able to leave it running with a secure internet connection.
sudo apt update && sudo apt full-upgrade -y
In this section we are going to cover how to connect your main computer or laptop to you pi via ssh. This is how we will be able to run commands via the command line to execute processes in terminal or windows.
- Boot up your Pi If your pi is not already on and connected to the internet go ahead a do that now.
- Open up ‘Raspberry Pi Configuration’ settings To do this you are going to want to click the start menu at the top left of the screen (The one with the raspberry). Go to preferences > raspberry pi configuration
- Click the interfaces tab
- Enable VNC and SSH In the pi configuration window, the second tab allows you enable and disable certain functions. You are going to want to enable VNC and SSH here.
Config Main Computer (Windows 10)
- (On your Pi) open up the terminal and type
sudo ifconfig. Under
wlanyou will see an ip address next to inet. This is the pi’s ip address and you will need this to connect to the pi using putty.
- (On Windows) Download Putty
- Once you have downloaded and installed Putty open it up and create a new connection by inputting the ip address and using port 22
- Once you have add all of the inputs and saved the connection click open and this will open a terminal window.
- This window will prompt you to log in to your Pi by asking for your user name and password. The default username is pi and the password is raspberry.
- Once you fill out this information you should be logged into the device. If you get errors, go back and check the ip address that you entered is correct and that you have turned on all of the necessary permissions for ssl connections.
Remote Desktop (VNC)
In this section we are going to go over how to connect via ‘Remote Desktop Connection’ on Windows 10. This will allow you to actually see what is happening on your Raspberry pi in realtime via your main computer or laptop. Just like SSH this will only cover how to do so when both devices are on the same network connection.
On your Raspberry Pi
- Install the xrdp packages by opening terminal and running
sudo apt install xrdp
This should only take a couple of minutes, but it will require you to have an internet connection to your Pi to download the software.
- In the SSH section you should have already enabled VNC on your Pi, but if you are not sure go back to step 2 in the SSH Config Pi section On Windows
- Open up your Remote Desktop Connection
- Type in the IP address that you used to SSH into your Pi
- When prompted enter your Pi username and password
- BOOM! Ya done son.
Access Pi files from Windows File Explorer
- Connect to Pi via SSH (using putty again)
- Navigate to the root directory by running
sudo apt-get install samba samba-common-binto install networking tools
- [Windows] in command prompt run
ping raspberry pito make sure you can connect to the pi.
- [pi] run
sudo cp smb.conf smb.oldto save a copy and
sudo nano /ect/samba/smb.confto start editing. This will open up the smbdgat.conf file to be edited via in command line
security = user
read only = no
- Hit CTRL+O and then ENTER to save the file.
- Then Hit CTRL+X to exit nano.
- In the pi terminal. Run
sudo smbpasswd -a pito set the samba password
- Type in and confirm your password to set and save.
- Restart samba by running
sudo service smbd restart
- [Windows] Open up file explorer and right-click ‘this pc’ > map network drive
- type in ’\raspberrypi\pi’ and set to different credentials hit okay and it will prompt you to sign in.
- There should now be a mapped pi to your file explorer and you can now transfer files between the 2.
https://www.raspberrypi.org/documentation/installation/installing-images/ —> Reimage Pi SD Card https://www.raspberrypi.org/magpi/ssh-remote-control-raspberry-pi/ —> SSH Tutorial http://www.circuitbasics.com/access-raspberry-pi-desktop-remote-connection/ —> Remote Desktop Connection https://blog.jongallant.com/2017/09/raspberrypi-file-share/ —> Install and Configure Samba https://www.youtube.com/watch?v=4P5nEH9zGDI —> Video on mapping pi as a network drive