Jul 232017
 

It’s a very common thing to have multiple hard drives in our possession these days. With all the data and media that we have with us, the inbuilt storage in our computers prove insufficient. External HDDs also provide easy portability for the media. But we always face an issue when we want to share our media or even the HDD space with others in our own home or on our internal network. One solution is to attach the HDD to the computer and configure it as a shared drive. But that would require a computer which is running 24×7 so that the drives are available at any given time to anyone. Not an ideal solution.

Another method is to configure a NAS or Network Attached Storage. NAS is basically a storage attached to a network device(typically a server, but can also be a dedicated controller) which is connected to a network and runs 24X7. You do get NAS devices in market but these devices are typically as costly as a single 2TB drive and are normally beneficial for higher speed transfers. The NAS configuration which I plan to discuss here, will give you transfer speeds of about 4-5 mbps over local network and should be suitable for home/home office networks. And we use a versatile computer which has very low footprint in terms of space and power consumption. The Raspberry Pi is one of the best suited computer board for this project.

Before you go further you need:

  • A Pi with Raspbian installed and connected over you local network. Use this tutorial for the same.
  • A powered USB hub sufficient to power your HDDs. Buy here based on number of HDDs you have

Warning : Do not attempt to power up your HDDs via the Raspberry Pi USB ports since the pi can handle only about 2.5 amps of current through it and may burn out in case overloaded.

So let’s get started.

(Note : This guide has been drafted based on my installation experience, which was further assisted by the guides available at howtogeek.com and instructables.com . Any errors during the installation, you can leave me a note or you can check the guides on their websites. Both websites listed different methods and I couldn’t get mine configured using them individually. But I succeeded when I followed both the guides together)

  • Connect your HDDs to the USB hub and connect the Hub to one of the USB ports on the Pi.
  • Open up shell via SSH( or terminal in case you have connected the keyboard/mouse and screen to your Pi)
  • Run the commands sudo apt-get update and sudo apt-get upgrade to update your Pi installation and repositories.
  • If your HDDs are NTFS format, you will need to run the following command in terminal.

sudo apt-get install ntfs-3g

This will get you Pi ready to understand the ntfs format on your HDDs.

Next step is to identify your drives

  • Type ls –l /dev/disk/by-uuid
  • The output of this command will be similar to below:

clip_image001

  • Here sda1, sdb1, sdc1 denotes the external HDDs. The number will vary as per the HDDs connected by you. We are interested in the 16 digit hexadecimal UUID against each of these. Note down the 16 digit codes and the corresponding HDD identifiers. eg. sda1 – 1C0CA2830CA25812  in the example above.
  • Next run code ls –l /dev/disk/by-label
  • The output will be something like this:

clip_image002

  • As you can see, my labels are Transcend, Storite and WD for sda1, sdb1 and sdc1 respectively. These are the actual labels which you have given to the HDDs. Note these down and match them with the UUID. So in my case it will be sda1 – 1C0CA2830CA25812 – Transcend.
  • Now that we have identified the HDDs, we need to mount these drives. But before that we create a location to mount these drives.
  • Run code sudo mkdir /media/DRIVE_NAME . eg. for my transcend drive, I created directory using sudo mkdir /media/transcend
  • Do this for all the drives that your have connected.
  • Next, mount each drive with the following command for each instance:

sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sdxx /media/DRIVE_NAME

  • Where sdxx is sda1, sdb1, sdc1 etc and DRIVE_NAME is the corresponding mount point which you created earlier. So for my transcend drive the command will be:

sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sda1 /media/transcend

  • Do this for all the drives.
  • If you have fat32 or ext4 drives, suitably modify the command:
    • ntfs-3g for NTFS drives
    • vfat for FAT32 drives
    • ext4 for ext4 drives
  • The drives should mount everytime we reboot. So we need to add it to startup script.
  • Run sudo cp /etc/fstab /etc/backup_fstab
  • Then run sudo nano /etc/fstab
  • Add the following correspondint to each drive

/dev/sda1 /media/transcend auto noatime 0 0

Use the correct drive identified sdxx and the corresponding correct DRIVE_NAME for each HDD.

  • Restart the Pi using sudo reboot
  • Next step is to install samba.
  • Run sudo apt-get samba samba-common-bin
  • Once installed, backup the samba configuration file before proceeding:

sudo cp /etc/samba/smb.conf /etc/samba/backup_smb.conf

  • Run sudo nano /etc/samba/smb.conf
  • In the configuration file that opens up, ensure that the workgroup is your local workgroup for your network. Ideally its WORKGROUP for windows. Modify it if you are using something else.
  • In the Authentication section, enter security = user  to enable verification
  • Now scroll to the bottom of the file and add your drives as follows:

clip_image003

  • Here valid user = @pi is the username I selected. You may select anything you want eg. valid users = @josh .
  • You may also choose to share specific folders inside the HDD instead of the entire HDD. Modify path if that is the case. The read only attribute specifies the modification rights and the no flag specifies that the users on network can read as well as write to the shared drive/folder.
  • Save using ctrl+X, say yes and hit enter.
  • Run sudo /etc/init.d/samba restart
  • Add user to give access to the shared drive
    • sudo useradd josh -m -G users
    • sudo passwd josh
  • You will be prompted to enter a password twice.
  • Next enter the command sudo smbpasswd –a josh
  • Create password on prompt
  • Restart samba using sudo service smbd restart
  • The HDDs should be visible to you on other computers on your network. You can configure it as a network drive. You will need to specify username and password once for access.

Next time, we will see how to configure DLNA server on your Pi to share the media files to your DLNA compliant devices.

Jul 162017
 

If you follow tech world, you must surely have come across the name “Raspberry Pi” which has been making waves in its field for about 5 years. I had provided a basic insight regarding credit card sized(and thumbnail sized) computers in my previous post. These tiny boards cost from  about 5$ to well over 100$, each with its own specialties. And they are the favorites of the geeks for small tasks, dedicated application or plain hobby projects.

But its not just the geeks who have the competence to use them. A common person like any of us can pick one up and configure with a little bit of research(nothing anyone can’t handle. Some basic configurations are straight forward.) You can use it as a simple linux based computer, a media server, a network attached storage controller, create a magic mirror, an interactive AI and pretty much anything you may want with a bit of advance tutorials.

The aim of my todays blog is to guide you through the installation of Raspbian and create a backup image of the setup. The back up will help you to copy the sd card in an image format which can be overwritten anytime you feel that the OS is not behaving well. I will also explain how to setup your pi to be used via a remote computer, thus dispensing the need to connect it to a monitor, mouse or keyboard. We shall set it up so that the pi is on static IP and easily accessible via shell or via VNC.

Note that the Raspbian OS is based on Debian distribution of Linux, so even though you get a GUI, be prepared to try out command line for advance configurations. They are fun to learn and not very difficult to remember(or to google for that matter)

What you need

  • A Raspberry Pi 3 with a 2.5 A 5V power supply(micro usb pin)– buy it here and here
  • A 16GB – 32GB micro SD Class 10 card – better a 32 GB version if you plan to setup more number of applications – buy it here
  • A keyboard/mouse/monitor(HDMI TV will do) for initial setup
  • NOOBS – download here (NOOBS is a “New out of Box Software”, a minimal intervention installer with OS packages built in)

Whenever you plan to buy a case for the pi, consider possibility of adding a fan and GPIO headers. Also consider that you may need to remove the micro SD card time and again in case you are using another card for another project. Make sure that the SD card is readily accessible.

Install Raspbian

Before you try to install raspbian on to your sd card, you will need to format in to Fat32 file system. You can use SDformatter for the purpose. Once the SC card is formatted, extract the downloaded NOOBS image in to the root of the SD card.

The installation method below gives the installations of only Raspbian OS with PIXEL desktop. You should be able to install and use any other OS listed within the list, once you are a little familiar with how it works.

  • Insert the card in to you pi in the card slot.
  • Connect the HDMI cable, keyboard and mouse to the pi.
  • Connect the power source.
  • The pi will start automatically. You will be taken to the list of available/downloadable OSes. Select Raspbian jessie with full desktop.

clip_image001

  • On the top left hand corner, you will find a icon shaped like a hdd. It is your install button. Click on the button to install Raspbian.
  • Go have a cup of tea cause it takes 15-20 minutes to install. Yes, no further intervention necessary.
  • When you come back from your short break, you will be greeted with a message saying that OS is installed. Click ok. The system will reboot.

That completes the installation part. Once the system reboots, it will take you to the PIXEL desktop. It is essentially similar to windows desktop with the taskbar and menu docked to the top. But don’t let the appearances fool you. The core on which it is built is rock solid, highly customizable and very secure.

The round raspberry on top left gets the things started for you. Navigate around to get a feel. The other important icons which you would be using time and again are:

  • The blue globe near the raspberry, which is essentially the web browser.
  • The folder icon, which is used to navigate the file system
  • The black window, which I guess you know from your windows days, the console or the terminal

Navigate around the icons, they wont kill the system for now.

clip_image002

Let’s change the default password

Ok, first thing’s first. We secure out pi before we connect it to network. Click on the terminal icon. The terminal, as below, will open up.

clip_image003

Here, the “pi” is the current user and raspberrypi is the hostname. Let’s change the password. Type the following code in front of the prompt:

passwd

You will be prompted to enter the current password. The factory default password for user pi is raspberry. Enter the password and you will be asked to type in the new password, two times. Enter it twice and the password will be changed.

clip_image004

Let’s setup static IP

Setting up a static Ip to your pi makes it easy to access it from another machine

  • Open terminal and type in sudo nano /etc/dhcpcd.conf
  • Here sudo mean you are telling the system to do something as a superuser. Something similar to run as administrator in windows.
  • nano is a text editor for terminal. another text editor available for GUI is leafpad. So when you are logged into desktop, you can type in sudo leafpad…… instead of sudo nano….. But it is a good practice to use nano since, once we switch off the GUI, console is all that you have until you switch it back on again. You will be able to use only the arrow keys and enter button in nano.
  • dhcpcd.conf is the configuration file for the network and etc is the directory where it is stored
  • scroll down to the bottom of the file that opens up and type in the following code:

interface eth0

static ip_address=192.168.1.95/24

static routers=192.168.1.1

static domain_name_servers=192.168.1.1

interface wlan0

static ip_address=192.168.1.96/24

static routers=192.168.1.1

static domain_name_servers=192.168.1.1

In the above code:

  • you can use either wlan0 or eth0 or both, depending on what kind of connectivity you plan. wlan0 is for wifi and eth0 is for wired connection.
  • static ip can be of your choice based on your network configuration (eg. some networks are configures 192.168.0.xxx). Make sure to keep the number /24 in the settings.
  • static router specifies the router to which the pi is to be connected. My router ip is 192.168.1.1
  • similarly static domain name servers can be as per your network configuration. My home network devices get their DNS from my router so I have entered my router address.’’

 

  • Press ctrl + S to save the settings.
  • Press ctrl + X to close the editor.

You can now connect to the home wifi, of ethernet, or both. The up and down arrow on your top right hand side of desktop will help you join a wifi network.

Once connected to internet, it would be a good practice to update your system before you go further.

Open the terminal and type in sudo apt-get update. Once this command is executed, use sudo apt-get upgrade. It is a good practice to use this two commands before installing any new software on your pi. They are used to update any packages which are installed on your pi and which have been updated ever since you installed. Fresh OS installations normally have some major updates available.

Let’s do away with that monitor, keyboard and mouse(Optional if you are comfortable running the show remotely via terminal. But that’s what these board is all about….accepting the challenge)

So now that you have changed password and set up static IP, let’s go a bit deep and dispense away that monitor. Only of course if you have a computer or a laptop from where you can control it. Remember, though the pi can be used as a regular desktop computer, it will run only may be one or two applications together because it simple lacks the resources needed for heavy multitasking. It is best suited for headless apps and servers, similar to ones which I have listed out in the beginning.

Open the terminal and type in sudo raspi-config

  • This will open the configuration tools for raspberry pi. Thins this as a BIOS for your PC with more configurations.

clip_image005

  • Use the arrow keys and enter button to select Interfacing Options.
  • Select SSH and enable it. Next Select VNC and enable it. Selection is by pressing enter and arrow keys.

clip_image006

  • Select Back.
  • Select Boot Options
  • Select Desktop/CLI
  • Select B2 Console auto login.

clip_image007

  • Select finish and reboot.
  • Move over to your regular use PC.
  • Download and install a SSH client like putty. Run Putty on your pc.
  • Enter the IP address in the hostname field, enter a recognizable name in saved session field and click save

clip_image008

  • Now double click on your saved session and a terminal window should open up asking you to enter username. Enter pi.
  • Next enter the password which you have set.
  • This will take you to console from where you can control your pi.

clip_image009

Since you have configured only console login via configuration tools, you can access only via putty(SSH). If you configure to boot in desktop mode via configuration tools, you can use VNC to login to desktop too. You will need to download VCN on your computer to do that. Try it out, its easy. If in doubt, just leave a query. You can always go back to desktop login by using sudo raspi-config.

Let’s backup

Let’s try the easy way to backup today.

  • Download win32 disk imager and install on your computer.
  • Shut down the raspberry pi, remove the card and insert it in your computer(via SD card reader)
  • Run win32 diskimager.
  • Select the device to backup(our sd card).
  • Select a backup location on your computer and give a file name (eg, raspbianbackup.img)
  • Click on Read

clip_image010

  • The backup will automatically be created at the specified location.
  • Next time, the setup on you pi doesn’t work as it should, run this program again and select this image we have created. Click write instead of read this time, to overwrite on the card.

In case you have any doubts or anything very clear or seems to be wrong, kindly leave a comment. In the next tutorial I plan to explain setting up a NAS server, a DLNA server and an always on bit torrent box.

Till then!!

Aug 162016
 

2000 was the year when I bought my first computer. 550 MHz Intel Pentium processor, 64MB RAM(wow…..back then), 20 GB HDD(another wow…..again back then) along with all the gizmos(read modem, multemedia speakers, cd drive….no not a writer or DVD rom…..just plain cd drive) had cost me(my father actually) about 40,000 rupees. I was quite fascinated by its capabilities(current midrange phones beat it by miles). Technology didn’t stop evolving ever since. While I was sailing at a speed of 13 knots mid of Indian ocean, technology was evolving million times.

Next I bought my first laptop, the Dell XPS M1530 which was a gaming monster(at reduced graphic levels and only few select games which already had their graphic details at the lowest). I was quite happy playing Crysis which played quite well. And NFS of course. Other than that, the Rs 55,000  that I put in the laptop just gave the pleasure of owning such a ‘powerful’ system.

I have matured ever since and currently own a Lenovo B50-70, which I got at a throwaway price and which satisfies my current needs.

But tech world has not stopped evolving. While they continuously strive to design monster machines capable of unearthly things, they have also managed to reduce the size of my first computer to a thumbnail. Meet Omega 2, the tiny computer. I was quite impressed by the specifications of Raspberry Pi 1/2/3, the credit card sized computer with all the required peripherals. But this one goes a step ahead.

This tiny computer is a quarter the size of Raspberry Pi

(Picture Source : techradar.com)

The Rapsberry Pi would beat my first computer in terms of computational power any day, but the Omega 2 matches my first computer and beats everyone else in terms of size. That sheer brilliance of the brains behind these tiny things. The possibilities are endless in this age of ‘Internet of Things’.

 

Raspberry Pi 3

(Picture Source : techradar.com)

And the best part. Omega 2 beats everyone else in terms of price. $5. Forget the usability, I would buy this one just to own a tiny computer and use it to make a doorbell if i wanted. Or a gaming console!!

So what’s next?! An invisible computer?

%d bloggers like this: