Archive for the ‘Networking’ Category

Distro hopping: Import music stored on NAS into Music

September 19th, 2015 No comments

So you’re running elementary OS and want to access the music files you have stored on a Network-attached-storage device within the Music program. Unfortunately while you can easily browse the network and find these files you can’t do so within Music. Luckily there is a solution to this problem! Borrowing heavily from a previous post this will walk you through how to set up a persistent media folder on your computer that will ‘point’ to the music directory on your NAS.

Step 1) Open up a terminal

Now wasn't that easy?

Now wasn’t that easy?

Step 2) Install the required software

For the purpose of this post I’m going to assume the NAS is presenting a Windows file share so we’ll need the software to be able to make use of it. Simply run the following command to install the needed software:

sudo apt-get install cifs-utils
Installing some software!

Installing some software!

Step 3) Create a location for where you want the media to appear

If this is just going to be used for your user account you can simply create a new folder in your home folder. For example create a new folder under the Music folder called “NAS”. However if we want multiple users to be able to access this then you’ll want to put it somewhere else (for example /media/NAS).

For my example I'm just going to put it under a new NAS folder inside of my Music folder

For my example I’m just going to put it under a new NAS folder inside of my Music folder

Step 4) Edit the fstab file and add the share(s) so that they auto connect on startup

So basically there is a file on your computer called fstab that contains information about all of the hard drives and mounts that the computer should create on boot. To make it so our new NAS folder points to the actual NAS directory we’re going to add a new line to this file telling our computer to do just that. Start by using your terminal and opening that file in an editor. You can use a terminal editor like nano or even a graphical one like Scratch.

To use the terminal editor nano run the following command:

sudo nano /etc/fstab
fstab in nano

fstab open in nano

To use the graphical editor Scratch run the following command:

sudo scratch-text-editor /etc/fstab
fstab open in Scratch

fstab open in Scratch

On a new line add the following (modifying it according to your system). Note that this should be a single line even though it may appear broken up over multiple lines here:

//<path to server>/<share name>  <path to local directory>  cifs  
guest,uid=<user id to mount files as>,iocharset=utf8  0  0

Breaking it down a little bit:

  • <path to server>: This is the network name or IP address of the computer hosting the share (in my case the NAS). For example it could be something like “” or something like “MyNas”
  • <share name>: This is the name of the share on that computer. For example I set up my NAS to share different directories one of which was called “Files”
  • <path to local directory>: This is where you want the remote files to appear locally. For example if you want them to appear in a folder under your Music directory you could do something like “/home/tyler/Music/NAS”. Just make sure that the directory exists (that’s why we created it above :)).
  • <user id to mount files as>: This defines the permissions to give the files. On elementary OS (as well as other Ubuntu distributions) the first user you create is usually given uid 1000 so you could put “1000” here. To find out the uid of any random user use the command “id <user>” in the terminal without quotes.

As an example the line I added for my example configuration here was:

//  /home/tyler/Music/NAS  cifs  
guest,uid=1000,iocharset=utf8  0  0

Now save the file.

Step 5) Test that it worked

Finally in the terminal we’re going to run command to actually test it:

sudo mount -a

This will do essentially the same thing that happens when your computer first boots so if this works it should work the next time you restart as well. If you don’t get any errors then congratulations it should have all worked! You can verify by now opening up your NAS folder and confirming that it shows the contents of your actual NAS directory.

We have music!

We have music!

Step 6) Import the music into Music

Now that we have the NAS music showing up in a local folder the Music application will be able to add it no problem. Simply open up Music and use the import option to import the music from your folder (in my case ~/Music/NAS).



This post is part of a series:

I am currently running a variety of distributions, primarily Linux Mint 17.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

How to set a static IP address on Ubuntu 14.04 server (and others)

September 16th, 2014 No comments

This assumes you want to set a static IP address on the network device eth0.

Open up the interfaces file

sudo nano /etc/network/interfaces

and remove or comment out the line that says

iface eth0 inet dhcp

then add the following lines in its place:

iface eth0 inet static
address [static IP address, i.e.]
netmask [i.e.]
network [i.e.]
broadcast [i.e.]
gateway [i.e.]
dns-nameservers [i.e.]

Save the file and reboot the server. On some systems you may also need to update /etc/resolv.conf and /etc/hosts

I am currently running a variety of distributions, primarily Linux Mint 17.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Querying the State of a Hardware WiFi Switch with RF-Kill

October 8th, 2012 No comments

The laptop that I’m writing this post from has a really annoying strip of touch-response buttons above the keyboard that control things like volume and whether or not the wifi card is on. By touch-response, I mean that the buttons don’t require a finger press, but rather just a touch of the finger. As such, they provide no haptic feedback, so it’s hard to tell whether or not they work except by surveying the results of your efforts in the operating system.

The WiFi button in particular has go to be the worst of these buttons. On Windows, it glows a lovely blue colour when activated, and an angry red colour when disabled. This directly maps to whether or not my physical wireless network interface is enabled or disabled, and is a helpful indicator. Under Linux Mint 12 however, the “button” is always red, which makes it a less than helpful way to diagnose the occasional network drop.

Lately, I’ve been having trouble getting the wifi to reconnect after one of these drops. To troubleshoot, I would open up the Network Settings panel in Mint, which looks something like this:

Mint 12's Wireless Network Configuration Panel

The only problem with this window is that the ON/OFF slider that controls the state of the network interface would refuse to work. If I drag it to the ON position, it would just bounce back to OFF without changing the actual state of the card.

In the past, this behaviour has really frustrated me, driving me so far as to reboot the machine in Windows, re-activate the physical interface, and then switch back to Mint to continue doing whatever it was that I was doing in the first place. Tonight, I decided to investigate.

I started out with my old friend iwconfig:

jonf@jonf-mint ~ $ sudo iwconfig
lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11abgn  ESSID:off/any
Mode:Managed  Access Point: Not-Associated   Tx-Power=off
Retry  long limit:7   RTS thr:off   Fragment thr:off
Encryption key:off
Power Management:off

As you can see, the wireless interface is listed, but it appears to be powered off. I was able to confirm this by issuing the iwlist command, which is supposed to spit out a list of nearby wireless networks:

jonf@jonf-mint ~ $ sudo iwlist wlan0 scanning
wlan0     Interface doesn’t support scanning : Network is down

Again, you can see that the interface is not reacting as one might expect it to. Next, I attempted to enable the interface using the ifconfig command:

jonf@jonf-mint ~ $ sudo ifconfig wlan0 up
SIOCSIFFLAGS: Operation not possible due to RF-kill

Ah-ha! A clue! Apparently, something called rfkill was preventing the interface from coming online. It turns out that rfkill is a handy little tool that allows you to query the state of the hardware buttons (and other physical interfaces) on your machine. You can see a list of all of these interfaces by issuing the command rfkill list:

jonf@jonf-mint ~ $ rfkill list
0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: yes
1: hp-wifi: Wireless LAN
Soft blocked: no
Hard blocked: yes

Interestingly enough, it looks like my wireless interface has been turned off by a hardware switch, which is what I had suspected all along. The next thing that I tried was the rfkill event command, which tails the list of hardware interface events. Using this tool, you can see the effect of pressing the physical switches and buttons on the chasis of your machine:

jonf@jonf-mint ~ $ rfkill event
1349740501.558614: idx 0 type 1 op 2 soft 0 hard 0
1349740505.153269: idx 0 type 1 op 2 soft 0 hard 1
1349740505.354608: idx 1 type 1 op 2 soft 0 hard 1
1349740511.030642: idx 1 type 1 op 2 soft 0 hard 0
1349740515.558615: idx 0 type 1 op 2 soft 0 hard 0

Each of the lines that the tool spits out shows a single event. In my case, it shows the button that controls the wireless interface switching the hard block setting (physical on/off) from 0 to 1 and back.

After watching this output while pressing the button a few times, I realized that the button does actually work, but that when the interface is turned on, it can take upwards of 5 seconds for the machine to notice it, connect to my home wireless, and get an ip address via DHCP. In the intervening time, I had typically become frustrated and pressed the button a few more times, trying to get it to do something. Instead, I now know that I have to press the button exactly once and then wait for it to take effect.

I stand by the fact that this is a piss-poor design, but hey, what do I know? I’m not a UX engineer for HP. At least it’s working again, and I am reconnected to my sweet sweet internet.

On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.

Great Success!

November 1st, 2011 No comments

Just a quick note tonight – I finally managed to get a bootable Gentoo system installed!

After my last post, things were looking pretty grim. Instead of continuing to perpetuate the recompile/reboot cycle, I decided to start fresh, in hopes that I had simply missed a step the first time around. With this in mind, I started back at page one of the Gentoo Handbook and worked my way through the entire thing.

When it came time to compile my kernel, I opted for a slightly less error-prone method, and started off by installing Genkernel, a tool that automates some of the kernel creation steps. When running it however, I was sure to pass the –menuconfig parameter, which gave me full control over what modules were included in the final product.

Next, I followed the kernel tutorials in the Gentoo Handbook and on the Gentoo Wiki Asus P5Q-E page. This ensured that I included every component that was necessary for my system.

Once I rebooted the machine, a login prompt came up the first time. Great success indeed!

One little gotcha that’s important to note at this step. On my first login, I didn’t have any network access. Two things that might help:

  1. Open up /etc/conf.d/net in nano and add a line like config_eth0=”dhcp” for each network interface in your machine, where eth0 is the name of the interface. This tells the machine to use DHCP when initializing the device. On most home networks, this will get you an IP address.
  2. Make sure that any required modules are loaded. I have two network interfaces. One uses the sky2 module, and the other uses skge. You can check to ensure that these are loaded with the command lsmod | grep sky2 where sky2 is the name of the module that you’re looking for. If it isn’t loaded, run modprobe sky2 to get it up and running. Note that you may need to recompile your kernel with support for the module in question if you missed it first time ’round.

Tomorrow, I’ll compile an X11 server, and hopefully get started on the GNOME desktop environment. Christ there’s still a lot to do…

On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.
Categories: Gentoo, Jon F, kernel, Networking Tags: