You are not logged in.

#1 2010-11-30 07:13:28

Ledti
Member
Registered: 2010-07-31
Posts: 122
Website

simple bash functions/aliases for udisks2

Here are some bash functions/aliases I made for (un)mounting devices through udisks. I wasn't sure if it was worth making a post over, but they're very useful and I haven't seen anything similar and as simple.

I recommend saving it to a separate location and sourcing it in your .bashrc file as it's somewhat long.

Code:

You can get it direct from gist here.

git clone git://gist.github.com/838039.git

Or for convience, you can get it from the AUR.

Usage:

It includes eight functions: sdm, sdu, mcm, mcu, srm, sru, fdm, and fdu and here's how you use them:

# mount all sd* devices
$ sdm
# mount all partitions on device sdb
$ sdm sdb
# mount the second partition on device sdb
$ sdm sdb 2
# same as above
$ sdm sdb2
# the sdu command is just the opposite of sdm, this will unmount the first partition on device sdc
$ sdu sdc 1
# same as above
$ sdu sdc1
# mount all cd/dvd devices
$ srm
# mount first cd/dvd device only
$ srm 0
# unmount third cd/dvd device (who has three?)
$ sru 2
# unmount all cd/dvd devices
$ sru
# mount all floppy devices
$ fdm
# mount all mmc devices
$ mcm

It also automatically creates aliases that slightly shorten the sdm, sdu, mcm, and mcu functions:

# mount all partitions on the device sdd
$ sddm
# unmount the second partition on sdc
$ sdcu 2
# mount the first partition on the first mmc device
$ mc0m p0
# mount all partitions on the first mmc device
$ mc0m
# this will not work
$ sdcu2
bash: sdcu2: command not found

Last edited by Ledti (2012-08-05 16:01:08)

Offline

#2 2010-11-30 08:50:54

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: simple bash functions/aliases for udisks2

Those are very nice functions. I think people will appreciate being able to to have simple udisks commands that only depend on bash.

It's too bad that adding optical disc support with udisks is such a pain in the bash. Please let me know if you'd like help with it, or, just check out the source code for one of the udisks wrappers.

Also, when you feel it's ready, I totally recommend adding a link to this thread in the wiki page on udev.

Last edited by drcouzelis (2010-11-30 08:51:51)

Offline

#3 2010-11-30 20:01:07

Ledti
Member
Registered: 2010-07-31
Posts: 122
Website

Re: simple bash functions/aliases for udisks2

drcouzelis wrote:

Those are very nice functions. I think people will appreciate being able to to have simple udisks commands that only depend on bash.

It's too bad that adding optical disc support with udisks is such a pain in the bash. Please let me know if you'd like help with it, or, just check out the source code for one of the udisks wrappers.

Also, when you feel it's ready, I totally recommend adding a link to this thread in the wiki page on udev.

I had totally forgotten about CD/DVD support (I'm on a netbook). Thanks for the reminder and kind words. I added two new functions that (I think) should mount all CD/DVD devices via /dev/sr*. Choosing the right method was rather ambiguous because CD/DVD devices create /dev/cdrom, /dev/dvd, and /dev/sr*.

I'll look into adding it to the wiki within the week.

Offline

#4 2010-12-01 17:50:43

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

Re: simple bash functions/aliases for udisks2

Great functions ! Would it be also possible to get one to mount/unmount floppy disks ?

Thanks a lot for your post,
Sirsurthur

Offline

#5 2010-12-01 18:34:17

Ledti
Member
Registered: 2010-07-31
Posts: 122
Website

Re: simple bash functions/aliases for udisks2

Sirsurthur wrote:

Great functions ! Would it be also possible to get one to mount/unmount floppy disks ?

Thanks a lot for your post,
Sirsurthur

Forgot about those too smile. I added fdm and fdu. They should work, but I can't test them.

Last edited by Ledti (2010-12-01 18:52:51)

Offline

#6 2010-12-01 18:48:34

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: simple bash functions/aliases for udisks2

drcouzelis wrote:

It's too bad that adding optical disc support with udisks is such a pain in the bash. Please let me know if you'd like help with it, or, just check out the source code for one of the udisks wrappers.

Yes, I realize I'm quoting myself. tongue

I was wrong. What I should have said was, AUTOMATICALLY mounting optical discs is a pain.

I apologize for any confusion. Good work on the script. smile

Offline

#7 2010-12-01 19:02:15

Ledti
Member
Registered: 2010-07-31
Posts: 122
Website

Re: simple bash functions/aliases for udisks2

drcouzelis wrote:
drcouzelis wrote:

It's too bad that adding optical disc support with udisks is such a pain in the bash. Please let me know if you'd like help with it, or, just check out the source code for one of the udisks wrappers.

Yes, I realize I'm quoting myself. tongue

I was wrong. What I should have said was, AUTOMATICALLY mounting optical discs is a pain.

I apologize for any confusion. Good work on the script. smile

Haha, yeah. smile - After looking into it, I assumed you must have meant something else. I can only imagine how awful it must be to detect when optical media is inserted since the device itself is always listed.

Offline

#8 2010-12-01 19:25:28

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

Re: simple bash functions/aliases for udisks2

I tested the function for the floppy disks and it works like a charm ! Thanks a lot !

Sirsurthur

Offline

#9 2010-12-06 15:42:35

masterkorp
Member
From: Ponte de Lima, Portugal
Registered: 2010-09-16
Posts: 47
Website

Re: simple bash functions/aliases for udisks2

Will you add support for SD cards ?
Its just change the notation (mmcblk[0-9]p[0-9]:)


Regards,
Alfredo Palhares

Offline

#10 2010-12-06 18:49:36

Ledti
Member
Registered: 2010-07-31
Posts: 122
Website

Re: simple bash functions/aliases for udisks2

masterkorp wrote:

Will you add support for SD cards ?
Its just change the notation (mmcblk[0-9]p[0-9]:)

Sure! http://sprunge.us/KAfB

Can you test these commands?

mcm
mcm mmcblk0
mcm mmcblk0p0
mcm mmcblk0 p0
mc0m
mc0m p0

The opposite is mcu and mc*u.

The mmcblk*p* part is quite long, but I suspect most people will use the aliases anyways.

Last edited by Ledti (2010-12-07 06:02:51)

Offline

#11 2011-11-20 08:34:00

mentat
Member
From: France
Registered: 2009-01-13
Posts: 138
Website

Re: simple bash functions/aliases for udisks2

Ledti, thanks for your file, love it !
I think it's quite useful so maybe you can create a (git?) repository with AUR ?

Offline

#12 2011-11-22 11:46:15

Ledti
Member
Registered: 2010-07-31
Posts: 122
Website

Re: simple bash functions/aliases for udisks2

mentat wrote:

Ledti, thanks for your file, love it !
I think it's quite useful so maybe you can create a (git?) repository with AUR ?

Thanks. smile

I created a package which can be found here.

Offline

#13 2011-11-22 17:15:46

mentat
Member
From: France
Registered: 2009-01-13
Posts: 138
Website

Re: simple bash functions/aliases for udisks2

Ledti wrote:

Thanks. smile

I created a package which can be found here.

Cool it's an "official" packet in my system now.
Thanks

Offline

#14 2012-08-05 16:09:36

Ledti
Member
Registered: 2010-07-31
Posts: 122
Website

Re: simple bash functions/aliases for udisks2

Update: depends on udisks2 since udisks is now deprecated.

Offline

#15 2012-08-18 10:36:39

mentat
Member
From: France
Registered: 2009-01-13
Posts: 138
Website

Re: simple bash functions/aliases for udisks2

Thanks for the update Ledti,
but have error during update.

The md5sums check fail (with yaourt)
When I download the github file, check the md5sums, your PKGBUILD is right. Can't understand.

Offline

#16 2012-08-18 23:38:40

Ledti
Member
Registered: 2010-07-31
Posts: 122
Website

Re: simple bash functions/aliases for udisks2

mentat wrote:

Thanks for the update Ledti,
but have error during update.

The md5sums check fail (with yaourt)
When I download the github file, check the md5sums, your PKGBUILD is right. Can't understand.

I'll be away from my Linux box for a while so I can't test it with yaourt. The only thing I can think of that would be causing it is that yaourt is caching the previous version of the udisks_functions file somewhere and checking the md5sum against that version. It's also possible that yaourt is modifying the file somehow, but I don't know for sure. The md5sum is definitely correct though.

You can try downloading the tarball here, and running:

makepkg -si

to make sure that it's not my package causing the problem. If it runs cleanly then it is probably an issue with yaourt.

Offline

#17 2012-08-19 08:36:22

mentat
Member
From: France
Registered: 2009-01-13
Posts: 138
Website

Re: simple bash functions/aliases for udisks2

Ledti wrote:

You can try downloading the tarball here, and running:

makepkg -si

to make sure that it's not my package causing the problem. If it runs cleanly then it is probably an issue with yaourt.

It's work with a message (I translate in english):

back to older version udisks_functions (1d2ac3-1 => e63f34-1) 

I clean the cache in

ls /var/cache/pacman/pkg/udisks*
udisks-1.0.4-4-i686.pkg.tar.xz    udisks2-1.94.0-2-i686.pkg.tar.xz

try to install via yaourt, same error.
It's seem it didn't ever try download from github.

Offline

#18 2012-08-19 09:02:46

Ledti
Member
Registered: 2010-07-31
Posts: 122
Website

Re: simple bash functions/aliases for udisks2

mentat wrote:
Ledti wrote:

You can try downloading the tarball here, and running:

makepkg -si

to make sure that it's not my package causing the problem. If it runs cleanly then it is probably an issue with yaourt.

It's work with a message (I translate in english):

back to older version udisks_functions (1d2ac3-1 => e63f34-1) 

I clean the cache in

ls /var/cache/pacman/pkg/udisks*
udisks-1.0.4-4-i686.pkg.tar.xz    udisks2-1.94.0-2-i686.pkg.tar.xz

try to install via yaourt, same error.
It's seem it didn't ever try download from github.

Sorry, it was my fault. I was using a dumb pkgver variable in the PKGBUILD file without thinking about how it's actually parsed. I've uploaded a new version to the AUR that should fix this issue in case there are any updates in the future. If it doesn't upgrade with yaourt, just uninstall the current version on your computer and then reinstall it again, that should work. Again, sorry for the inconvenience.

Offline

#19 2012-08-19 10:17:26

mentat
Member
From: France
Registered: 2009-01-13
Posts: 138
Website

Re: simple bash functions/aliases for udisks2

Thanks for the fix and support.
Hope you will continue to follow it.
^_^

Offline

Board footer

Powered by FluxBB