Alias to attempt mounting multiple times doesn't work correctly

0

I have the following in my .bashrc

alias ext='sudo mount /dev/sd'{b..d}'1 /ext/hdd || sudo'

I intended the alias to mount my external hard drive without having to worry about the semi-random device it's given. Instead, it only seems to attempt the last option (/dev/sdd1).
I ask for an explanation of why this happens and a possible alternative to this method.

AstroSnail

Posted 2016-05-09T19:06:23.107

Reputation: 53

Answers

0

I recommend to use uuid instead of device paths. If you look into folder like

/dev/disk/by-lable
/dev/disk/by-id
/dev/disk/by-uuid

you should find your device always with the same name. These files are symlinks to the actual device file.

You would write something like that:

sudo mount /dev/disk/by-uuid/123-456 /mnt/ 

OSC

Posted 2016-05-09T19:06:23.107

Reputation: 81