LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy
User Name
Password
Puppy This forum is for the discussion of Puppy Linux.

Notices


Reply
  Search this Thread
Old 06-07-2015, 06:12 PM   #1
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Rep: Reputation: 169Reputation: 169
UUID for pendrive ?


Is there a way to get a pendrive to use the same drive name each time it
is inserted ?

When I insert one into the same port, I get sdd1 or sdc1.
 
Old 06-08-2015, 03:15 AM   #2
roger_heslop
Member
 
Registered: Oct 2009
Location: Leander, TX
Distribution: Fedora 20
Posts: 97

Rep: Reputation: 35
Yes and no.

No in the sense that you can't control the letter that is assigned to the block device (Ex: /dev/sdb vs /dev/sdc)

There are however other options. You can symlink sdd or sdc (whichever the pendrive takes on) to a known value everytime it's inserted by using udev rules on your device. You could insert your pendrive and know that it is symlinked, for example, to /dev/mapper/my_drive1 for mounting. You can find an article on by searching for 'udev symlinks', I found one here.

Other options include labeling (by using e2label for example, but that's specifically for ext based filesystems, and may not be what your wanting. While it will control how your pen drive appears within the desktop environment, it won't change the block device name for mounting.

Last edited by roger_heslop; 06-08-2015 at 03:36 AM.
 
Old 06-08-2015, 03:16 AM   #3
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,478

Rep: Reputation: Disabled
You can give it a 'label' or use the UUID in your /etc/fstab file to give it a specific mount point.
 
Old 06-08-2015, 03:21 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,792

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
you can add label to the partitions, filesystem and that will be used for mount points (so for example if the label is mydrive, the mount point will be /media/mydrive). But probably it won't work on all distros.
 
Old 06-08-2015, 08:02 AM   #5
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Quote:
Originally Posted by fatmac View Post
You can give it a 'label' or use the UUID in your /etc/fstab file to give it a specific mount point.
I tried it but it did not change anything.
 
Old 06-08-2015, 08:25 AM   #6
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
What about modifying this so that if sdb1 is not present, then run sdc1 ?

Quote:
#!/bin/bash
#
# Linux Puppy 5.6.0
# SiegeWorks 2014 A.P.K.
#
thunar /mnt/sdb1/Linux_Files
 
Old 06-09-2015, 02:24 AM   #7
roger_heslop
Member
 
Registered: Oct 2009
Location: Leander, TX
Distribution: Fedora 20
Posts: 97

Rep: Reputation: 35
It would be safer to run a mount command specifying the exact device. You could use the -U option of mount to mount by UUID - or the -L option to mount by label.

The label is a filesystem feature, so use e2label if it's ext3/4 or mlabel if it's fat32, then:

Code:
mount -L [label] /mount/point
If you prefer UUID, you can get it via:
Code:
blkid /dev/sdX
(Where X is b or c, depending on how your drive is recognized when you run the command.)
 
Old 06-09-2015, 02:33 AM   #8
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
My script just uses Thunar to open a directory.

If it can not, I want it to open another directory which in my case is sdc1.

How would mount help a script make decisions on what to do based on what is mounted ?

I need something that can perform a task based on whether an operation failed or not.

Hope that made sense. :-)
 
Old 06-09-2015, 05:10 AM   #9
roger_heslop
Member
 
Registered: Oct 2009
Location: Leander, TX
Distribution: Fedora 20
Posts: 97

Rep: Reputation: 35
I might not be following your intent but here's my thought:

Code:
mount -L [label] /mnt  
thunar /mnt > /dev/null 2>&1 || echo "Operation failed."
The mount command above just mounts whatever device by label.

The second command attempts to open the directory /mnt (where the root of your drive should be) and thows away any output or error (> /dev/null 2>&1)

I think what you're looking for is "||".
If the first command fails, then the command after "||" is run. Like that?

Edit: Related to the desired commands above, that might also be:
thunar /mnt/sdb1/Linux_Files || thunar /mnt/sdc1/Linux_Files

Last edited by roger_heslop; 06-09-2015 at 05:12 AM.
 
Old 06-09-2015, 05:57 AM   #10
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Using

Quote:
mount -L [Backup_Toshiba_Partition] /mnt/sdb1/Linux_Files
thunar /mnt > /dev/null 2>&1 || echo "Operation failed."
Quote:
# blkid
/dev/sda1: LABEL="Windows_XP" UUID="5E1006FC1006DAC3" TYPE="ntfs"
/dev/sda2: LABEL="SDA2" UUID="a5e8a20b-472b-4156-99fd-7f5f2c6e6104" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda5: LABEL="Puppy_5.9.3_SDA5" UUID="ae03ec69-b09e-48c2-815d-58a494be70cc" TYPE="ext3"
/dev/sdb1: LABEL="Backup_Toshiba_Partition" UUID="9C24D67524D651BE" TYPE="ntfs"
/dev/sdb5: LABEL="Toshiba_Partition_Empty" UUID="01D050F76A0DD520" TYPE="ntfs"

# test.sh
mount: no such partition found
It opens thunar at /mnt.

I have all volumes mounted at bootup.

Do they have to be unmounted for this to work ?

Last edited by Fixit7; 06-09-2015 at 05:58 AM.
 
Old 06-09-2015, 06:02 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,792

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
what is that test.sh? How should we know what caused that error message?
You used the mount command improperly:
remove [ and ], just enter the label itself.
do not add the device to the command, but the mount point (an empty dir)
mount -L label /mount/dir
 
Old 06-09-2015, 07:09 AM   #12
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
I made the corrections.
Quote:
Mount is denied because the NTFS volume is already exclusively opened.
The volume may be already mounted, or another software may use it which
could be identified for example by the help of the 'fuser' command.
 
Old 06-09-2015, 07:15 AM   #13
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
If I manually unmount sdb1

mount -L Backup_Toshiba_Partition /mnt
thunar /mnt > /dev/null 2>&1 || echo "Operation failed."

I get this.

# test.sh
df-FULL: /mnt/sda1: No such file or directory
df-FULL: /mnt/sda2: No such file or directory
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to mount by-uuid if the device won't show in /dev/disk/by-uuid untill after blkid /dev/sd* ? masmddr Linux - General 4 01-10-2011 07:38 PM
Cameras, pendrive: how to have severail UUID into the /etc/fstab ? Xeratul Linux - General 3 12-29-2010 06:34 AM
Change UUID - Edit UUID using the dd command GMHilltop Linux - Newbie 10 10-28-2010 07:39 PM
Volume has problems including no uuid in /dev/disk/by-uuid abejarano Linux - Hardware 3 12-31-2008 08:41 PM
How to install and configure grub on pendrive while os' are on the same pendrive? CeremCem DamnSmallLinux 0 11-07-2006 11:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy

All times are GMT -5. The time now is 05:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration