LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 11-26-2018, 05:13 PM   #1
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Kubuntu, Mint
Posts: 411

Rep: Reputation: 31
mount directory using uuid in fstab


Is it possible to mount a directory using a uuid in fstab something like:
Code:
UUID=29537a49-632f-4774-8bbc-b68cd5181d74/opt /home/john/opt  none  bind
 
Old 11-26-2018, 06:52 PM   #2
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
UUID, yes, but I have never used it with a directory appended. Normally this would be used so you don't have to reference the drive device designation directly, in case you move it. For example:

Code:
UUID=41c22818-fbad-4da6-8196-c816df0b7aa8  /disk2p2      ext3    defaults,errors=remount-ro 0       1
 
Old 11-26-2018, 07:06 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,922

Rep: Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375
No, you need 2 fstab lines. One to mount the file system to /opt and the second as a bind mount to remount /opt to /home/john/opt. As an example using your UUID but may not be exactly as your original fstab

Code:
UUID=29537a49-632f-4774-8bbc-b68cd5181d74 /opt ext4 defaults 0 0

/opt /home/john/opt  none  bind 0 0
Note that the filesystem mount options maintained by kernel will remain the same as those on the original mount point.
 
Old 11-26-2018, 07:06 PM   #4
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Kubuntu, Mint
Posts: 411

Original Poster
Rep: Reputation: 31
Thanks, but that mounts the (whole) partition on /disk2p2. I'm looking for a way to mount one particular directory on that partition. Using uuid is independent of drive cabling.
 
Old 11-26-2018, 07:07 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,445

Rep: Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203
Why didn't you just try it ?. You might learn something.
 
Old 11-26-2018, 07:14 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,922

Rep: Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375Reputation: 6375
You can not mount a directory within a filesystem without mounting the filesystem itself.
 
1 members found this post helpful.
Old 11-26-2018, 08:07 PM   #7
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Kubuntu, Mint
Posts: 411

Original Poster
Rep: Reputation: 31
Thank you michaelk.
My reply was intended to sevendogsbsd . I had not seen your message at that stage.

I have now tried your suggestion (in fstab). It mounted the whole drive in /opt.

My original question may have been miss-leading in that I was presuming it may be a one stage process. /home/john/opt was a test location; if that worked I intended the destination be /opt

I have several OS and decided to have one /opt directory common to all (with frequently updates apps like Firefox, etc)

If I cannot mount only the directory, ie need to mount the drive first, then I may as well use a symlink to "mount" the required 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] UUID booting: tune2fs cannot set uuid of flash thumb? creates virtual box issue X-LFS-2010 Linux - Newbie 6 06-20-2018 09:28 PM
[SOLVED] /dev/disk/by-uuid/<uuid here> does not exist and initramfs shell Mitt Green Linux - Kernel 4 08-03-2015 11:56 AM
[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
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

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 11:14 AM.

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