Can folders be "linked" via UUID?

Technical issues/questions of an intermediate or advanced nature.
User avatar
Rava
Contributor
Contributor
Posts: 5410
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Can folders be "linked" via UUID?

Post#1 by Rava » 22 Aug 2022, 10:48

man ln

Code: Select all

ln - make links between files

-d, -F, --directory
allow the superuser to attempt to hard link directories (note: will 
probably fail due to system restrictions, even for the superuser)
I have on my largest external hard drive 4 partitions:

1st VFAT (so that it can be used e.g. to record TV stuff, cause what all the receivers agree on is that it only can be the 1st partition of an external harddrive, and all support VFAT, while only a few also support NTFS.

2nd, 3rd NTFS

4th ext4

I have video/ folders in all these 4 root directories. Since some partitions get too full, while the 4th partition has still the most space, I wonder, how can I link to files or folders regardless of how the external drive is mounted? So that 1 have one video/ main folder and all sub-folders are to be found there, be they on any of the other mentioned partitions or in the actual video/ folder that I currently have opened?

Would what I want work via UUID instead of hardlinks or symlinks? Since the UUID should always represent only that one partition, regardless if its mounted as sdb2 or sdc2.

Since Porteus can use UUID and a path so should be the whole system (e.g. terminal, mc, Thunar…) , or not?
Cheers!
Yours Rava

beny
Full of knowledge
Full of knowledge
Posts: 2098
Joined: 02 Jan 2011, 11:33
Location: italy

Can folders be "linked" via UUID?

Post#2 by beny » 22 Aug 2022, 11:33

hi try blkid to your device and see if you have four uuid i think you can mount what you want but porteus have the fstab rebuild at every boot,maybe i am wrong on this...

User avatar
Rava
Contributor
Contributor
Posts: 5410
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Can folders be "linked" via UUID?

Post#3 by Rava » 23 Aug 2022, 03:19

beny wrote:
22 Aug 2022, 11:33
hi try blkid to your device and see if you have four uuid i think you can mount what you want but porteus have the fstab rebuild at every boot,maybe i am wrong on this...
The mounting is not the issue, I mount it as /mnt/sda1, /mnt/sda2,[…], /mnt/sdb1, /mnt/sdb2,[…] and so on, and I want to keep it that way.

But the issue is: video/ folders on e.g. extHD8 can be like this:

Code: Select all

/mnt/sdb1/video/
/mnt/sdb2/video/
/mnt/sdb3/video/
/mnt/sdb4/video/
when extHD8 is mounted as sdb
or like this

Code: Select all

/mnt/sdc1/video/
/mnt/sdc2/video/
/mnt/sdc3/video/
/mnt/sdc4/video/
when extHD8 is mounted as sdc
Or when I would have Porteus bootable on extHD8 and the PC has no internal harddrive, then it could even be mounted as

Code: Select all

/mnt/sda1/video/
/mnt/sda2/video/
/mnt/sda3/video/
/mnt/sda4/video/
Now, how can I access extHD8_4/video/ - be it mounted as /mnt/sda4/video/ or /mnt/sdb4/video/ or /mnt/sda4/video/ or […]

AFA neiher soft- nor hardlinks help - but can it be done via UUID?
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8369
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Can folders be "linked" via UUID?

Post#4 by Ed_P » 23 Aug 2022, 06:28

I understand the varying mount ids. A USB drive on my old Dell notebook mounted as sdb1, the same USB drive on my new Dell mounts as sda1. So many scripts had to be changed to use a variable to reference the drive's folders and files and a script to set the variable runs when the USB drive is booted.

Code: Select all

#!/bin/bash

# https://forum.porteus.org/viewtopic.php?p=86943#p86943 - ncmprhnsbl 
# but, yeah, to set an env variable, add a file to /etc/profile.d:
# my_env_var.sh

#set -x;
# http://forum.porteus.org/viewtopic.php?f=53&t=3801&start=30#p28472 - Rava
BOOT=`grep -A1 "Booting" /var/log/porteus-livedbg|tail -n1|sed 's^//^/^g'`
SYSTM=
DRV=${BOOT:5:4}
if [ "${BOOT:0:12}" == "/mnt/isoloop" ]; then
   ISOBOOT=`grep -A1 "//porteus" /var/log/porteus-livedbg|tail -n1|sed 's^//^/^g'`
   SYSTM="${ISOBOOT:14:10}/"
   DRV=${ISOBOOT:9:4}
fi
if [ "$DRV" == "nvme" ]; then
   SYSTM="${ISOBOOT:19:10}/"
   DRV=${ISOBOOT:9:9}
fi 
export DRV
Can the extHD8 drive's reference be a variable? Like /mnt/$DRV/video where $DRV would be set by a script you run when the drive is mounted?

According to "mount --help" the source can use "UUID=<uuid> specifies device by filesystem UUID"
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5410
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Can folders be "linked" via UUID?

Post#5 by Rava » 23 Aug 2022, 07:20

Ed_P wrote:
23 Aug 2022, 06:28
Can the extHD8 drive's reference be a variable?
No, it is the name I gave it and the way my lsfind script addresses it.
My lsfind suite relies on empty files in the partition root (empty files take no space since they occupy only one entry in the directory of the folder) - e.g. intHDD1_1 for the 1st drive of the "D" aka 4th internal harddrive, or extHD8_3 for the 3rd partition of my 8th external harddrive, or extUSB_FlashDisc05_2 for the 2nd partition of my 5th USB flashdrive, you get the drift.

I coded indeed some auto-created symlinks for one folder of extHD8_3 - to be executed via rc.local - and I also made it as external script for /usr/local/bin when the extHD8 was not present at boot time or got removed and plugged in again resulting in a different mount path e.g. from sdb to sdc.

I just hoped there was no need to script it every time I want folder be found univerally.
Cheers!
Yours Rava

isr
White ninja
White ninja
Posts: 7
Joined: 04 Aug 2013, 15:19
Distribution: porteus-2.0 & gentoo
Location: California, USA

Can folders be "linked" via UUID?

Post#6 by isr » 26 Aug 2022, 00:26

Rava, the cleanest solution for you would be mergerfs

https://github.com/trapexit/mergerfs

Its a FUSE union filesystem, so you can think of it as a neat counterpart to aufs. What it does is allow you to present a single unified folder hierarchy, which encapsulates multiple actual mountpoints underneath it.

In short, its exactly what you're looking for. The docs are VERY comprehensive (your particular use case is quite simple, so don't let all the knobs and levers scare you!), and mergerfs itself is battle-hardened production-quality stuff.

User avatar
Rava
Contributor
Contributor
Posts: 5410
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Can folders be "linked" via UUID?

Post#7 by Rava » 26 Aug 2022, 03:38

^
thanks isr, I look into it. :)

Added in 14 minutes 27 seconds:
And looking into it I found an example how they handle questions - via RTFM - and the one asking ends it with
Thank you for helping me understand some mechanics.
:D
https://github.com/trapexit/mergerfs/issues/553
Cheers!
Yours Rava

isr
White ninja
White ninja
Posts: 7
Joined: 04 Aug 2013, 15:19
Distribution: porteus-2.0 & gentoo
Location: California, USA

Can folders be "linked" via UUID?

Post#8 by isr » 26 Aug 2022, 21:42

trapexit, the author of mergerfs, is very active and responsive on various subreddits (eg: r/datahoarders)

Oftentimes, a specific web search will lead you to threads there, where the dev will have given a definitive answer.

Good luck :thumbsup:

User avatar
Rava
Contributor
Contributor
Posts: 5410
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Can folders be "linked" via UUID?

Post#9 by Rava » 26 Aug 2022, 23:13

isr wrote:
26 Aug 2022, 21:42
Good luck :thumbsup:
thanks,

though currently this is the main issue - off topic
Cheers!
Yours Rava

Post Reply