Showing posts with label home router. Show all posts
Showing posts with label home router. Show all posts

Getting my pi on the network

I have recently been setting up a Raspberry Pi and documenting the process here.

In previous posts I have been dealing with the RISC OS setup. Today I moved over to Raspbian. This post will deal with:

  • Getting the Pi to see my home network hard drive.
  • Setting up the Pi as a home server.
  • Changing the system password.

Getting the Pi to see the network hard drive
I have a 2TB USB hard drive on my home network. I use this to share music, movies and other media between computers in my home. You can read my full article about getting a USB hard drive to work on your network, however I have summarised the steps for Raspbian below.


  • You need to mount the network drive into the Raspbian file system.  To do this you need to have cifs-utils installed.  My Raspberry Pi 2 came with this pre-installed.  You can check whether it exists or not by running the following command: dpkg -s cifs-util


  • Should you need it, you can install cifs using the command sudo apt-get install cifs-utils


  • Next create a directory on your pi for where you want to mount the network drive: sudo mkdir -p /media/network/public


  • You need to edit the etc/fstab file in order to mount the network drive. You may need to give yourself permission to do this, so navigate to your /etc folder and type chown pi: fstab (where pi is your username).


  • Now open the etc/fstab file in your text editor and add the following single line:

   //192.168.1.254/usb1 /media/network/public cifs defaults,rw,username=pi,password=yourpassword,domain=domain 0 0

Note that the first part is //IP ADDRESS OF ROUTER/directory name of network folder. If your network folder has any spaces in the name, eg "My Documents", then replace the spaces with \040, eg My\040Documents.

The second part is the path to the folder you created in part 3. You will need to put in your own username and password .


  • Now mount the drive using sudo mount -a


Once complete, you will see your network drive appear as a folder in your file manager.

Raspberry Pi file manager showing network drive

Setting up the Pi as a home server
The following steps will allow your Raspberry Pi to serve dynamic web pages to other devices on your network.

  • First install the full LAMP stack with sudo apt-get update and then sudo apt-get install apache2 php5 php5-mysql mysql-server
  • This will install all the software that you will need to run a home server. You may be prompted to enter a password so do add a suitably secure password at this stage. Once you are happy with your password (at it is one that you will remember) the rest of the process may take a few minutes.
  • When the install finished you should navigate to the /var/www/html folder. This folder will contain all of the files that your server will use.
  • To check that your server is working, Apache should provide a test page. Using another computer or phone type the IP address of your web server on your home network. Mine is http://192.168.1.162 and you may be able to get this information from your home router page or using the command ifconfig. If all is well, you should get a confirmation page.
Apache confirmation page as viewed in Chrome browser under Windows 10

  • You can now replace this file with your own home page. Should you find that you do not have permission to access files in your webserver, you can use the Linux chown command to change ownership permissions. The syntax is: sudo chown pi: item where pi is your username and item is the name of the file or folder you wish to access, for example: sudo chown pi: index.html will give you ownership access to the file. It may still mean that you can't edit the file, so navigate to the file in your file manager, right click and bring up the 'properties'. Then change the 'permissions' to 'change content: anyone'.
Changing the system password
Now that your Raspberry Pi system is running a web server and has access to the network drive, you will probably want to set the password for access to the Raspberry Pi system. Your Pi may boot directly into a password entry when it boots, however many new installations of Raspbian skip this step so as to make using the machine as painless as possible for new users.

  • Find the main menu, and navigate to 'Preferences' and then 'Raspberry Pi Configuration'.

Finding the password preferences in Raspbian
  • You will be prompted to enter your old password before you can change it. If you are using the default user 'pi', then the default password is 'raspberry'.
  • Make sure that you un-check the box that says Login as user 'pi'.
Hit the 'change Password...' button to change your password. Then make sure you un-tick the box shown. This is what has been letting you log in automatically to the Raspberry Pi, but it also lets your little brother get in and see all your stuff too!


Well, that's all I have for today.  If you are still awake, then you might be interested in some more Raspberry Pi related posts.

Sharing a usb drive to chromebook, raspberry pi, Android and Windows 10

I noticed that my new home router comes with a USB port. I figured that it was possible to connect an external hard-drive and use my router as a home file server. This means that I will be able to share files between my Chromebook, Raspberry Pi, Android tablet and Windows machines.


Here are the steps I used by device.

First steps
Plug in your usb drive and check the admin settings on your home hub.  I get there through the default address of my router which is 192.168.1.254 and yours is likely to be similar.  It is a good opportunity to change the admin password at this stage.

In Windows 10
Access to the shared network drive is as easy as opening the file explorer and typing the address into the address bar eg //192.168.1.254

Your files are now ready to be accessed on all your devices.


On a Chromebook.
It would be useful to access my PC files on my Chromebook as well.  I used File System for Windows.


Your shared files are now available in the ChromeOS File app.

On Raspberry Pi under Raspbian

1. You need to mount the network drive into the Raspbian file system.  To do this you need to have cifs-utils installed.  My Raspberry Pi 2 came with this pre-installed.  You can check whether it exists or not by running the following command: dpkg -s cifs-utils

2. Should you need it, you can install cifs using the command sudo apt-get install cifs-utils 

3. Next create a directory on your pi for where you want to mount the network drive: sudo mkdir -p /media/network/public

4. You need to edit the etc/fstab file in order to mount the network drive. You may need to give yourself permission to do this, so navigate to your /etc folder and type chown pi: fstab (where pi is your username).

5. Now open the etc/fstab file in your text editor and add the following single line:
   //192.168.1.254/usb1 /media/network/public cifs defaults,rw,username=pi,password=yourpassword,domain=domain 0 0

  Note that the first part is //IP ADDRESS OF ROUTER/directory name of network folder
 If your network folder has any spaces in the name, eg "My Documents", then replace the spaces with \040, eg My\040Documents.
 The second part is the path to the folder you created in part 3.
 You will need to put in your own username and password .

6. Now mount the drive using sudo mount -a


Android

There is no single file explorer app for Android, but many of them allow you to access network drives. I use ES file explorer which has a nice 'search' feature which will find your network drive in a few seconds. You can also pin your network drive to your desktop for easy access.

Accessing your network drive in Android

Windows Phone

I have downloaded Metro File Explorer to access my home network files on my Lumia 950.


That's all for now (I've run out of devices to try). It's time to backup to my file server and tidy up a bit.

Label

World Karma Game