So if you have followed my instructions, you now have a:
Computer that runs Debian Linux
Computer that you can look into using Remote Desktop
Computer that you can share part of the local hard drive
Congratulations. You now have a file server!
If you followed those directions, it also installed a bunch of other programs that will let you do other things. I noticed that something called “CUPS” was installed, and that will let you plug a printer into the same machine and act as a “Print Server” or a “Network Printer” – if you can find the instructions on how to configure it.
Debian and Raspbian both come with enough that you could use that machine as your one and only daily driver computer. The browser is called “Iceweasel” and is Firefox, rebranded. You have Libre Office to write letters, work with spreadsheets, and make presentations that are all compatible with Microsoft Office.
Yes, it really is, I use it every day. No, you don’t have to pay for it. Ever.
There are more apps, and I would suggest looking into some of the software that is out there, all free. If you start “synaptic” from your terminal as root or “sudo synaptic &” you will find so much free software that your mind will fog up and get tired before you find everything you want.
But that all is just the preamble to this discussion. You came here to share an external drive. This is like any other shared drive on the network, you have to have it plugged into the server (USB Port on your netbook), you have to tell the computer where it is, and you have to tell it how it is to be shared.
Remember, I am trying to write this for a Windows audience so I’ll go as basic as I can. You Windows folks are in a new world, and you will want to have this go well. If you are a Linux expert or even intermediate, you may find this needlessly wordy. Not to worry, you’ll be right.
One Step At A Time. Divide and Conquer.
First step – Make sure you can read the drive from Linux.
Before you get anywhere, start the computer. Log in. Get to your desktop. Then plug in the drive.
Start your terminal session by clicking on the (start) “Applications Menu”, then click on Terminal. Sign in as root by entering “su” and your root password. You will eventually need this
Now, launch the file manager by clicking on the (start) “Applications Menu”, then click on “File Manager”.
In the left pane of the file manager you will see Devices, Places and Network. In “Places” your external drive will come up with a little eject arrow to the right of it. Click on the icon for the drive. A little wait icon will start to rotate. When it is through it will do one of two things:
Success is if you are dropped into a view of whatever files are on the disc. It means that all the drivers are in place. Most likely this drive is something called “vfat” or “fat32”. Remember this for later.
Failure is if you get a big ugly warning message up. That means that you don’t have the drivers for the format that the drive has on it. Most likely you will have to install the set of drivers called “ntfs-3g”. This would be where your external is a really big drive and you did it to make things faster. To install that do the following steps:
- apt-get update
- apt-get upgrade
- apt-get install ntfs-3g
- shut down the server
- unplug the drive (It isn’t shared yet and you don’t want to wait for the computer to release it)
- start the server
- and plug in your drive when you have logged back in to the desktop, terminal, and file manager.
No matter what, at this point, you should be able to read your external drive.
You also need information. When you worked with the server software “samba” you created a user and a password, and you will need that later.
Next step – finding where Linux thinks that drive actually is.
Here is where Linux people will be saying “gparted“. If you know how, go for it, this is the slower but less risky method.
To determine what is plugged into your machine type into the terminal:
- dmesg | tail -30
Linux keeps a log of whatever is important to the system. Since you “just” plugged that external drive into the computer, the last thing on that very long stream of text will be what was reported when the computer detected the hardware. The “tail” bit will tell terminal to just show the last 30 lines of what are in the display of messages (dmesg).
The clue there are the lines that say “usb 1-2” and “sdb”. When I plugged in the drive, it said “new high-speed USB device number 2”. So what we’re going to tell the system is that the drive is sitting on a device called sdb. The partition we will be using will be the first one, so it is officially “/dev/sdb1”. In windows, it would come up as your D drive if there is no DVD/CD drive present, E Drive if it is, this is the same thing.
Since my stick is formatted to be removable on Windows, it is a format that Linux calls “vfat“. My big 4 TB drive is formatted NTFS, so I would have to mount it as “ntfs-3g”
Create a place to store the data in. In my case, it is “/home/bill/external“. You should change “bill” to the name of your user that you logged into when you started this exercise. To make the directory, open terminal again as a regular user and enter this command:
- mkdir /home/bill/external
- chmod 0770 /home/bill/external
You just created the directory and set it up so that you and root can use it.
There is one file that you need to edit in Terminal with the following command:
- nano /etc/fstab
This file tells linux where all of your disc drives sit, so be careful and don’t delete anything. You will be adding a line, as below:
- /dev/sdb1 /home/bill/external vfat defaults 0 0″
That says – put the external drive’s first partition “in” the /home/bill/external directory. It also says that it is “vfat” format so change that if it is an ntfs-3g format. The defaults are lengthy and you can go into them in great detail on the Wikipedia Article.
If you wanted to go further and add multiple partitions for other people, you could do it in /etc/fstab by adding multiple entries.
Once you restart the computer, you should be able to find the drive on Windows, and you are on your way. Just find the drive in Windows File Manager, enter in your login from Linux, and you’re good to go.
One final wrinkle
What this does is to “bind” the external hard drive or memory stick to the server. It is now set to automatically mount and share the drive whenever the power comes back on. If you do not have a drive plugged in, Linux will boot, but put you into a terminal session as root into what is called “Single User Mode”. You can do the following edit at that point with the commands below.
To remove the hard drive so that the server is no longer looking for the drive at boot, in terminal as root:
- nano /etc/fstab
- find the line with the external drive and enter a # as the first character in the line
- save the file and restart the computer
This now turns your server into a machine that only serves the local hard drive.