Mounting Shared Folders to Play Media Files in Kubuntu
The world’s most complicated fix for the world’s simplest problem
As a warning, this article is not for people who are afraid to run some commands from a text-based terminal or edit some system files used by Linux. I’ve tried to make things as simple as possible, and you can use the GUI for most of these tasks, but some steps will require you to open a shell and type a few commands by hand. I don’t think there is much risk of hosing your system if you follow the steps carefully- it is more likely that the new changes just won’t work- but if you get too far off track or something goes poorly enough, I can’t be held responsible if it messes up your system. You have been warned.
Anyway, if the intro didn’t scare you off, you’re probably wondering “just how hard could it actually be to play .mp3 and .avi files over a network share?” Well, Kubuntu (or Dolphin to be specific) can open shared folders on PCs running Windows right out of the box, but it can’t seem to open media files without first copying them to the local hard drive. The reason is because shared folders on NTFS hard drives (the file system used for most Windows installations) are not “properly mounted”, which is a fancy way of saying that Linux doesn’t have enough control over them.
I almost uninstalled Linux when I first encountered this problem, because it is so ridiculously complex for such a simple request, but I’m glad I stuck with it because although Windows doesn’t have this particular problem, it has plenty of others. Now, let’s get started!
In case you were wondering, you can access shared folders by going to the System menu (next to the K menu) and selecting “Samba Shares”. Then you should be able to find the PC you are looking for. Although this is useful for some things, it is not useful for playing media, which tend to be large files.
The solution for this, as I mentioned before, is to properly mount your network drives. This involves a little bit of trudging through the command line, and there is probably a better way to solve this problem but after all the searching I did, this is the best I can come up with. There are basically 4 parts to this fix.
- Setup a local folder for mounting
- Create a credentials file under your root directory (optional, but recommended so your password is not revealed to other users on your PC)
- Edit your fstab file to mount the folders from step 1 upon booting into Linux
- A “fix for the fix”, because of a known bug when unmounting drives (during shutdown)
Setup a local folder for mounting
Go to the system menu and click any option to open Dolphin. Click on the root shortcut on the left, and then choose the option on the right hand column for “Open as root“. In here, right click and create a new folder named “net” without quotes. It doesn’t really matter what you call it here but you will use it later and it is case sensitive. In any case, open this new folder you just created and create another folder.
I named this new folder after the computer I was connecting to, then created another folder under that with the same name as the shared folder of the machine I’m connecting to. This is because I have a few computers on my network and I wanted it to be like a re-creation of my network tree, but you really just need one folder for each shared folder you want to connect to. For this demonstration, I will make a directory structure of /net/mkd/d, but again, you can call it whatever you want. mkd is the name of my computer, and d is the name of the shared folder on that PC (my D: drive in Windows).
Create a credentials file
To create the credentials file, go back to Dolphin and click on the root shortcut again (from the column on the left). You should still have root access unless you closed the window or opened the wrong Dolphin window, so go to /root in the folder list below. Right click here and create a new text file named “.smbcredentials“. The dot as the first character means it is a hidden file, so you will have to click Alt+. (alt and the period key at the same time) to see it in dolphin. Do this and then open the blank file you just created and add the following two lines:
username=[YOUR_USER_NAME]
password=[YOUR_PASSWORD]
Obviously, replace the parts that are in brackets with your actual username and password that you would use to connect to your network share. This would be your Windows password.
Edit your fstab file
Click on the root shortcut in dolphin again and open the folder named “etc“. In here, scroll down a ways and look for the file named “fstab“. Right click on it and choose Actions -> Edit as root. In this file, scroll down to the very bottom and add a couple of blank lines. Then add the following line:
//[IPADDRESS]/[SHAREDFOLDER] [MOUNTEDFOLDER] cifs credentials=/root/.smbcredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0
Again, replace the parts inside the brackets with real information. [IPADDRESS] is the IP address of the machine you are connecting to. You *can* use the computer name however for some reason this causes problems so I reccomend you find the IP address and use that. If you need to find out what the IP address is, go to your windows machine that you are trying to connect to and click on the start menu. Choose “run” and type “cmd” (without quotes) and press enter. When the window pops up type in “ipconfig” to see your ip address.
[SHAREDFOLDER] is just the name of the shared folder you are trying to access, and [MOUNTEDFOLDER] is the directories we created in the first part of this guide, for example, “/net/mkd/d“. Remember that uppercase and lowercase matters here. Also, note that between each field is a tab, though I think any whitespace (tabs or spaces) will do fine. In all, there should be 6 fields: ip address & shared folder name, mounted folder name, file system type (cifs), a long string of different options, 0, and another 0. I’m not sure what the last two are for but they are necessary.
Now when you restart you should have a network drive mounted for the shared directory sitting right on your desktop. Rename this to something meaningful like “d on mkd” and you’re almost done! You can add as many lines as you want to to fstab, and if it can’t find the network share it will simply ignore it. Just make sure to have a different folder in your net folder (or whatever name you gave it) for each network share you are trying to access. Going back to the example I used before, I might have folders for /net/mkd/d, /net/mkd/c, and /net/mediabox/d as different shared folders I’m connecting to.
A Fix for the Fix
Since that was not nearly complicated enough, we get to cover an additional fix for that fix. All of this just to be able to open a media file without copying it to your local hard drive! As you may notice when you restart, Kubuntu will take it’s jolly time to shutdown. It will also show the same cryptic error message for each of your mounted drives, which will usually add about an extra minute or two to the shutdown time for each shared folder you added. If you only mounted one shared folder then maybe this is acceptable, but if you mounted 6 like I did it is absolutely not acceptable.
First, we will need to use a script for unmounting all cifs drives before shutdown (all shared folders). Fortunately, two contributors to the Ubuntu forums came up with a solution for us: Max.durden modified a simpler version of jferrando’s script and posted it on the ubuntu forums here (http://ubuntuforums.org/showthread.php?t=293513). You may need to log in to be able to download the archive. Once you have downloaded it, right-click on it and choose Actions -> Extract to get the script file “mountcifs“.
Next, we have to install it. Open dolphin again if it isn’t already, and click on the root shortcut again. You may as well click on the option on the right for “open as root” now, since everything you do here will need to be done as root. Go into the folder /etc and look for the folder in here named “rc6.d“. Open this and copy and paste the script that you downloaded here.
Now, go to the K menu, choose “system“, and select “Konsole” to open a shell window. type the following commands one by one:
cd /etc/rc6.d
sudo chmod +x mountcifs
sudo ln -s /etc/init.d/mountcifs K02mountcifs
If all went well, you should be all set! Restart your machine and check to make sure that it doesn’t hang during shutdown anymore. If you still have problems with either mounting or unmounting your shared folders, I’m afraid you will have to consult the Ubuntu/Kubuntu forums or google. For me, the script worked fine and I believe this solution is complicated enough as it is.
I now have a shortcut on my desktop to all of the shared folders I regularly access on my Windows machines. Eventually, I will migrate them over to Linux, and hopefully this problem will go away altogether, but for now I can enjoy listening to music over the network on my Linux machine without any problems!
My iPhone Wishlist – Future Updates?
All the things I want from my iPhone and then some!
Driving home from work today I had a great idea in the car that I needed to write down so I didn’t forget. Now I love my iPhone to death, and use it all the time for taking notes. The only problem is when I am driving in my car this is not the safest or smartest thing to do.
It got me thinking about how I wish the iPhone had an audio recording feature so you could record mental notes for yourself when it is not convenient to write them down.
My mind started to wander, thinking about all the other functions that I wished the iPhone was capable of. I have had my iPhone since the week they first came out and this has given me plenty of time to come across numerous things I wish it could do. As if it doesn’t do enough already, I’m sure I am not alone when I say it needs to do more!
The first thing that is at the top of my list is an audio recording feature like I mentioned for making quick notes of things you need to remember. You could then set these audio reminders to calendar events that could be triggered as reminders or just look them up in a “notes’ type browser.
I really love the camera on my phone and I use it a lot. For the most part the pictures come out great! That is, when I have good lighting. If it is dark out, it is really hit or miss with the camera. Some pictures will come out nice, but most of the time they tend to come out grainy looking which can really ruin some shots.
I can understand why the iPhone doesn’t have a flash as this would probably chew through the battery life in no time, but I wish the camera had a higher megapixel count and some extended options for it. It is just so convenient to have the camera function that I use it all the time, and wish I had a little more control over it.
One thing I am really disappointed my iPhone doesn’t have is a video recording function. This seems like something that could have easily been incorporated since most digital cameras out there have the ability to capture motion jpeg. I am guessing this was also probably a battery life consideration but considering how great the video playback is on the phone it’s disappointing that you can’t record video with it.
Another really nice feature would have been a GPS capability. It seems silly, since most phones are required to utilize some sort of GPS technology for emergency services, that this can’t be put into practical use by users. The incorporation of Google maps and how well it works on the phone always drives me nuts when I think about how cool it would be to be able to track myself on that map as well. Between Apple and Google this seems like it should have been there from the start.
This next one is something I am sure I am not alone on, which is full fledged java and plugin support through Safari, especially for playing simple mpeg videos. Because of competition between Apple and Microsoft I can understand why the phone does not support WMV files but mpeg is pretty much standard. It is frustrating to be limited to videos in YouTube or content you have downloaded to the phone. It would make the internet experience on a phone unmatched in my opinion, if they could add this ability in the future.
Another thing that has really bugged me along these lines is that I cannot save files to my iPhone directly from a website. I’m talking about images to use as backgrounds, mp3s and videos to enjoy when I’m bored, and text files for projects I am working on. I can understand that this may be to protect the phone from potential security flaws, but having an 8GB hard drive that can’t store things at the touch of a button is like having a beach house I lost the key to. I don’t want to climb in through the window every time I want to enjoy that luxury.
The last 2 things I wish the iPhone had are an external keyboard similar to what some of the PDAs out there have, because I take lots of notes with my phone and I mean LOTS! I will use it for taking meeting notes, jotting down ideas, making lists, writing down songs to download, etc. I would really love a keyboard for those times when you are sitting down somewhere and you really want to get your ideas out in full. Especially for things like blogging!
The second thing along these lines would be a stylus. Now don’t get me wrong. The iPhone has one of the best touch screen systems I have ever used. In fact I was blown away by how good it actually is. You see it in the commercial and think there is no way it can be that good and then you use it yourself only to find out it’s better! I would just really like the ability to use a stylus for when I am messing around with various options and sliders in settings that are smaller than the standard keyboard letters. It would also be nice because then you could incorporate some type of doodle program for me too!
Ok have I asked for enough yet?
Don’t get me wrong, I love my iPhone. (Did I already mention that?) I take it everywhere and use it all the time. I have used it so much in fact that my battery is finally starting to show some slight signs of aging after about 10 months.
Requests like this show how good you have made something when people make all sorts of unreasonable demands about “lacking” features. Whenever I read a review on an item and the negative comments are “Did not come with a universal remote to start the vacuum from the other room”, I immediately buy that product because you know it must be good if that’s all there is to gripe about.
Speaking of which, where is my universal remote function Apple?
Why can’t my phone control all the things in my real life like it does in my cyber life? Oh wait that’s right! Check out the following article for information on rumors that apple is developing limited universal remote functionality for the iPhone. (For use with iTunes of course)
http://blog.wired.com/gadgets/2008/04/rumor-apple-to.html
But considering they can do this, it would be nice to control all the rest of the stuff in the house with my iPhone too.
Even if it can’t do these things I guess I can settle for what it currently offers me. It’s like having someone cook dinner for me, and then complaining that I wanted to get Chinese take out. I guess I have set pretty high standards for my iPhone but it is only because I see the potential for this device and all the things it can be used for in the future.
I hope Apple sees the same thing and continues to build on the great device they have already created.
