Mount a drive by UUID?

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

Mount a drive by UUID?

#1 Post by greengeek »

On my PC I have my music files on a usb stick that usually shows as sdc2 but 10% of the time shows up as sdd2 (this seems to be a legacy of the fact that this usb stick is hanging off a 7-port usb adapter, which is hanging off a pcmcia usb2 adapter card so detection time seems to vary a bit). I am wanting to automate the playing of the music files after boot (by setting it up to be automounted - there are various methods for this and I haven't decided which is the best option yet...) but cannot do so if the drive designation is varying.


The answer seems to be to use the UUID of the usb stick to identify it, and mount it using that UUID. I can find the UUID but I don't know WHERE/HOW to mount it. I can't afford to mount it as sdc2 because some other drive will probably be occupying that designation. The command I have found via google suggests to add the following to the fstab:

Code: Select all

UUID=9263eae3-bdba-4707-89bb-a8e0fd4a1c29   /mnt/backups   ext3  defaults   0 0
But does puppy even use the fstab? I've read that puppy does not mount in the same manner that other *nixes do... Would I need to make a new directory like /mnt/music and mount the device there?

The page I'm working from is:
http://centoscert.com/content/how-mount-drive-uuid

I could fiddle around with this and give it a try (normally I'm happy to tinker) but I'm not keen to fiddle with my filesystem structure without advice from someone more experienced. :-)

I'm thinking I should not bother tinkering with the fstab, and possibly do the following:
1) create the /mnt/music directory
2) write a script to mount the uuid to that directory:

Code: Select all

#!/bin/bash
UUID=9263eae3-bdba-4707-89bb-a8e0fd4a1c29   /mnt/music   ext3  defaults   0 0
(ok - i'm just getting this WRONG i know it)

I don't want to use startmount or other "mount-all" solutions because they still suffer from the varying designation issue - it is just how/where to mount (and what to do with the fstab) that I can't figure. And if I do mount the drive in some manner, will it appear on the desktop? And how will puppy handle it if I remove / reinstall the drive - will it merely tack it onto the string of drives as sdx? (maybe this suggests that I SHOULD put it in the fstab so puppy knows what i want done with it...?)

Comment re puppy handling of fstab here:
http://mail.murga-projects.com/puppy/vi ... 6fdde2e829

These other sites seemed useful aswell:
http://www.cyberciti.biz/faq/linux-find ... ate-fstab/
http://administratosphere.wordpress.com ... x-by-uuid/
.
Last edited by greengeek on Mon 28 Oct 2013, 18:08, edited 1 time in total.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#2 Post by mikeb »

mount -U {uuid} /mnt/mountpoint .... tried that?

yes fstab no worky... perhaps use the uuid as the mount point eg /mnt/{uuid}

mike

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#3 Post by greengeek »

Thanks Mike. I just gave that (and a couple of variations) a try as follows:

mount -U {023E-C239} /mnt/music
mount -U {"023E-C239"} /mnt/music
mount -U {UUID=023E-C239} /mnt/music
mount -U {UUID="023E-C239"} /mnt/music

but in each case it came back with:

no such partition found

My blkid is as follows:

Code: Select all

blkid
/dev/loop1: UUID="90dfda6a-fcb6-4829-8976-494387f90b82" TYPE="ext2"
/dev/sdb2: LABEL="Data ext2" UUID="0a2630d3-1bb9-4c53-81c1-4cba4a6c9342" TYPE="ext2"
/dev/sdb3: LABEL="Data fat32" UUID="45B6-2F7F" TYPE="vfat"
/dev/sda1: UUID="f68ca8aa-2d2b-4a84-ad72-7f8aae7ede62" TYPE="ext2"
/dev/sdd2: UUID="023E-C239" TYPE="vfat"
/dev/sdd3: UUID="165ec7e2-9a9d-4e83-8104-b57d511a2e9d" TYPE="swap"
/dev/sdd1: LABEL="Bootin" UUID="a88c1f47-eafe-4fd5-aad2-806ea60f5bbb" TYPE="ext2"
/dev/sdb1: LABEL="Boot" UUID="25e8c365-46d3-4899-9752-8428eb48e071" TYPE="ext2"
/dev/loop0: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/sda2: UUID="665d6c58-a16e-4bd9-aa99-bfd060629e4a" TYPE="ext2"
/dev/sda3: UUID="fc84d9dd-3fc1-4f85-aaf4-388cf723e2fa" TYPE="swap"
# 
The target usb stick is sdd2 at this moment.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#4 Post by mikeb »

mount -U 023E-C239 /mnt/music

the braces were just so show to substitute the actual uuid
Sorry if that confused my annoyingly short answer :D
I tried it here with a flash stick and it behaved so hopefully will solve your problem

mike

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#5 Post by greengeek »

Champion. Working well now. Thanks!

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#6 Post by sunburnt »

I made another simple solution that uses a file in the / of the partition to ID it.

It`s nice because you can control where the link is made and the name of the link.

http://www.murga-linux.com/puppy/viewto ... 398#733398
.

User avatar
mikeslr
Posts: 3890
Joined: Mon 16 Jun 2008, 21:20
Location: 500 seconds from Sol

Obtaining the UUID

#7 Post by mikeslr »

Hi All,

Thought this was a good place to post something fundamental about UUID's for those of us who struggle to keep up: how to get them.
Open a terminal and type "blkid" without the quotes. Thanks keef.
Of course, if you aren't able to memorize gibberish of some twenty-odd alpha-numerics, or find looking at one window while typing in another stressful, then do this instead:

Open a terminal and type

bklid > /root/my-documents/UUID.txt

which will generate a file named UUID.txt in /root/my-documents/ containing the UUID's of all the then mounted drives/partitions. Open in any text editor. Pick the right one. Copy and paste.

mikesLr
Last edited by mikeslr on Mon 09 Dec 2013, 19:35, edited 1 time in total.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#8 Post by musher0 »

Hi, greengeek.

I don't know much about UUID, but here's a trick to populate fstab in Puppy.

Puppy has a minimal fstab, usually comprised of:

Code: Select all

# Default fstab in Puppy
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
none /dev/pts devpts gid=2,mode=620 0 0
/dev/fd0 /mnt/floppy auto noauto,rw 1 1
Now a fully populated fstab is handy when you use the < mount all partitions command >:

Code: Select all

mount -a
This command consults the fstab and mounts all partitions specified there -- instead
of you mounting each drive manually, through
the usual commands. E.g.

Code: Select all

mount -t ext3 /dev/sda1 /mnt/sda1
or

Code: Select all

mount -t iso9660 /dev/sr0 /mnt/sr0
The structure of the fstab file is as follows:
# dev mnt type parameters fsck
# (fstab fields [structure])
Now to populate your fstab:

1 ) unpack the attached, make it executable and run it;

2 ) open /etc/fstab in your editor; prepare your next move by placing your cursor on
the line below the floppy disk line;

3 ) open a terminal and run

Code: Select all

echo;cat /proc/mounts | grep "v/sd" | grep -v swap;echo
For some reason, adding ">> /etc/fstab" to the above line doesn't work.
So we have the following extra steps:

4 ) inside this terminal, with your cursor, highlight the part between the two empty
lines, and do a middle click or Shift-Delete to copy;

5 ) Alt-Tab back to your editor. Do another middle-click or Shift-Insert to paste;

6 ) You should now have your list of hard drives in fstab;

7 ) check the drives with ext* type: they should have 1 1 at the end of each line,
not 0 0. "1 1" allows them fo be checked by fsck (trick given by the e2fsprogs
author in his INSTALL file);

8 ) if you have a CD/DVD drive, after the list of hard drive partitions,
add the line (if it's not already there):

Code: Select all

/dev/sr0 /mnt/sr0 iso9660 auto,ro 0 0
Notice the two zeros at the end. CD can't be defragged, so they don't need to have
the fsck flag up.

9 )Hit return at the bottom of the edited fstab file to make sure it has an empty line
after all the listings;

10 ) Save your newly edited fstab. (Obviously!) :)

Next time you do a < mount -a > command, all your drives will be mounted.

As I said, I know little about UUID, but here's a little more info:
http://linux.byexamples.com/archives/32 ... with-uuid/
You can apparently replace the /dev/<partition> part in fstab with the UUID number.

Also here's an URL to info.com if you want to a do a more thorough search:
http://www.info.com/searchw?qkw=fstab+w ... &qhqn=&KW=

Sorry if I've been a little too wordy, but I hope the above helps you somehow. BFN.

musher0
Attachments
mount-all-drives2.sh.zip
Derived from: der-schutzhund and SFR, http://murga-linux.com/puppy/viewtopic.php?t=84759, 2013-03-04, 10 h 47; with a few edits by me.
(790 Bytes) Downloaded 208 times
Last edited by musher0 on Tue 10 Dec 2013, 05:45, edited 1 time in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#9 Post by greengeek »

Thanks musher0. I notice BK has been incorporating UUID into his gpt boot trials lately. I'm watching with interest.

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#10 Post by BarryK »

greengeek wrote:Thanks musher0. I notice BK has been incorporating UUID into his gpt boot trials lately. I'm watching with interest.
I do sometimes still visit this Forum!

I am using PARTUUID, not UUID, as the former is what has to be used as a kernel boot parameter.

The PARTUUID is for the partition itself, whereas the UUID (as given by blkid) is for the filesystem on the partition.

You need to use the gdisk utility to find out the PARTUUID.
[url]https://bkhome.org/news/[/url]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#11 Post by musher0 »

@greengeek:

Hi!

Would you find this of use?
http://murga-linux.com/puppy/viewtopic. ... ost#743723

BFN.

musher0
Last edited by musher0 on Sat 14 Dec 2013, 19:48, edited 1 time in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#12 Post by greengeek »

Thanks musher0. There is a lot for me to learn about how to get these things sorted out so that my puppies know what is where...
I've added your link to a couple of other similar topics so I can try to tie the information together.

Post Reply