Tag Archives: ubuntu

Mounting external usb drives automatically to its label

I am maintaining a file server running Ubuntu 12.04 in my company and was faced with the problem how to backup my system easily and on a low cost. As we have a huge amount of data and a rather slow internet connection have I made the decision to backup onto external hard drives which we will rotate frequently. In the end USB drives are still the cheapest option to backup your data… ;).

This blog post is though not about backing up your data but rather how to mount a USB drive automatically when connected to a server and access it with its label. This helped me to have a specific mount point for backup hard discs but won’t interfere if anyone else needs to connect another USB drive to the server. I am sure you might have different use cases for such feature as well. I have tested following configuration on a Ubuntu Server 12.04 but it should run on other Debian based operating systems as well.

OK this said let’s get started with the configuration then.

While I was looking for a tool to automatically mount my usb drives have I found usbmount which was very simple and pretty much worked out of the box.

You can install it with the following command:
apt-get install usbmount

After usbmount is installed you can simply connect your usb drive to your server and usbmount will automatically mount it to /media/usb0. When an additional drive is connected it will be mounted to /media/usb1 and so on.

That’s a good start… but there is a draw back that every drive connected to the server will be mounted to /media/usb0 so we cannot really distinguish the different drives from each other. But usbmount has a feature for this that it creates a symlink for each drive in the folder /var/run/usbmount.

Such symlink can look like the following:
lrwxrwxrwx 1 root root 11 Apr 11 10:53 SAMSUNG_HM160HI_1 -> /media/usb0

The name of the symlink is built by using the vendor, model and partition number. So accessing the hard disc you simply access it using this symlink. This is great when you want to identify a specific hard disc. There is still one problem with it though when I want a group of hard disc to be access the same way I cannot really use this symlink.

So my idea was why not using the volume label and when I format hard drives I simply give all those drives the same volume label.

This can be done for instance with following format command using ext4 as an example (of course you can change ext4 to whatever file system you need):
mkfs.ext4 -L VOLUMENAME /dev/sdb1

Unfortunately usbmount doesn’t create any symlink of drives by its volume label. I therefore created following script to do this:

#!/bin/sh
# This script creates the volume label symlink in /var/run/usbmount.
# Copyright (C) 2014 Oliver Sauder
#
# This file is free software; the copyright holder gives unlimited
# permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
#
set -e
 
# Exit if device or mountpoint is empty.
test -z "$UM_DEVICE" && test -z "$UM_MOUNTPOINT" && exit 0
 
# get volume label name
label=`blkid -o udev /dev/sdc1 | grep ID_FS_LABEL\= | cut -d'=' -f2`
 
# If the symlink does not yet exist, create it.
test -e "/var/run/usbmount/$label" || ln -sf "$UM_MOUNTPOINT" "/var/run/usbmount/$label"
 
exit 0

This script you have to save to /etc/usbmount/mount.d/01_create_label_symlink and do not forget to add executable rights to it (chmod +x /etc/usbmount/mount.d/01_create_label_symlink). usbmount will run this script whenever a hard disc is connected.

Beside creating this symlink we also have to make sure that the symlink will be removed when the hard disc is disconnected. usbmount already has a script which removes symlink from /var/run/usbmount but we have to adjust it as it only removes the first link and not all. We can simply open the file /etc/usbmount/umount.d/00_remove_model_symlink and remove the break statement in line 19.

The script will then look like the following:

#!/bin/sh
# This script removes the model name symlink in /var/run/usbmount.
# Copyright (C) 2005 Martin Dickopp
#
# This file is free software; the copyright holder gives unlimited
# permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
#
set -e
 
ls /var/run/usbmount | while read name; do
    if test "`readlink \"/var/run/usbmount/$name\" || :`" = "$UM_MOUNTPOINT"; then
        rm -f "/var/run/usbmount/$name"
    fi
done
 
exit 0

So now when we connected a hard disc to the server there will be a symlink created /var/run/usbmount/VOLUMENAME and such path we can then use to point to for backups or whatever other use case you have.

Hope this was helpful. While working with usbmount I have found some more articles which might be helpful for you e.g. when you have issues with permissions or want to use ntfs as a file system.

Clipboard Unity Scope with its full potential

Test version of Diodon with its new Zeitgeist integration has been out for a while. In the first test version there was only a limited version of Unity Diodon Scope available. We have been working on improving this integration to bring the Unity Scope to its full potential. In this post do I want to describe what new features have been integrated and how you can testrun those before we hopefully release them soon.

When the Unity Scope (resp. Lens back then) has been introduced in Diodon version 0.4.0 it was fairly limited and it was only possible to search in the recent clipboard history which had a limit of 100 items. With the recent change of Zeitgeist and infinitive clipboard history this limit has been removed and makes the Unity Scope more powerful itself.

But there is more like the new filters for category (Text, Files, Images) or time when a clipboard item has been copied.

Diodon Unity Scope Filter

With this filter and text search available you hopefully find any item you have copied before. There is also a preview available when you click on a clipboard item. The preview will show you the full content of the item (especially helpful when verifying a longer piece of text) with additional information what application the item has been copied from and the date copied.

Unity Diodon Scope Preview

You can open Unity Diodon Scope with the hotkey <Super>b or simply by pressing the clip icon on the right hand side on the dash and start search your clipboard history.

The Diodon Scope used to be an plugin which caused some issues as Smart Scopes service was not able to start and stop it itself. We therefore have now turned the scope into its own service as it should be which also gives the advantage that the scope can be closed when not needed to safe resources, but started as soon as requested.

This brought about some changes in the packages to install it – we have removed the package diodon-plugins (will be added again as soon as we have other plugins available again) and added a new package unity-scope-diodon. As soon as you have installed this package and logged in and out again the scope will be available. No need to activate it as before.

If you are interested and want to test it use the following commands:
sudo add-apt-repository ppa:diodon-team/daily
sudo apt-get update
sudo apt-get install diodon unity-scope-diodon

Let us know what you think and report a bug if you find any glitches or have suggestion to improve it.

I herewith also want to thank all translators who took the time to update the Diodon translations. Great work. There are still some translations which are not quite up-to-date yet. Have a look whether you can help out.

Diodon is getting official

I am glad to announce that with version 1.0.2 Diodon has made it into the official Ubuntu repository for Raring. This means that from Ubuntu 13.04 onwards no PPA will be needed to install Diodon. So simply install it with apt-get or use the Ubuntu Software Center.

Of course the Stable Diodon PPA will remain for other versions of Ubuntu and to release stable packages which have not made it into the official repository yet. And for all lovers of cutting edge software, there is still the Daily PPA for the daily snapshots of Diodon.

Additionally with version 1.0.2 comes there a Apport integration so you can simply report bugs. Just use the following command to do so:

ubuntu-bug diodon

Apport is collecting data like what version of Diodon is installed, what are the dependencies etc. and then also ask you whether you want to include your clipboard history. It then puts all this together and uploads it to Launchpad.net, where you can input a bug description. And then hopefully with all this information we will be able to find the cause of the issue quickly and provide a fix.

So therefore have fun using Diodon and do not hesitate to file any bug or annoyance you find.

Starting a new Diodon era with a new look and feel

It has been two years when the first version 0.1.0 of Diodon has been released. A lot of work has been done since when it comes to features but mainly to integration into the desktop. This new release is just one of those little steps to make Diodon better integrated and even more useful (see issues solved). And there are still many ideas to be implemented in the future.

Nevertheless is this new version of Diodon a special milestone and therefore I want to give it the version 1.0.0. This is mainly to its long overdue new icons set which gives it’s unique look and feel. razvi of iloveubuntu.net has summarized the significance of this change in this blog post which I want to quote here:

Usually, app icons play an important role on establishing the identity of applications, visual items that contain essential aspects of applications and/or shapes, colors, patterns, etc, designed with an easy-app-identification process in mind. [...] Diodon has just been enriched with new icons, refreshing its identity and properly expressing itself via simplistic yet interesting monochrome icons, as well as adopting colored icons.

DiodonIndicator

As a celebration of this new milestone I think it is also time to start promoting Diodon even more. I therefore put a list together with possibilities for you to help out. And I am sure you will have plenty of more ideas.

  • Post about Diodon on your blog
  • You use another distribution then Ubuntu? Create packages for this distribution (I promise that I will soon look into making a package for the official Ubuntu repository).
  • Add Diodon to your software stack on Ohloh.net by using the I Use This! button.
  • Mark Diodon as “Like” on AlternativeTo and add alternatives
  • Now, there is also a Diodon user group on launchpad. Join in to show your appreciation to Diodon and also optionally take part in the mailing list conversations.
  • Or simply follow Diodon on Freecode

I am looking forward to see Diodon getting more adapted in 2013. I herewith also wanted to take the opportunity to thanks the Diodon user community for all the valuable feedback I have received and for you loyalty ;). Thanks… and have a happy new year 2013…

Diodon now with a zeitgeist

Diodon version 0.9.0 has been released today which is basically a maintenance release so it runs smoothly on Ubuntu 12.10. However, behind the scenes a few more things have changed.

For instance is there now a unit testing framework in place which I wrote about in a previous post.

What I want to introduce you in this post though is a start into a new Diodon era using Zeitgeist. You might ask yourself: What is Zeitgeist?

That’s a good question and I think best answered by the Zeitgeist folks themselves. So here is a quote from there website:

Zeitgeist is a service which logs the users’ activities and events, anywhere from files opened to websites visited and conversations had.

It makes this information readily available for other applications to use. It is able to establish relationships between items based on similarity and usage patterns.

As Diodon is basically keeping a history of the last users’ copy events it makes perfect sense to store those events in Zeitgeist. Therefore is there now a Zeitgeist plugin (a so called Data Source) available for Diodon. You simply have to install the package diodon-plugins and enable the plugin by going to Preferences -> Plugins.

What this plugin for now basically does is storing a description of what has been copied at a certain time plus the path to the original application content has been copied from. It also points to a clipboard id. However as items currently get deleted when a certain history size has been reached, this id can not be used to execute a copy/paste event again. There are some ideas though for the future that it might be possible to replace the current xml based storage with Zeitgeist completely. This is however only an idea so far. This Diodon Zeitgeist Plugin therefore is a playground to really see what Zeitgeist is capable of and how well it works with a clipboard manager. So if you have any feedback where we can go further from here, please let me know.

Will keep you updated about more exciting news when it comes to Diodon.