Basic setup for all Raspberrypi projects

This is a starting point that I do on every one of my raspberry pi projects. You can branch off from this point to any number of projects. I used to like a screen and keyboard/mouse interface, but this is how to set up a headless rpi that you only control over the network. it is much easier than it sounds.

Hardware:

  • Raaspberrypi startup kit with power cable and SD card.
  • Computer (I have windows 10 but there are guides out there for mac and linux as well)
  • Wireless network to connect to
  • Maybe a camera to format the SD card?

Software Tools required :

  • SD card formatter (I use a DLSR camera because sometimes even this tool won’t format the cards right)
  • Balena etcher to burn the raspberryPiOS to the SD card

Firstly, I downloaded and installed the latest raspberrypiOS Lite to an SD card. Once it was installed, I reinserted the SD card into my laptop and created a wpa_supplicant.conf file in the partition I was able to open in windows (one will be openable, the other won’t be). This file sets up your Wifi settings so you can control the pi remotely instead of trying to find the right HDMI or component cable an display and connecting a keyboard and mouse to it.  I can simply ssh into the Rpi and run the scripts I need. This may sound intimidating, but it isn’t too hard at all.

Open a text editor (NOT word or notepad, download something like Sublime3 or notepad++) and create a new file names wpa_supplicant.conf. Paste the following and make sure to enter your WIFI’s credentials and keep the quotation marks.

country=US
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
scan_ssid=1
ssid="Put your networks SSID here"
psk="Put your networks password here"
}

That will get the pi on the network, next we need to be able to actually control the Rpi from another computer on the network. To do so, just create a blank file with no file extension named “ssh” in the same SD card partition as wpa_supplicant.conf.  That’s it. This empty file just tells the Rpi to turn on ssh, which allows you to connect and control it remotely.

Now you can insert SD card into Rpi and plug in power to boot up.

With my older Rpi3 I give it like 5 minutes depending on the OS. Then you can check to see if your Rpi is on the network.  Open the command window in windows (windows key, then type “cmd” then enter) and type

ping raspberrypi.local

You should see a response. If it times out, then give it a little more time to install the OS and try again. If you can’t ping it (communicate with it ) after 15 minutes after you booted t up (or 30min or longer sometimes for a pi Zero w) need to start from scratch because something went wrong in your wpa_supplicant file. Triple check that the file is not saved as “wpa-supplicant.conf” or “wpa_supplicant.conf.txt” For that last one you may need to “show file extensions” in window’s explorer.

I always used putty to ssh into linux machines from windows, but Windows 10 apparently has ssh built right in, so you can just click the windows icon and type “powershell” to open a command window, then enter

 ssh **@*********pi.local

We’ll use powershell instead of the Cmd window to allow us to copy and paste stuff into the window easily.

The first time you do this, it’ll give you a warning that it “can’t verify the [raspberrypi], do you want to continue”  just type “yes” and hit enter. Then you will be asked for the password. Note that as you type, you will see no letters appear in the terminal. This is normal for password entry on linux machines. The default username is “pi” and default password is “raspberry”.  When you type it and hit enter you should see a green line that says “pi@raspberry” which means you are logged into the pi.

The first order of business is to change the default password. type the following:

passwd

Enter your new password and you’re set. Now you can go off doing whatever random things you want to use the Rpi for.

To copy and paste into the SSH window you may need copy as usual form a webpage then right-click into the powershell window (maybe do this twice if you hadn’t already selected the powershell window) and it’ll automatically paste it for you.

Static IP: Next I like to set up a static IP address for my Pi so I always know where it is. This also helps things like streaming a webcam for Octoprint since the address won’t change. Android phones won’t use the mDNS entry of “raspbeypi.local” so if you want to use your phone to control or view things on the pi you need to set a static ip. Do so by issuing the following command:

sudo nano /etc/dhcpcd.conf  #this opens nano command line text editor to the IP address file...

My pi is on wifi  so I’ll adjust the wlan0, but you can replace this with “eth0” if your pi is using ethernet.

interface wlan0
static ip_address=192.168.0.100/24    
static routers=192.168.0.254
static domain_name_servers=192.168.0.254 8.8.8.8

This way I know all my raspberrypi stuff is found at 192.168.0.100. I can just type that in for ssh, or into a browser if I’m running a server on it (like octoprint, hassio, mjpg streaming video, etc.

Remote Desktop: To make it easier to connect to the pi in the future and to remote into it and control it’s graphical desktop from any other computer (such as your desktop or laptop), you can set up your pi to allow VNC. First, in your ssh terminal, we need to enable VNC.

sudo raspi-config

Then use arrow keys to select “Interface Options”.  Select “VNC” and you’ll be prompted to enable VNC the server. Then you can exit Raspi-config. On your desktop/laptop/other computer you need to install a VNC viewer which will allow you to connect. Visit https://www.realvnc.com/en/connect/download/viewer/ and install it. You should then be able to connect via the IP address of the pi, login to it and have full access and control as if you controlling it with your keyboard, mouse and monitor.

 

Remote shutdown:

Next you need to know how to shutdown and restart your rpi safely. It is a computer after all and I can’t tell if  just unplugging power will corrupt the SD card, so a safe method of shutdown is required. I use a couple. There’s a script you can add to allow shutdown by connection one of the GPIO pins to ground. This is essentially what you do on a regular computer’s power button. You tell the computer you’d like it to shutdown so it will trigger the shutdown functions. Secondly, you might want the ability to shut down or restart via ssh.

sudo shutdown -h now

or

sudo poweroff

and a restart is

sudo reboot

I’ve added a plugin and scripts to my octoprint setup to do the GPIO and I can shutdown from the web interface.

 

Now if at any point you mess up and can no longer communicate with the pi (setting the wrong IP address, etc) simply format the SD card in windows or in a digital camera and try again.

I recommend once you get all your settings correct, you backup your Rpi OS periodically. There’s a script that you can use to copy a bootable filesystem to another (can even be smaller) SD card you plug into a USB card reader on the pi.

Ukulele Repair

imageA few months ago, Jess accidently stepped on one of the ukuleles neck and broke the neck in two. Here you can see the break. It broke at the splice that was already in the neck. The fretboard came off at that spot as well.  We had recently build a ukulele from a kit, so we knew what to do.

The first step was to glue the two pieces of the neck back together.  I cleaned up any badly-fitting sprigs of wood and mated the two pieces together dry to find the correct length. If it isn’t the correct length, then the fretboard won’t fit back correctly and the scale will be off.

 

image

Once I got the placement correct, I used Titebond II mixed with a little water to thin it out and used a paintbrush to apply a thin layer of glue to both sides of the break.  I clamped it with a mini cam clamp and left it for 24 hours to dry.

image

Once this was done, I attached the fretboard piece. Due to the way it broke, I had to file down a couple places before it would fit correctly. I used the same mix of glue and water as before to attach it.  I clamped it with two large 24” bar clamps. I used these because the large foot applied even pressure on the face of the fretboard. Again, I left it to dry for 24 hours.

Finally, there was one loose fret and a couple of places where the fretboard didn’t seat fully, so I used water-thin super glue to wick into those gaps and used the bar clamps again to apply even pressure.

With the exception of the fret I replaced being a bit too low, and the chunk missing from the back of the neck, it is as good as new! There is only a very slight buzz on one string due to the fret I replaced being too low and I’ve since been too lazy to fix it. Otherwise the uke plays as good as it did before the accident.  I think the key is patience with this type of project. We learned that with the uke kit we built previously. You absolutely can’t rush things else you will ruin them.

Building a Zen Meditation or Seiza Bench for better Posture at my Desk

I used to have a standing desk for years, but since we moved, I haven’t found a similar solution. My posture is suffering because of it. I discovered that by resting on my knees at my computer desk, and raising my computer screen a bit I can get back in to the correct posture. I realized I could build a seiza bench would be the best solution to add a bit of support and reduce stress on my knees.

I began with an exhaustive search online but ended up just making my own. The design I liked most was this travel seiza bench from Sakura Co.  While they list the dimensions on their site, I found that to be too short for my needs. I experimented, having my wife help measure how high my butt was from the ground when I was in the best position, but the best experimentation was when I went to build the bench in the garage. I sat on a bucket which happened to feel like a comfortable height. I have a variety of buckets in the garage so I tried them all out. I took measurements of the ones I liked most and went about freestyling the design.

I had an old 7 1/2” wide by 3/4” thick pine board from a previous project laying around the garage, so I began with that. I laid out the 2 heights I measured and drew a diagonal line to connect them. This will be the final angle of the bench. Then I went about measuring and calculating the tab lengths. Here’s what I ended up with.

image

In that pic, I had already made my first cut. Basically the back of the bench is 11 3/4” tall, the front is 10 1/4” tall. this is a pretty steep angle, but I feels acceptable so far as I’ve been using it, though I haven’t used it much yet and I may end up making a different angled bench.

The tab that sticks up at the top rises about 2 1/8” above where the bottom of the seat will be. It has to be high enough to go through the seat and accept the holding pin to mount the legs with a bit of material on top of the holding pin. That’s how I came up with that measurement.

I tweaked the design from the inspiration more by having my tabs move at a 90 degree angle from the slant, rather than follow the edge of the board as in the bench form Sakura Co. This makes is far easier to construct.

This entire project can be built using 1 pine board, electric drill with a 3/4” drill bit, and a jigsaw. I had other tools available so I used a circular saw to cut the board all the way across as you see in the above pic.

Next, I used the bandsaw to cut the excess material away from the tabs. You can see that I forgot to tune my bandsaw before cutting.  This board looks pretty janky.

image

At this point, I messed again when cutting out the hole for the pin to fit into. I thought it’d be smart to drill a couple of holes just big enough for my jigsaw blade to fit into. I should have used the largest drill bit that would fit the hole instead.  This made for a nasty cut where the pin is supposed to be tight.

The idea is to drill a hole or two to give your jigsaw blade enough room to cut the edges and the corners. It takes a few passes from different angles, but I got it done. Now I got my 30+ year old jigsaw out of someone’s garbage can… it’s missing a few screws, but gets the job done, even if it isn’t very clean.

image

image

The next board was easier to cut since I tuned up the bandsaw. It came out with much cleaner edges.

image

I made the same mistake of using too small a bit to drill the hole, however I did learn something.  When drilling the hole in the first leg using the spade bit, I just drilled all the way through.  This tore out the back and made a nasty edge.

image

This time, I drilled a into the piece from one side until just the tip of the spade bit poked through the back and I stopped. I flipped the piece over and placed the tip into the hole to line it up and then drilled the rest of the way through the wood. This left a much cleaner edge.

image image

I’ll spare you the carnage from the jigsaw. It was better than the first one, but not good overall.

I then moved on to the seat. I cut a 22” long piece from the board. I measured 2 inches from each end to begin marking where I wanted the legs to mount. Due to the slat, the legs will stick out a bit from the seat about 3/8”.  I decided to make the front of the legs flush with the seat and allow that excess to hang out the back. No one will notice that, and I won’t be annoyed by it while using it.   I drew an arrow on each of the 3 parts to determine which side was the front. Then I traced the outline of the tabs for each leg on the seat board. I want as tight a fit as possible with this so it doesn’t wobble when I sit on it. Since each leg’s tab is a bit different due to my excrement woodworking skills, tracing the actual shape of the tab will get me a closer fit.

image

This is when I wised up about the spade bits. I mounted a 3/4” spade bit into my drill press and used the trick of going not quite all the way through the board, flipping it and drilling from the other side for a cleaner hole. Somehow I still managed not to get it perfect.

image

I made the edges and corners straight with the jigsaw again on each side.

Then I used some scrap wood and cut the pins on the bandsaw. I didn’t get a pic of them alone, but I made them wedge shaped with 2 right angles and a slanted side. One side 3/4” tall and the other 2 1/4” tall. The bottom edge (the longest edge which is at right angles to the sides) is 3 1/4” long.  I made two of them.

To even out some of the nasty straight cuts, I went to my trust poor-man’s belt sander setup by clamping my handheld belt sander in my workmate project center and locked the trigger in the on position as I maneuvered the parts on the 150 grit sandpaper. Put  the puzzle together and you have a bench!

I use a pillow on the ground under my knees to add some comfort, and I may eventually get either a couple of gardening knee rests (one for my knees and the other for my bum) or an hammock pillow for the seat. Given the ridiculous costs of hammock pillows though, I might just make a thin seat rest pillow myself to tie around the seat.

Loom and Guitar or Ukulele Strap Weaving

image

I became fascinated recently while browsing pinterest by examples by different weaving techniques. I began researching one method in particular called card weaving or Tablet weaving. Evidence shows it was used as far back as about 3,000 years in Europe. The fascinating part is that it is one of the earliest methods of algorithmic programming.

To do tablet or card weaving, you need to have some cards with holes in the corners. Through these holes, you pass threads of different colors. With every pass of the horizontal thread, you’ll spin the cards either forward or backward depending on what your pattern is. These designs are typically used to create belts or edging material for garments. Jess said this method was similar to making friendship bracelets. I wanted to build a ukulele strap for the ukulele Jess and I built a couple of years ago.

The first thing to do is create some cards. I used some larger-than-normal playing cards I got at the dollar store. These aren’t the best quality paper but they are glossy and slide across one another easily. Cut them to be square and I even rounded the corners with a corner punch to make sure they don’t snag on the corner when I spin them. I then used a hole punch to pinch a hole in each corner. I started with regular playing cards, but quickly realized that the larger the card is, the easier it is to use.You can see the steps below and the beginning of the cutting of the larger cards.

image      image

The next step is to have a loom. There are many different designs of looms. Some people simply tie one end of the strings to the back of a chair, and the other end to their belt which is the simplest method, however it isn’t easy to use. If you are just starting, this might make a lot of sense, but I was not successful with getting quality results this way.

Another loom design essentially uses a wooden box (box loom or rigid heddle looms) of some type that keeps about 2 feet of the threat taught, allowing you to weave easily. Here’s a version you can make out of PVC. Here is yet another PCV design. When you weave longer pieces, you can roll the threads onto spools at each end of the loom keeping the portion you are working on tight.

The loom style I chose to build was called an Inkle Loom.(Here’s a PVC inkle loom).  This is a traditional loom design that allows you to wrap the threads fully around a zig-zag path and tie the ends together to make continuous loops. To build this, I used the left-over parts from our Ikea Snigler crib hack shown here. I had half of  the crib wall sitting in the garage so I made a couple of cuts and screwed them together with 3” long screws (drilled pilot holes first of course).

image

image

It isn’t the most sturdy design as the dowels are mostly friction fit. A few have staples that somewhat hold them in. I can use it for this project and a few more without having to add additional support.

The next part that is required is the shuttle which holes the thread which is passed back and forth during the weaving process. I cut a piece of scrap clear acrylic on my bandsaw to look like a kite string holder and sanded the edges so they had a smooth radius. This makes sure it won’t catch other threads while weaving.

image

Now for the design I wanted to weave. I came across this particular pattern on pinterest from user Silvia Dominguez who has many great designs available.

card weaving pattern The way to read this chart is to look first at the little design on the bottom. It is 4 blocks high by 26 columns long.

imageEach column refers to one card or tablet. This means we will need to use 26 card (or tablets) each with 4 holes and threads through those holes. Each hole on the card should be labeled A, B, C, and D respectively and the color of each hole is listed from the bottom up in the design. i.e.
D
C
B
A

The design refers to the colors of each of the threads that are threaded through the each hole of the card.  I used 2 color of size 10 crochet thread. I got a light green and a darker green color to represent the grey and black of the design. Pull the strands out to the length of the finished object plug an extra 12-18 inches or so. For example, starting at column 1, it will use 4 strands of the light green in my case so I cut long lengths of thread for that card. Looking at a more complicated column, you can see column 4 uses two light threads and two dark threads, etc.

The next step is to thread the cards or tablets. It is very important how threads enter the cards. This is listed below each column. Depending on how they should be threaded, it is referred to as either a Z or an S. If you imagine your card on edge, the threads should come from the top of the loom into the card (top to bottom in the image below) If a card is a S card, all 4 threads enter from the left and exit the card on the right side. Here is a close-up of the rightmost column. You can see how all 4 of the threads enter the card with this angle\” like the middle of the letter S. This page (use google translate to read it) shows in detail with better graphics how this works.  image

Z cards of course enter on the right side and output on the right with an angle like “ / ”. 

The Z or S will allow the weave to be tight and you can actually tell the difference when looking at the end result.  If you have some of the threads on one card S and some Z, then the cards won’t spin and you can’t weave so be careful when doing this. Also, make sure to keep the cards in order.

Next wrap each set of 4 threads on the loom, zig-zagging on the dowels until you can just tie the ends of the strings together to make a continuous loop. The cards should be in the clear area (not inside the zig-zags). The threads should be a little taught. Not so tight that the cards can’t spin and not too loose that there’s a lot of slack in the threads. I actually ended up using a fisherman’s knot (basically two slip knots tied together) which allowed me to adjust the tension of each set of 4 threads as needed throughout the weaving process.

image

 

Once you put all the threads on, align the cards so that the A-D sides of the cards are facing you all facing you. Next wind some thread on the shuttle. I did about 4 times the length of the other threads. You only need one thread on the shuttle.

A little weaving nomenclature: The long threads on the cards are called the Warp and the thread on the shuttle is called the Weft.

imageImage Source: https://buddhajeans.com/encyclopedia/warp-weft-diagram/

The area of space that is lofted by the cards is called the Shed. To weave, you pass the shuttle through the shed, then spin the cards to zig-zag the warp over and under the weft. Once you’ve done this that horizontal line is called the Pick. To begin, literally just leave an extra 6 inches or so of thread off the shuttle and just pass the shuttle through the shed. Once you do this you need to turn the cards. That’s where the larger portion of our design comes into play.

card weaving pattern

Start at the bottom at row 1. Once you’ve passed the shuttle through the shed, you’ll spin the the cards either forward or back based on which pick you are working.  In the yellow section it will tell you which cards will move forward and which will move backwards. I chose this design for its simplicity.All the cards are moved in the same direction. More complicated designs get really crazy and hard to follow. In this case, pick 1 rotates all cards forward. Once you spin the cards, you need to beat the previous pick with the shuttle to make it tight, then pull the slack out of the weft thread before doing the next pick.

I came across this site which was this person’s first tablet weaving project as well using the same design. She linked to a dead link to where she first saw this design. I found the wayback machine’s cache of the site and it turns out they used the same colors I did! I found NorseGirl’s website which did this design and uses the same colors. so much for being original, haha.

Once I wove about 4 feet of material,  I cut off the excess leaving about 1 foot on the end where the cards were. Jess braided these into a cord (which seems to be a traditional method of finishing the end). One the other end, I sewed a hem so it wouldn’t fray on that end and then sewed it to a 1.25 inch strap slider. I only needed 1 and was able to get it at the local outdoors store for less than $1.

 

Turn an old Computer into a Local Fileserver (Mostly Graphical Setup)

We’re running out of space. With photos, astrophotography files, and music recordings and work and just life stuff; we are running low on hard drive space. Over the years we’ve bought a few external USB hard drives but even those aren’t manages well and being portable get moved around a lot. That’s not the safest way to handle hard drives. Unless they are SSDs, they can be damaged by moving them around and such. We needed a better solution. I prefer using GUIs to set things up but will for through the terminal if I have to… I just haven’t used my unix fileserver skills since I worked in IT and my linux is a bit rusty as well.

Googling around you’ll find a ton about setting up a NAS or RAID5 or somesuch, but that’s overkill. I’m not looking to spend any money with this, otherwise I’d just have bought yet another portable drive. I already have a bunch of hard drives full of stuff (and honestly, there are a LOT of duplicates of each file taking up tons of space from the crappy way I store my backups). I want to use those drives and be able to clean out the duplicates to gain space. The first step is to build a basic file server.

I had a linux machine (my workhorse during grad school) that wasn’t being used, and  bunch of old hard drives that I wanted to use/access  It was a variety of drives from old PCs (back to win XP actually, and even older). I had a few external drives that broke so I just plopped them into this machine as well. I didn’t want to format them for a RAID or anything as they were all different sizes and I had data like pics and projects and work stuff from ages ago on them I wanted to keep. The best solution for me was the JBOD (just a bunch of drives) style server. All the NAS examples looked annoying to setup and I’d easily forget what I had done to set them up so JBOD it was.  I couldn’t find any single document explaining how to do all the steps I wanted so I spent a couple of weeks failing in my spare time… breaking and unbreaking my linux fileserver and documenting the working parts here for when I need to work on it again. I prefer doing things with GUI if possible, but I’ll do some things using the terminal because you just have to but I tried to keep it to a minimum.

Installing Linux:

If you don’t already have linux running on this computer, I suggest you install it. It sounds hard, but it is super easy to do actually. Just download any flavor of ubuntu you like (lubuntu, kubuntu, linux mint, cinnamon, etc.) I recommend the versions that say “LTS” as those are supported for 2 years or so. There’s a lot of options here.

Install linux without formatting hard drive or losing data:

  1. Download Wubi. This will let you install linux without killing your windows files or messing anything up. you can always uninstall linux later if you want using this method.

Start clean on either blank hard drive or format an old drive:

  1. Download ubuntu flavor you prefer
  2. Format a USB flash drive that’s at least 2GB (lubutnu and xubtunu) or 4GB (all other flavors).
  3. Use Balena Etcher to burn this ISO file to the USB drive.
  4. Once finished, you can reboot your computer.
  5. Enter the boot menu when you see your computer’s startup logo (before windows logo) by pressing either F10, F11, F12, or the delete key. Different manufacturers have different keys they choose for this.
  6. Select to boot off the USB drive.
  7. Doubleclick the icon on the desktop to install *buntu. Follow the menus or youtube videos on how to install it.
  8. Remove the USB drive and reboot when done.

I was already running ubuntu so I just needed to put all the drives in the computer case. I could have 2 drives that were IDE on the same ribbon cable, and 4 SATA drives on the motherboard of my old linux box. Sadly, that’s all this mobo could accommodate. I see spots for 4 more SATA drive on the PCB but they aren’t populated. I filled all 6 spots with drives, making sure that all the drives were set up as slaves except the bootable one (see another post about how I set that up).  I also had a TON of USB ports on this motherboard as well (literally 6 on the back, 2 on the front and I added 2 more to a breakout cable inside for a total of 10 USB ports). These can add more portable drives and other drives with some of  these awesome USB to IDE/SATA drive cables I have to the server. As I loaded these drives in the bays I made a note as to their serial numbers and capacities. I wrote it on paper, but I also used a sharpie and wrote it on the chassis so I could keep track of what is what and where.

When I turned the machine on, I went into the BIOS and set up the boot order for the hard drives so that my /filesystem always boots first in order of hard drives.  When booting the linux machine, hold the Delete key to enter BIOS. Then go to Advanced BIOS Features.

bios1

Next select “Hard Disk Priority”. Here’s what that looks like:

bios2

Finally, use the arrow keys to select a particular hard drive (the one you want to boot from) and then use the + key to increase its priority until it is number 1:

bios3

Once this is done, Hit F10 to save and exit BIOS. It will reboot the machine into linux as it usually did.

Accessing all the Hard Drives:
Open your ubuntu menu and search for the “disks”  program. This should be part of gnome-system-tools, which is a standard program in ubuntu. If you don’t have it then open your package manager and search for it. Mark it for installation and click the “Apply” button. or open a terminal and enter the following:

sudo apt-get install gnome-system-tools

You can copy that line of text paste it into the terminal using ctrl+shift+v to paste in a terminal.

All your hard drives should be visible in the Disks app. It lays out all the gory details. Serial numbers, model numbers, etc. Click each drive in the left and note what the “mount point” is for them. I have my Filesystem (this is where I installed the linux operating system)  and /home mount points on separate drives. /home is like the user folder in Windows with a folders for Desktop folder, Documents folder, etc. Separating this from the operating system installation file tree allows me to reinstall linux without breaking my user’s documents and settings and Desktop items, etc. I have another post on that and it has served me very well over the years.

For my other drives, they have mount points that start with /mnt  and end in a weird code.  That code is the UUID (hardware ID) for that hard drive and it isn’t very descriptive for humans.  Let’s change that to something helpful. For instance I changed my 1TB drive’s mount point to /mnt/_old_1TB_MyBook

image

Once all the drives have normal names click the link to one of them and it’ll take you to the folder in your file browser. Go up one directory to see all the hard drives. You’ll note the old folders with the UUIDs in there as well as any old names you had mounted in the past, but they are empty. Only the mount points you named in Disks are connected to your hard drives. You can just delete the other empty old mount points. You have to be root to do so. I used the terminal and the command sudo rmdir <folder name> to delete the ones I was CERTAIN were empty old mount points.

All we’ve done here is essentially modify the /etc/fstab file which contains drive mount info. Lots of other tutorials out there can show you how to do this in the terminal if you want to know how.

Now we need to install all the other software we’ll need for the other steps of setting up the server. in your start menu, search for your package manager software. Mine is “Synaptic package manager” and install the following (make sure you check the box next to these entries, select “Mark for Installation” and when all are selected, click the “Apply” button.) Don’t be surprised if some of these are already selected, just ignore them then:

gnome-system-tools

samba

samba-common

python-glade2

system-config-samba

Or you could open a terminal and paste the following which will install them all for you automatically

sudo apt-get install gnome-system-tools samba samba-common python-glade2  system-config-samba

Once these all install you will create your linux users who can access this machine. You need linux users to be able to create Samba users. Samba is the file server software. From your start menu button, search for the app “Users and Groups.” Add whoever needs users for the fileserver.

linuxUsers

Now you can start fiddling with Samba, which is the actual fileserver software. Since there’s no icon to select to load this app, you need to open a terminal (hit ctrl+alt+t) type or paste:

sudo -H system-config-samba

You can copy that line of text paste it into the terminal using ctrl+shift+v to paste in a terminal.

You have to enter your password, but then a window should pop up. The very first time I did this I got the following error:

SystemError: could not open configuration file `/etc/libuser.conf': No such file or directory

ok, so the file doesn’t exist… I’ll simply make a blank file there and try again.

sudo touch /etc/libuser.conf #creates a blank file named libuser.conf in /etc folder
sudo -H system-config-samba

Success! It opened!

samba server config

Now we need to figure out which folders we want to share and how they are set up in linux.

As we saw before, the internal hard drives all have mount points in the /mnt folder. So let’s create a share for that. Click the big plus sign button and make yours match mine below. Be sure to click the “Access” tab and make it open for everyone.

image

Do the same kind of thing for the /media folder. This is where any USB storage devices will mount to by default.

And finally, I have a TON of files on my old desktop and user folder, so I want to make the entire /home folder accessible as well. You have to be careful with this though because if you allow all users (and even guests) edit access to your home folder, they can delete stuff, and snoop to their hearts’ content. Any sensitive data should be locked so that users are required to log in and can only access their files. If for example you wanted each linux user we created earlier to access only their home folders, you’d set that up as /home/adam then you could set the access rights to only allow user “adam” to view it.

Once you’ve set this up, now you must create the Samba users. While in the same application, select Preferences –> Samba users. Here you will add a new user with the same name as each linux user. You will select each user from the “Unix user” dropdown box (this is why we had to create all the users before). You can have the same or different passwords than your linux login. Once you added everyone, close this app. The steps we just took replace the manual process of editing a configuration file for Samba. This is a plain text file stores in /etc/samba called smb.conf and this is usually what most tutorials will do, show you how to edit this file manually. I didn’t have luck with that. Also, you might see tutorials using a tool called gadmin-samba however when I used that it completely hosed up my system hardcore. I had to purge all samba stuff, delete all the files and start from scratch several times to fix the issues.

File/Folder Access Rights:

The final step here that is required is to set the access rights of each folder you want to share. This is important because unless we change these permissions, we will end up only being able to VIEW files and folders on the server but we can’t create new files, paste, move, or delete anything yet. To fix this we need to change the permissions on the folders we set up to share.

We need to open the folders as root or administrator. Depending on the file manager software you might have different ways to do this, but in mine you simple right click ANY folder and choose “open as Administrator” or “Open as root” then I can simply navigate to the filepath “/” If yours doesn’t offer this, then open a terminal and type in the name of your file manager but call it from sudo like one of the following lines:

sudo nautilus /
#or
sudo nemo /
#or
sudo caja /

Right click on the folder of interest, for example “/mnt” and view the Properties. Click the Permissions” tab and make sure that they all show the ability to “Create and delete files.”

But if you’re using the terminal anyway, you can simply use the chmod commands. Here’s the best explanation of how to use it I’ve ever seen. You can make /mnt and /media fully writable like this:

sudo chmod 777 –R /mnt
sudo chmod 777 –R /media

Or you can give others the ability to look at files in your home user folder, but not create or delete like this:

sudo chmod 755 –R /home/adam

And you can block others from your folders and have them only viewable and editable by you like so:

sudo chmod 700 –R /home/adam

On the Windows machine:

Now your fileserver is set up you need to access it. Go on your windows machine and open a file browser window. Right-click on “This PC” and select “Add a Network Location”  Click Next until it asks for the location. Click “Browse” and wait a minute for it to search your network. You should see your fileServer’s name pop up in the list. Click literally any folder under the fileServer and select Next.

fileserver List

Shorten the terribly long name it gives you (I just delete the highlighted part) and you’re done.

name1

It’ll pull in the other accessible folders on that drive as well. Now you should be able to access and edit anything on those folders on the fileserver. To get to this again simply choose the fileserver option in the left-pane of the windows file explorer. If this doesn’t appear, then make sure your server is turned on and is on the same network as your windows machine and repeat the instruction in this section of the post.

remote

The first time you visit something in here it might ask you for a username and password. Just enter one of the Samba username and password combos we created earlier. You can make it save these credentials and never ask you again if you’d like.

Cherry on top – Remote Shutdown of server:

If you don’t want to connect a keyboard, mouse and monitor to the screen just to shutdown the fileserver, you can do so remotely by installing and using SSH. SSH is a way to securely tunnel into the fileserver’s terminal remotely. That way you can send it the standard linux shutdown message from your windows PC when you are done with it for the day.

Open synaptic and you should select the following:

or run the following command:

sudo systemctl status ssh

This will install the needed files for SSH. Next, we need to let the firewall built into linux know you want to allow ssh. In a terminal window run the following:

sudo ufw allow ssh

Now you can go to the windows computer and use putty.

Putty1

Enter your data here (keep the port as 22) and when you click “open” a black command window will pop up asking you who you want to login as. Type your linux username and hit enter and it’ll ask for a password. Now you’re commanding the terminal of the linux machine from windows. You can do literally anything the terminal can handle. You can’t do anything that requires GUIs though this way. That’s fine though because this is enough to send the reboot or shutdown signal. The shutdown takes about a minute before it actually shuts down, so don’ t think it isn’t doing anything, just give it some time.

sudo shutdown
#or
sudo reboot

Remote Desktop:

If you want a graphical environment for controlling your server, there’s 2 options. One is to simply remote Desktop into it.  There are many ways to do this, but the easiest is to simply install and enable the xrdp app on the linux machine and use the built-in RDP app in windows to connect.

Open synaptic package manager and search for xrdp and xorgxrdp.  Mark it for installation and click Apply.

Once this is done, go to the in the App search, look for “System Settings

Go to Sharing and make sure Remote Login is ON.

image

Next, in system settings, click “Network” in the left column and then click the gear button next to your wired (or wireless) connection. This will give you your IP address. It should look similar to your router’s address. Mine’s 192.168.x.x. You’ll need this to connect in windows.

To do all this in the terminal on the linux machine (or through SSH) run the following:

sudo apt install xrdp
sudo systemctl enable xrdp
ifconfig

This last command, ifconfig, will give you a screen showing you the local IP address of the machine. It should match closely to your router’s address. Mine is 192.168.x.x so I look for something that matches that. You’ll use this on the windows machine.

Now on the windows machine, click the start button and type “RDP” and hit enter. Type in the IP address of the linux machine.

I found an easier way. Simply right click on the fileserver in your explorer folder and select “Remote into this machine”

image

When you click connect, you’ll be able to login. I had a little trouble with this connecting. I tried all the selections in the dropdown menu a couple of times and on the 2nd or 3rd try it worked. Once I was logged in I got an error asking me to login to create a color device over and over. After entering my password 3 times I just canceled it and the window stopped popping up. I haven’t done this in like 15 years, but I don’t remember the experience being so crappy. I can access the desktop, but it is displaying a GNOME environment instead of the Mate environment I have installed on the linux machine. Nonetheless I can get do things graphically without issue.

Other Thoughts:

The way I’ve done it is quite insecure. I’m allowing Guests on the network access to create and destroy all the shared files which is kind of dumb… I’ll live with it though because I will only turn this fileserver on if I am immediately accessing the files on it, then immediately turning it off again.  In that short time I hope I don’t get hacked…

Storing all your files in one location is not the best for preservation. You can make a personal cloud like Google Drive, Dropbox, Box, OneDrive, Apple Cloud, etc. by using the Unison program.  It essentially synchronized two folders. These can be on the same computer, one on a portable USB drive, or even across the network. Anything added, modified, or deleted in one folder is automatically synched to the other in both directions.

Windows Networks Issues:

If the network disappeared from the “Networks” thing in Windows 10 but still somehow appears in the sidebar and is still accessible, no prob. Follow these instructions: https://www.wintips.org/fix-windows-10-network-computers-not-showing/#method-5

File Manager Share plugins:

Previously, I had some luck with using my file-brower’s “share” plugin. Nautilus, Nemo, and Caja all have their respective “share” app you can install in apt-get or synaptic eg “caja-share“.  This will allow you to simply right-click on a folder and select “share settings” where you can set this up yourself. The problem with this is that this info is NOT stored in the basic /etc/samba/smb.conf configuration file. In fact, it is nowhere to be found anywhere in that folder.  This is because this plugin stores this info in the following path:

  /var/lib/samba/usershares

To create the Samba users and set up their SAMBA passwords (these can and maybe *should* be different than their linux user passwords)

sudo smbpasswd –a user1
sudo smbpasswd –a user2

Now enable the users

sudo smbpasswd –e user1
sudo smbpasswd –e user2

Check the status of the samba server. You should see “active” somewhere. If not, you hosed it somehow. Tips on how to fix this at the end…

sudo systemctl status smbd

Restarting samba (after every big change to users, folders, etc you should do this. Or you can reboot the machine, which is foolproof method of restarting the server the right way)

sudo systemctl restart smbd
sudo systemctl restart nmbd

or do it directly for smbd and nbmd

sudo smbd stop
sudo nmbd stop
sudo smbd start
sudo nmbd start
Protected by CleanTalk Anti-Spam