MOUNT AN SMB NETWORK DRIVE ON RASPBERRY PI

original post: http://geeks.noeit.com/mount-an-smb-network-drive-on-raspberry-pi/

In this tutorial we will describe how to connect your Raspberry Pi to a network drive and permanently mount it to your system. Even though this article uses a Raspberry Pi as an example to connect to an SMB drive, the steps used can be applied to any Debian based system, such as Ubuntu.

If you have a Raspberry Pi you might have noticed that the storage possibilities are kind of limited unless you have some external storage. Even though you can get SD cards with 64+gb of storage, you probably want more if you have a lot of music and movies that you are streaming through your Pi.

There are several choices when it comes to storage for your Pi, such as network drives, flash drives, or external USB HDDs. Using a network drive you can not only access your files from the Pi, but from any computer connected to your network, which is very convenient.

Prerequisites

Before we start, I will assume you already

  1. have a network drive connected to your LAN, and
  2. know its LAN IP address

Note: remember to change all text in red to your own values.

 

Installation

In order to mount the drive, you need to have cifs-utils installed on your system. If you are running a newer version of Raspbian or RaspBMC you should already have this installed. You can check whether it is installed or not by running the following command:

dpkg -s cifs-utils

If it is installed, it should output something like this:

Package: cifs-utils
 Status: install ok installed
 Priority: optional
 Section: otherosfs
 Installed-Size: 189
 Maintainer: Debian Samba Maintainers <pkg-samba-maint@lists.alioth.debian.org> Architecture: armhf
 Version: 2:5.5-1
 ...

If it says that it’s not installed, you need to install it:

sudo apt-get install cifs-utils

 

Mounting unprotected (guest) network folders

You might have public folders on your network drive that can be accessed by anyone without having to provide any credentials. These are mounted in the same way as password-protected folders (we will mount these in the next section), but with a few different options.

First, let’s create a directory on the Pi where we want to mount the directory. You will need a separate directory for each network folder that you want to mount. I will create the folders in the /media folder:

sudo mkdir -p /media/networkshare/public

Then edit your /etc/fstab file (with root privileges) and add this line:

//192.168.0.18/publicshare /media/networkshare/public cifs guest,uid=1000,gid=1000,iocharset=utf8 0 0

The first part is the IP of your network drive, and the public folder you want to mount.
The second part is the folder on your local machine where you want to mount the network share.
The third part indicates what type of drive you want to mount (cifs).

The last part is the set of options you can pass, and here’s an explanation of the ones we are using:

  • guest is basically telling the network drive that it’s a public share, and you don’t need a password to access it (not to confuse with username),
  • uid=1000 makes the Pi user with this id the owner of the mounted share, allowing them to rename files,
  • gid=1000 is the same as uid but for the user’s group,
  • iocharset=utf8 allows access to files with names in non-English languages.

Note: If there is any space in the server path, you need to replace it by \040, for example //192.168.0.18/My\040Documents

To find the uid and gid for your username, use the following command:

id username

Now that we have added this to our /etc/fstab, we need to (re)mount all entries listed in /etc/fstab:

sudo mount -a

Now you can access your network drive from /media/networkshare/public (or wherever you chose to mount it).

 

Mount password-protected network folders

Mounting a password-protected share is very similar to mounting a public ones, with some minor changes to the options we pass. Let’s start by making a new folder where we want to mount the password-protected share:

sudo mkdir -p /media/networkshare/protected

Again, open /etc/fstab (with root privileges), and add this line:

//192.168.0.18/protectedshare /media/networkshare/protected cifs username=msusername,password=mspassword,uid=1000,gid=1000,iocharset=utf8 0 0

While this is a perfectly valid way of mounting your protected folder, it’s not very secure. Since /etc/fstab is readable by everyone, so are your credentials in it. So, let’s make it more secure by using a credentials file. This file will contain nothing else but your username and password, but we will make readable only to you. This way, other users on the system won’t be able to see your credentials.

Using a text editor, create a file that will contain the credentials for your protected network share:

vim ~/.smbcredentials

Enter your username and password for the protected share in the file:

username=msusername
password=mspassword

Save the file.

Change the permissions of the file to make sure only you can read it:

chmod 600 ~/.smbcredentials

Then edit your /etc/fstab file and change the line where we are mounting the protected share to look like this:

//192.168.0.18/protectedhare /media/networkshare/protected cifs credentials=/home/username/.smbcredentials,uid=1000,gid=1000,iocharset=utf8 0 0

Save the file.

Again, we need to (re)mount all entries listed in /etc/fstab:

sudo mount -a

 

Now you’re all set to access your public and protected folders from your Pi.

 

firefly – serenity 萤火虫 冲出宁静号

serentiyFireFly  serenity-summer_00354141

最近总算追完了《firefly》这部美剧,然后又看了《Serenity》这部电影,算是交代了电视剧的结局。

Take my love
Take my land
Take me where I cannot stand
I don’t care,I’m still free
You can’t take the sky from me

Take me out to the black
Tell them I ain’t coming back
Burn the land and boil the sea
You can’t take the sky from me

There’s no place I can be
Since I found Serenity
But you can’t take the sky from me

这部电视剧以这首歌开始,体现了电视剧的基本内容:

即使夺走了我的爱和我的土地,让我无处可栖,但是我不怕,我向往自由,你无法夺走我的天空。

听到对白里面英语里面掺杂着我也听不懂的中国话,总感觉怪怪的。后来才知道导演比较喜欢中国,认为未来是中国的天下,剧中未来的世界,汉语和英语是通行的两种官方语言。话说回来,现在很多人说话,汉语里面插着不少英语单词,给老外也许也是怪怪的感觉。

這戲的偉大,在於它很短,就是被腰砍了,才播出11集(後來的dvd,出到14集),但不給人「爛尾」之感,而接續的電影版大結局serenity(衝出寧靜號),更是壯烈到驚人的地步,這麼艘破船,一船見錢眼開的爛傭兵,到最後,真是以命相博,就為了個,不知從哪撿來的,怪里怪氣的小屁孩。

這群人,最終不但揭漏了聯邦的無恥祕密,其代價更是無比昂貴,只因他們基本上是下定決心,命不要了,集體立志犧牲生命……。

至此,firefly 終於成就了一個影史的特例,一部被砍的小美劇,竟然能衍生出 serenity 這樣的電影鉅作,科幻鉅作,太空史詩鉅作,類型電影鉅作。它,不但成為影史特例之一,不但是影迷心中的cult,它,更變成影迷心目中的孤絕象徵。

片中,mal 帶領著寧靜號,抵抗聯邦。

戲外,我們這些影迷,也跟該死的fox電視台抵抗呢。

你把我們的影集砍了,我們用dvd的銷量,還有用電影版的賣座,證明你們的無知和罪惡!

(Joss Whedon:「這部電影本不該存在的」,他繼續說:「遭停播的電視劇,沒有資格拍成電影,除非製片、演員和影迷,能相信……這部電影,意義空前。」)

电影的结局以mal和river的对话,讲述了他和Serenity的关系,

You know what the first rule of flying is?

well, I suppose you do, since you already know what I’m about tot say.

Love. You can learn all the math in the ‘verse, but you take a boat in the air that you don’t love, she’ll shake you off just as sue as the turn of the worlds.

Love keeps her in the air when she ought to fall down, tells you she’s hurting before she keels.

Makes her a home.