You are not logged in.

#26 2011-05-21 05:28:30

semeion
Member
From: Brazil
Registered: 2008-10-20
Posts: 56

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

working fine for me, thanks!

Offline

#27 2011-05-23 20:41:30

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

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

semeion wrote:

working fine for me, thanks!

Awesome, thanks for the feedback smile

bashmount 1.2.0 just released, with some code refactoring and a fix for the "unmount all" command.


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#28 2011-05-26 21:08:59

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

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

bashmount 1.3.0 released with various bug fixes.

There is a new configuration option called fancy_sort. This option is basically a big hack to get around a shortcoming of the sort command, which causes /dev/sdc11 to be shown in the menu before /dev/sdc2. This option deals with /dev/sd* and /dev/dm-* devices, but not /dev/mmcblk* devices as the sorting is not that simple. I have disabled this option by default. I introduced this change in response to a request by an obdevicemenu user.

Kudos to anyone who can implement it in a less hacky way than I did smile

Last edited by jnguyen (2011-05-26 21:24:58)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#29 2011-05-31 07:25:18

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

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

bashmount 1.3.1 released, which just fixes a typo when displaying optical devices.


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#30 2011-07-28 23:19:23

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

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

Hi jnguyen,

bashmount looks very interesting to me! I use arch (64bit version) with Xfce and compiz. I have this file:

# cat /etc/polkit-1/localauthority/50-local.d/org.freedesktop.udisks.pkla 
[Local Users]
#Identity=unix-user: your_username
Identity=unix-group:storage
Action=org.freedesktop.udisks.*
ResultAny=yes
ResultInactive=no
ResultActive=yes

I don't know exactly what this is for, but my guess is, it should allow normal users (that are a member of the storage group) to mount and unmount partitions which is otherwise reserved to the root user.

My user is a member of the storage group:

~> groups
sys lp wheel video audio optical storage power users vboxusers

If I try to mount a partition from a USB stick with bashmount, I get this:

Command: 1m

==> Mounting /dev/sdc1 ...

Mount failed: Not Authorized

==> ERROR: /dev/sdc1 could not be mounted.

I can run and successfully mount partitions if I call bashmount as root. But then my normal user has no permission to access the files in the resulting /media/XYZ directory. I guess, I am doing something wrong...

@jnguyen: Perhaps you can give me a hint what it is or could be.

Thanks in advance & kind regards,
jamesbond007.

Offline

#31 2011-08-03 11:27:49

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

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

Hi jamesbond007. Sorry for the late reply.

It sounds like a policykit problem. How do you start your X session? Is it a login manager, or do you use ~/.xinitrc ? If you use xinitrc, perhaps you could post it?

Last edited by jnguyen (2011-08-03 11:28:32)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#32 2011-08-03 15:52:12

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

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

Hi jnguyen,

thanks for your reply.

jnguyen wrote:

How do you start your X session?

I use SLiM (Simple Login Manager) and the .xinitrc looks like this:

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

exec ck-launch-session startxfce4

Anything wrong with that?

Offline

#33 2011-08-04 06:42:26

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

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

You could try doing this.


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#34 2011-08-04 20:34:36

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

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

Hi jnguyen,

/etc/slim.conf already contained this (no need to modify):

login_cmd exec ck-launch-session /bin/bash -login ~/.xinitrc %session

So the only thing I changed in .xinitrc was from

exec ck-launch-session startxfce4

to

exec startxfce4

I did not really expect this to cause any improvement, but: now bashmount seems to work like a charm!

Do you think this was caused by the modification of .xinitrc or could it be just some kind of strange coincidence?

Offline

#35 2011-08-04 23:19:12

Shinryuu
Member
From: 俺のコスモス
Registered: 2010-02-27
Posts: 338

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

Wooosh.. Finally some non-GUI, cli based simpliticy! Works like a charm and helps me quite a bit with things.

Offline

#36 2011-08-08 08:28:05

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

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

jamesbond007 wrote:

So the only thing I changed in .xinitrc was from

exec ck-launch-session startxfce4

to

exec startxfce4

Do you think this was caused by the modification of .xinitrc or could it be just some kind of strange coincidence?

Yes I believe it was the change to xinitrc that fixed the problem. I think ck-launch-session need only be used in either slim.conf or xinitrc, not both.

Shinryuu wrote:

Wooosh.. Finally some non-GUI, cli based simpliticy! Works like a charm and helps me quite a bit with things.

I'm glad you are finding it useful smile

Last edited by jnguyen (2011-08-08 08:28:41)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#37 2011-08-31 19:23:10

igoyak
Member
Registered: 2011-08-31
Posts: 3

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

Thanks a lot, I've been looking for this for a long time. smile
I have one suggestion, to improve user friendliness you can substitute:

read -r -e -p "Command: " action

with:

read -s -n1 -p "Command: " action

This will not wait for _Enter_ after user input.

Offline

#38 2011-09-03 13:14:02

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

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

igoyak wrote:

Thanks a lot, I've been looking for this for a long time. smile
I have one suggestion, to improve user friendliness you can substitute:

read -r -e -p "Command: " action

with:

read -s -n1 -p "Command: " action

This will not wait for _Enter_ after user input.

Thanks for your feedback smile

Personally, I think not waiting for [enter] here would be inconsistent with the behaviour of other menu screens in bashmount. Having to press [enter] also reduces the chance of choosing the wrong option by accident.

Last edited by jnguyen (2011-09-03 13:14:40)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#39 2011-09-05 13:01:27

keenerd
Trusted User (TU)
Registered: 2007-02-22
Posts: 647
Website

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

Could you add support for hd-idle?  As far as I know, it is the only way to spin down hard drives in linux.  (If it is not the only, then it is certainly the easiest.)  Before hd-idle I was breaking an external drive every six months.  My latest crop of drives has been running fine for a year.

Using it is pretty simple.  Its got a bunch of fancy daemon stuff, but you don't need that.  All you need is to spin down the drive once there are no more mounted partitions.  This is just

hd-idle -t sdb

(for /dev/sdb)

Offline

#40 2011-09-05 15:19:21

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

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

keenerd wrote:

Could you add support for hd-idle?  As far as I know, it is the only way to spin down hard drives in linux.

Hi keenerd, could you try changing this function in bashmount to look like this:

action_unmount() {
	local -i info_mounted=
	check_device "${1}" || return 1
	info_mounted="$(info_mounted "${1}")"
	if [[ "${info_mounted}" -eq 0 ]]; then
		printf '\n'
		error "${1} is already unmounted."
		enter_to_continue
		return 1
	fi

	printf '\n'
	msg "Unmounting ${1} ..."
	printf '\n'
	$udisks --unmount ${1}
	info_mounted="$(info_mounted "${1}")"
	if [[ "${info_mounted}" -eq 1 ]]; then
		printf '\n'
		error "${1} could not be unmounted."
		enter_to_continue
		return 1
	fi
	msg "${1} unmounted successfully."

	msg "Running post_unmount ..."
	dev=${1#/dev/}; hd-idle -t ${dev%%[0-9]*}

	enter_to_continue
}

I'll obviously implement it differently so that it's configurable via bashmount.conf. I just wanted to check that it works how you want. I haven't installed hd-idle but I have a feeling hd-idle needs sudo, so put that in if required.


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#41 2011-09-05 22:31:01

keenerd
Trusted User (TU)
Registered: 2007-02-22
Posts: 647
Website

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

It does need sudo.  It also does the wrong thing on the edge case I mentioned, when you have multiple partitions on a drive and some are still mounted.  So it needs something like

dev=${1%%[0-9]*}
if ( ! mount | grep -q "^$dev" ); then
    sudo hd-idle -t ${dev#/dev/}
fi

hd-idle also seems to be harmless for the handful of flash drives I tested it on.

Offline

#42 2011-09-05 22:49:53

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

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

By the way, does this command work for your devices?

udisks --detach /dev/sdb

TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#43 2011-09-06 00:04:40

keenerd
Trusted User (TU)
Registered: 2007-02-22
Posts: 647
Website

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

I never use --detach.  It powers down the port.  This has the same effect as ripping the plug out - the drive will attempt an emergency park and over time the drive will break.  Detaching a few tenths of a second after hd-idle is probably a good idea though.

Offline

#44 2011-09-06 00:18:13

dhave
Arch Linux f@h Team Member
From: Outside the matrix.
Registered: 2005-05-15
Posts: 1,110

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

This is nicely done, jnguyen. Thanks for your work on it.


Donate to Arch!

Tired? There's a nap for that. --anonymous

Offline

#45 2011-09-06 06:00:46

vinoca
Member
Registered: 2011-07-24
Posts: 4

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

nice.i think udev is more concise.

KERNEL!="[hs]d[b-z][0-9]|mmcblk[0-9]p[0-9]",GOTO="am_usb_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# specify a label
ENV{dir_name}="u-%k"
# Global mount options
ACTION=="add",ENV{mount_options}="defaults" 
# Filesystem-specific mount options 
ACTION=="add",ENV{ID_FS_TYPE}=="vfat|ntfs",ENV{mount_options}="$env{mount_options},utf8,umask=000"
# Mount the device 
ACTION=="add",ENV{ID_FS_TYPE}!="ntfs",RUN+="/bin/mkdir -p /media/$env{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/$env{dir_name}"
# Clean up after removal
ACTION=="remove",RUN+="/bin/umount -l /media/$env{dir_name}",  RUN+="/bin/rmdir /media/$env{dir_name}",RUN+="/bin/rm /media/$env{dir_name}"
# Exit
LABEL="am_usb_end"

Offline

#46 2011-09-06 10:08:41

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

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

keenerd wrote:

Could you add support for hd-idle

Done in bashmount 1.4.0.

I've added two options in bashmount.conf. post_mount is a hook that runs immediately after a successful mount operation. post_unmount is a hook that runs immediately after a successful unmount operation. These hooks can be edited in bashmount.conf to run any arbitrary commands.

Please let me know if you encounter any bugs!

dhave wrote:

This is nicely done, jnguyen. Thanks for your work on it.

Thanks for the kind words smile

vinoca wrote:

nice.i think udev is more concise.

Those looks like automounting rules. bashmount doesn't try to do any automounting. In fact, you can use bashmount alongside any automounting solution, such as udev rules, udiskie or even nautilus.

Last edited by jnguyen (2011-09-06 10:10:19)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#47 2011-09-16 14:41:12

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

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

bashmount 1.5.0 released.

Development can now be followed at Gitorious.

Last edited by jnguyen (2011-09-16 14:42:20)


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#48 2011-09-20 19:54:16

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

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

bashmount 1.5.1 released with a fix for the "fancy_sort" function.

Thanks to WorMzy for reporting: https://bbs.archlinux.org/viewtopic.php … 75#p992575


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#49 2011-11-04 08:52:13

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

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

bashmount 1.5.3 released with a number of fixes for the device sub-menus.


TOMOYO Linux: Mandatory Access Control.
My AUR packages

Offline

#50 2011-11-05 03:55:19

rogue
Member
Registered: 2011-08-03
Posts: 68
Website

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

Thank you for this wonderful little utility jnguyen! Bashmount is simplistic and useful smile

Last edited by rogue (2011-11-06 13:08:48)

Offline

Board footer

Powered by FluxBB