You are not logged in.

#1 2011-04-27 10:07:51

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

bashmount: removable devices kept simple and made easy!

Links
Sourceforge Project Page
AUR Package
GitHub Repository

Screenshots
Main menu
Device sub-menu
Custom commands

Overview
bashmount is a menu-driven bash script that uses udisks to easily mount, unmount or eject removable devices without dependencies on any GUI or desktop environment. An extensive configuration file allows many aspects of the script to be modified and custom commands to be run on devices. It is written in bash and ~1000 SLOC so is easily hackable.

This script does not provide automounting of removable media as there are already many ways to automount. The file managers in GNOME and KDE handle automounting, while udev rules or scripts like Udiskie can be used in other environments. However, bashmount can be used alongside any of these, and should work in any recent distribution that uses udisks.

You should edit the configuration file first before running. Make sure to always copy over the configuration file, as some options may be changed or added in each release.

Notes
Dbus and consolekit/policykit need to be running. If you aren't using a login manager, put this in ~/.xinitrc:

source /etc/X11/xinit/xinitrc.d/30-dbus
exec ck-launch-session i3

If it doesn't already exist, create the file "/etc/polkit-1/localauthority/50-local.d/10-udiskie.pkla" with these contents:

[Local Users]
Identity=unix-group:storage
Action=org.freedesktop.udisks.*
ResultAny=yes
ResultInactive=no
ResultActive=yes

Bug reports, comments and criticisms welcome! smile

Last edited by jnguyen (2012-02-06 20:55:35)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#2 2011-04-27 10:55:29

metre
Member
Registered: 2011-03-13
Posts: 130

Re: bashmount: removable devices kept simple and made easy!

Wrong link (http://aur.archlinux.org/packages.php?ID=48524).

Anyway, good job, indeed! KISS and comfortable at the same time

Offline

#3 2011-04-27 10:58:06

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

metre wrote:

Wrong link (http://aur.archlinux.org/packages.php?ID=48524).

Anyway, good job, indeed! KISS and comfortable at the same time

Oops, fixed now!

Thanks, I'm glad you find it useful smile


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#4 2011-04-27 11:25:40

Rupp
Member
Registered: 2010-02-14
Posts: 47

Re: bashmount: removable devices kept simple and made easy!

That is really nice. Good job.

Offline

#5 2011-04-27 15:45:25

mundane
Banned
Registered: 2011-03-23
Posts: 49

Re: bashmount: removable devices kept simple and made easy!

I liked obdevicemneu, but this is even better! Thanks!

Offline

#6 2011-04-27 22:46:26

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

Thanks for the feedback smile

@mundane: you can actually use both obdevicemenu and bashmount together. I prefer bashmount though, as there are some things that I have implemented better, and you also don't have to use a mouse cool


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#7 2011-04-27 23:25:05

metre
Member
Registered: 2011-03-13
Posts: 130

Re: bashmount: removable devices kept simple and made easy!

jnguyen, let my add that your way to show your software is really awesome: I mean, Title, Links, Screenshots, Overview. A model of clarity and elegance.
You deserve every compliment you get

Offline

#8 2011-04-28 17:16:48

mundane
Banned
Registered: 2011-03-23
Posts: 49

Re: bashmount: removable devices kept simple and made easy!

I have moved permanently from obdevicemenu to bashmount now....... I really like how configurable it is!

It really is well thought out, good job

Offline

#9 2011-04-29 08:20:19

Sirsurthur
Member
Registered: 2009-02-02
Posts: 114

Re: bashmount: removable devices kept simple and made easy!

Thanks, it looks great ! Would bashmount also work for floppy disks ?

Offline

#10 2011-04-29 15:01:26

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

Thanks very much for the feedback everyone smile

Sirsurther wrote:

Thanks, it looks great ! Would bashmount also work for floppy disks ?

I'm pretty sure udisks will support floppy disks. I just don't have a floppy drive in order to test roll so if you could help me out with a few questions then that would be great! I'm assuming that your floppy drive appears as /dev/fd0.

1) Is this device file (/dev/fd0) present even when there is no floppy drive inside? If yes, then could you post the output of "udisks --show-info /dev/fd0" with no floppy disk in the drive.

2) Post the output of "udisks --show-info /dev/fd0" with a floppy disk inserted but not mounted.

3) Keep the floppy disk in the drive and try running "udisks --mount /dev/fd0" and post the output if any.

4) Post the output of "udisks --show-info /dev/fd0" with a floppy disk inserted and is mounted.

Remember to put BBCode code tags around the output when you post it up here!

Last edited by jnguyen (2011-04-29 16:02:59)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#11 2011-04-29 20:06:39

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 149
Website

Re: bashmount: removable devices kept simple and made easy!

Very nice application! smile One question: this is the only application that uses the dbus daemon on my system. Is there a way to circumvent dbus?

Offline

#12 2011-04-30 11:44:28

Sirsurthur
Member
Registered: 2009-02-02
Posts: 114

Re: bashmount: removable devices kept simple and made easy!

Hello jnguyen,

Answers to your questions :

1) output when there is no floppy drive inside "udisks --show-info /dev/fd0" : http://pastebin.fr/11222

2) output with floppy but not mounted "udisks --show-info /dev/fd0" : http://pastebin.fr/11223

3) output when mounted  "udisks --mount /dev/fd0" : http://pastebin.fr/11224

4) output when mounted "udisks --show-info /dev/fd0" : http://pastebin.fr/11225

Thanks for your help. Best regards,

Offline

#13 2011-04-30 15:37:01

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

Sirsurthur wrote:

1) output when there is no floppy drive inside "udisks --show-info /dev/fd0" : http://pastebin.fr/11222

2) output with floppy but not mounted "udisks --show-info /dev/fd0" : http://pastebin.fr/11223

3) output when mounted  "udisks --mount /dev/fd0" : http://pastebin.fr/11224

4) output when mounted "udisks --show-info /dev/fd0" : http://pastebin.fr/11225

Thanks for posting these.

Good news is that it is quite simple to support floppy disks. Just change to this in the configuration file:

optical_devices="-E ^/dev/sr[0-9]+|^/dev/fd[0-9]+"

Or you could add to removable_devices instead depending on where you want your floppy drive to show up in bashmount:

removable_devices="-E ^/dev/sd[b-z]?[0-9]*|^/dev/fd[0-9]+

Bad news is that with the above change to the configuration file, "fd0" will always be present in bashmount whether there is a floppy disk inside or not. Floppy drives are similar to optical drives in that the device file is always present. However, udisks is able to tell if there is a CD/DVD inserted, but is not able to tell whether a floppy disk is inserted (judging from the output you gave me). Currently, bashmount hides the /dev/sr0 entry if no CD/DVD is inside.


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#14 2011-04-30 15:43:56

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

Revelation60 wrote:

Very nice application! smile One question: this is the only application that uses the dbus daemon on my system. Is there a way to circumvent dbus?

Thank you smile

Dbus is not a direct dependency of bashmount but is a dependency of udisks. I'm pretty sure you can't really use udisks without dbus running, sorry. From the udisks freedesktop.org page:

The udisks project provides: a storage daemon that implements well-defined D-Bus interfaces that can be used to query and manipulate storage devices.

If it's any consolation, it is the same situation on my system: nothing else is using dbus. But personally I'd much rather be able to handle removable devices a little easier than try to run a system without dbus.

Last edited by jnguyen (2011-04-30 15:44:59)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#15 2011-04-30 19:35:31

Sirsurthur
Member
Registered: 2009-02-02
Posts: 114

Re: bashmount: removable devices kept simple and made easy!

jnguyen wrote:

Good news is that it is quite simple to support floppy disks. Just change to this in the configuration file:

optical_devices="-E ^/dev/sr[0-9]+|^/dev/fd[0-9]+"

I added this to my /etc/bashmount.conf and it seems that bashmount still doesn't look at my floppy disks ?

Thanks again for your help !

Offline

#16 2011-04-30 22:39:47

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

Sirsurthur wrote:
jnguyen wrote:

Good news is that it is quite simple to support floppy disks. Just change to this in the configuration file:

optical_devices="-E ^/dev/sr[0-9]+|^/dev/fd[0-9]+"

I added this to my /etc/bashmount.conf and it seems that bashmount still doesn't look at my floppy disks ?

Thanks again for your help !

Oops, bad advice on my part. Looking at the code again, it should (hopefully) work if you undo your changes to optical_devices and append this to removable_devices instead:

removable_devices="-E ^/dev/sd[b-z]?[0-9]*|^/dev/fd[0-9]+"

TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#17 2011-05-01 08:54:53

Sirsurthur
Member
Registered: 2009-02-02
Posts: 114

Re: bashmount: removable devices kept simple and made easy!

jnguyen wrote:

Oops, bad advice on my part. Looking at the code again, it should (hopefully) work if you undo your changes to optical_devices and append this to removable_devices instead:

removable_devices="-E ^/dev/sd[b-z]?[0-9]*|^/dev/fd[0-9]+"

Thanks, now it works ! smile great bashscript !

Offline

#18 2011-05-01 09:11:17

metre
Member
Registered: 2011-03-13
Posts: 130

Re: bashmount: removable devices kept simple and made easy!

Sirsurthur wrote:
jnguyen wrote:

Oops, bad advice on my part. Looking at the code again, it should (hopefully) work if you undo your changes to optical_devices and append this to removable_devices instead:

removable_devices="-E ^/dev/sd[b-z]?[0-9]*|^/dev/fd[0-9]+"

Thanks, now it works ! smile great bashscript !

so it's finally time for bashscript 1.1, I suppose tongue

Offline

#19 2011-05-01 16:54:44

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

Sirsurthur wrote:

Thanks, now it works ! smile great bashscript !

No problem smile

metre wrote:

so it's finally time for bashscript 1.1, I suppose tongue

Yep, in the next version I will put in a comment within bashmount.conf to demonstrate how to include floppy drives. Also a bit of code review going in too smile


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#20 2011-05-08 15:06:04

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

bashmount 1.1.0 released, now with support for SD card readers (which appear as /dev/mmcblk* devices).

I don't actually have a card reader to test this, so please do let me know if it doesn't work at all!

Please remember to update your configuration files, as there are several changes.

Last edited by jnguyen (2011-05-08 15:07:49)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#21 2011-05-08 15:39:33

Awebb
Member
Registered: 2010-05-06
Posts: 4,418

Re: bashmount: removable devices kept simple and made easy!

That thing is cool. I use thunar for auto-mounting, but sometimes it does not unmount the devices quick enough when I want to access them via gparted. I always had to use small scripts to do that and they failed sometimes.

One little problem though... It shows me the following drives:

bashmount 1.1.0

================== REMOVABLE MEDIA ==================

5) sde: No label (A953)
6) sdf1: Exile [mounted]

=================== OPTICAL MEDIA ===================


===================== COMMANDS ======================

e: eject   i: info   m: mount   o: open   u: unmount

a: unmount all   r: refresh   q: quit   ?: help

=====================================================


Command: 

It says the drives have the number 5 and 6 (for 5=e and 6=f), but I have to access them with 1 and 2, for they are the first and the second in the list. I haven't had a look at the settings yet, maybe it's in there.

Online

#22 2011-05-08 15:41:46

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

Hi awebb, can you post your bashmount.conf as well please (if you've changed it), and the output of:

udisks --enumerate-device-files

Last edited by jnguyen (2011-05-08 15:44:02)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#23 2011-05-08 16:27:37

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

bashmount 1.1.3 released. Again, several important configuration file changes were made so remember to update them. This should fix some issues regarding /dev/mmcblk* devices, as well as numbering.

Awebb, can you also let me know if bashmount 1.1.3 fixes your problem.

Last edited by jnguyen (2011-05-08 16:43:18)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#24 2011-05-12 10:18:22

chris.elliot
Member
Registered: 2011-05-12
Posts: 1

Re: bashmount: removable devices kept simple and made easy!

Just wanted to say a big thank you for writing this script. It's so comfortable to use and works flawlessly on Debian Testing, Ubuntu Natty 11.04 and all other Ubuntu derivatives I've tried, even on the Unity or GNOME desktops. I don't use Archlinux yet, but I've been thinking about giving a try!

Offline

#25 2011-05-19 11:25:31

jnguyen
Member
Registered: 2011-02-17
Posts: 139
Website

Re: bashmount: removable devices kept simple and made easy!

chris.elliot wrote:

Just wanted to say a big thank you for writing this script. It's so comfortable to use and works flawlessly on Debian Testing, Ubuntu Natty 11.04 and all other Ubuntu derivatives I've tried, even on the Unity or GNOME desktops. I don't use Archlinux yet, but I've been thinking about giving a try!

Thanks for the feedback smile I got desktop universality for free due to the integration of udisks into pretty much all modern Linux distros.

1.1.4 released with only minor code changes.


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

Board footer

Powered by FluxBB