Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

how to create permanent access to folders on other disk?

Linux Kernel, Network, and Services configuration.
Message
Author
canti
Posts: 74
Joined: 2011-01-31 12:57
Location: The Netherlands

how to create permanent access to folders on other disk?

#1 Post by canti »

I have two separate disks in my laptop: sda and sdb, see below:

Code: Select all

lsblk -f
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
sda                                                      
├─sda1 vfat         xxx-xxx                           /boot/efi
├─sda2 ext4         xxxxxxxxxxxxxxxxxxxx /
└─sda3 swap         xxxxxxxxxxxxxxxxxxxx [SWAP]
sdb                                                      
└─sdb1 ext4   data  xxxxxxxxxxxxxxxxxxxxxx /media/familie/data
sr0                                                      
sda is a SSD disk of 256 MB, and sdb a HDD of 1 TB. sda contains Debian buster which was clean installed recently while the latter contains data such as documents, pictures, videos and like that. Now, from sda I would like to get access to the standard folders on sdb (Pictures, Documents, Music, and so on). My idea is that the standard folders on sda are permanently linked to the corresponding folders on sdb. How do I that?

The extra complication is that sdb is not standard accessible from sda. Hence an automount is probably needed. I saw several possible solutions like fstab, autofs, symlinks, bindfs, What is the best way in my case? I have Debian buster with Gnome, all standard such as Nautlius and systemd.

Regards,
canti
Last edited by canti on 2018-10-28 17:10, edited 1 time in total.
HP Envy 17 n120nd containing Debian Bullseye (Gnome 3)

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: how to create permanent access to folders on other disk?

#2 Post by bw123 »

There are a lot of ways to do it. I do something similar, it's not all that complicated unless you want it to be. Nobody can really say what is the best way for you.

Look up 'symbolic link' there are several ways to create one. Most filemanagers can do it, or you can use ln command from terminal. You probably can't create one while the name exists as a subdirectory. Don't remove or delete a folder with data in it by accident!

Look up how to automount a partition in gnome might help you, or how to mount with fstab. autofs is really cool too, or the x-systemd.automount option in fstab, it just depends which way you want to go. For an always mounted plain old storage partition I would just go with fstab, follow the example that mounts your / partition and back the file up first. (copy /etc/fstab to another location)

Go slow, and just try getting the part mounted when you boot. Then try linking one folder on the data partition to some place in /home/user as a test.

The other trick will be setting the permissions, you didn't say who (what user id) wrote the files on the drive, who owns them? What user do you want to allow read/write or full access?

You'll get it, honest. If 'linux zoo' project is still up, it is a good place to start. I'm surprised you haven't tried it since you've been a member here longer than I have.
resigned by AI ChatGPT

Proinsias
Posts: 4
Joined: 2018-10-18 09:32

Re: how to create permanent access to folders on other disk?

#3 Post by Proinsias »

I have a storage partition mount at /mnt/storage with /etc/fstab

Code: Select all

UUID=xxxxxxxxxxx /mnt/storage ext4 defaults 0 0 
I just changed ownership of the storage to make for easy access, granted I am the only real user on the system and not really sure this is best practice:

Code: Select all

chown -R username /mnt/storage

milomak
Posts: 2158
Joined: 2009-06-09 22:20
Been thanked: 1 time

Re: how to create permanent access to folders on other disk?

#4 Post by milomak »

what am i missing here?

/dev/sdb is already mounted and is available no?

so why does /dev/sda need to be involved?
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: how to create permanent access to folders on other disk?

#5 Post by p.H »

Proinsias wrote:I have a storage partition mount at /mnt/storage with /etc/fstab]
/mnt is not intended to be used for permanent mounts, nor to contain subdirectories. See the FHS.

Proinsias
Posts: 4
Joined: 2018-10-18 09:32

Re: how to create permanent access to folders on other disk?

#6 Post by Proinsias »

p.H wrote:
Proinsias wrote:I have a storage partition mount at /mnt/storage with /etc/fstab]
/mnt is not intended to be used for permanent mounts, nor to contain subdirectories. See the FHS.
I looked in to this a little 4 or 5yrs ago when initially looking to have an internal hdd mounted as a storage and found little in the way of recommendation in the FHS for this scenario. Asking some questions on IRC channels and looking at similar questions on stackexchange led me to opt for /mnt.
http://tldp.org/LDP/Linux-Filesystem-Hi ... l/mnt.html
This is a generic mount point under which you mount your filesystems or devices. Mounting is the process by which you make a filesystem available to the system. After mounting your files will be accessible under the mount-point. This directory usually contains mount points or sub-directories where you mount your floppy and your CD. You can also create additional mount-points here if you wish. Standard mount points would include /mnt/cdrom and /mnt/floppy. There is no limitation to creating a mount-point anywhere on your system but by convention and for sheer practicality do not litter your file system with mount-points. It should be noted that some distributions like Debian allocate /floppy and /cdrom as mount points while Redhat and Mandrake puts them in /mnt/floppy and /mnt/cdrom respectively.
This seems to tie in with my usage over the past few years. A space which contains mount points and subdirectories whilst not littering the file system.

From the same link /media provides a little more insight regarding the older tradition but no real solution for non-removable or permanent mounts.
http://tldp.org/LDP/Linux-Filesystem-Hi ... media.html
The motivation for the creation of this directory has been that historically
there have been a number of other different places used to mount removeable
media such as /cdrom, /mnt or /mnt/cdrom. Placing the mount points for all
removeable media directly in the root directory would potentially result in
a large number of extra directories in /. Although the use of subdirectories
in /mnt as a mount point has recently been common, it conflicts with a much
older tradition of using /mnt directly as a temporary mount point.
Whatever the automount feature is on Debian, and derivatives, it seems keen to mount these partitions on /media which doesn't really fit either.

One precaution is when using installer scripts on the main system with /mnt/blahblah mounted as they may expect free use of /mnt.....but I tend to tread carefully with any installers, especially outwith a live environment.

Curious about any other solutions to this.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: how to create permanent access to folders on other disk?

#7 Post by p.H »

2004 - isn't it a bit outdated ?
Proinsias wrote:no real solution for non-removable or permanent mounts.
There is no need for a solution. Permanent mounts must be located where they logically fit. It is contents dependent.

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: how to create permanent access to folders on other disk?

#8 Post by bw123 »

resigned by AI ChatGPT

canti
Posts: 74
Joined: 2011-01-31 12:57
Location: The Netherlands

Re: how to create permanent access to folders on other disk?

#9 Post by canti »

Sorry for the delay of my reply.

I added the following to my fstab:

Code: Select all

UUID=xxxxx    /home      ext4     noauto,x-systemd.automount      0     2
The result is the immediate access to the /home partition on the harddisk, without creating creating symlink (probably because I already created symlink years ago). I hope I did it correct by using the mount point /home. However, when booting the system, in the graphical Gnome environment a square appeared, containing the following message:
System Monitor Extension
Dependencies Missing
Please install:
libgtop, Network Manager and gir bindings
on Ubuntu: gir1.2-gtop-2.0, gir1.2-networkmanager-1.0
on Fedora: libgtop2-devel, Networkmanager-glib-devel
on Arch: lipgtop, networkmanager
on openSuse: typelib-1_0-GTop-2_0, typelib-1_0-Network
Of course I have Network Manager and so on. Probably I did somewhere wrong...

edit: I found where it went wrong: in fstab I used /home where I have to use /media instead. Stupid of me...
HP Envy 17 n120nd containing Debian Bullseye (Gnome 3)

canti
Posts: 74
Joined: 2011-01-31 12:57
Location: The Netherlands

Re: how to create permanent access to folders on other disk?

#10 Post by canti »

I am struggling to create useful symlink. I use the following command:

Code: Select all

ln -s /home/testhome /media/familie/testmedia
where the latter contains data on sdb.
The only result is that a small file "testhome" has been created within the folder /media/familie/testmedia. Clicking on that file leads to the the message that the symlink cannot be used because its goal "/home/testhome" does not exist. The folder /home/testhome itself is empty.

Trying the reverse, i.e.

Code: Select all

ln -s /media/familie/testmedia /home/testhome
leads to the error that no symbolic link "/home/testhome" can be created: the access is denied.

I don't know what to do...
HP Envy 17 n120nd containing Debian Bullseye (Gnome 3)

kevinthefixer
Posts: 190
Joined: 2018-05-05 22:30

Re: how to create permanent access to folders on other disk?

#11 Post by kevinthefixer »

Try /home/YourUserNameHere/testhome. Or try it with sudo.

User avatar
NFT5
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 597
Joined: 2014-10-10 11:38
Location: Canberra, Australia
Has thanked: 10 times
Been thanked: 43 times

Re: how to create permanent access to folders on other disk?

#12 Post by NFT5 »

The simplest and arguably most robust solution is to create mount points in /home/<username> and then mount each drive/partition using fstab.

For example, my fstab looks like this:

Code: Select all

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
#
# / was on /dev/sda6 during installation
UUID=13b081a7-653e-48e1-b0db-1175f2a6cd66 /               ext4    errors=remount-ro 0       1
#
# /boot/efi was on /dev/sda1 during installation
UUID=C3A8-EEA4  /boot/efi       vfat    umask=0077      0       1
#
# /home was on /dev/sda7 during installation
UUID=09a78e50-1716-49c5-8439-f94f314c62bf /home           ext4    defaults        0       2
#
# Mount SWAP
UUID=0a3dd51f-e085-477a-a750-cd2e81d02dc4	none	swap	sw	0	0
#
# Automount DATA
UUID=043A4F4345301970   /home/chris/DATA        ntfs	 defaults        0       0
#
# Automount MYDOCS-VM
UUID=975c915b-6c44-4ea0-b914-85514a31ea1e	/home/chris/MYDOCS-VM	ext4	defaults	0	0
#
# Automount VBOX-VMS
UUID=bdc2948d-0793-43c0-af75-34965771ac99	/home/chris/VBOX-VMS	ext4	defaults	0	0
#
# Mount CD drive
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0
In practice it appears that the folders on the other drives are in /home but they are physically separate. It's also a very good solution if you have multiple boot setups or are running virtual machines in that each can access the data drive(s) so you don't get duplication. Just be sure that, in fstab, you mount /home before you mount the other drives.

It is better to actually create the folders in /home than it is to rely on fstab creating them - this can lead to permissions problems whereas, by doing them separately, you can allocate permissions and they will still be there next time you boot.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: how to create permanent access to folders on other disk?

#13 Post by p.H »

canti wrote:I found where it went wrong: in fstab I used /home where I have to use /media instead
This is not the only mistake.
/home was the wrong mount point.
/media is the wrong location (only for removable media).
noauto is the wrong option for a permanent mount.

Follow NFT5's advice : create a directory in /home or wherever the filesystem contents fits, and add a permanent mount line on this directory in fstab.

canti
Posts: 74
Joined: 2011-01-31 12:57
Location: The Netherlands

Re: how to create permanent access to folders on other disk?

#14 Post by canti »

NFT5 wrote:The simplest and arguably most robust solution is to create mount points in /home/<username> and then mount each drive/partition using fstab.
...
It is better to actually create the folders in /home than it is to rely on fstab creating them - this can lead to permissions problems whereas, by doing them separately, you can allocate permissions and they will still be there next time you boot.
Since I realize editing fstab should be careful, I am trying to understand your point. Do you mean to create for example sdb1 for pictures, sdb2 for documents, sdb3 for music, sdb4 for Downloads, and so on? Hence to create mount point for every standard Nautilus /home folder, fstab them, and create symlink with the corresponding folders on sda?
HP Envy 17 n120nd containing Debian Bullseye (Gnome 3)

canti
Posts: 74
Joined: 2011-01-31 12:57
Location: The Netherlands

Re: how to create permanent access to folders on other disk?

#15 Post by canti »

p.H wrote:
canti wrote:I found where it went wrong: in fstab I used /home where I have to use /media instead
This is not the only mistake.
/home was the wrong mount point.
/media is the wrong location (only for removable media).
noauto is the wrong option for a permanent mount.

Follow NFT5's advice : create a directory in /home or wherever the filesystem contents fits, and add a permanent mount line on this directory in fstab.
Okay, thanks for corrections :).
Hence,
/home -> should be /home/<my username>?
/media -> this has to be changed into /home, perhaps via F2?
noauto -> I took that from https://wiki.archlinux.org/index.php/fs ... _partition. I thought this fits my situation because my sdb is large (1 TB). But I can have understand it wrongly.
HP Envy 17 n120nd containing Debian Bullseye (Gnome 3)

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: how to create permanent access to folders on other disk?

#16 Post by debiman »

canti wrote: Trying the reverse, i.e.

Code: Select all

ln -s /media/familie/testmedia /home/testhome
leads to the error that no symbolic link "/home/testhome" can be created: the access is denied.
this is the correct way, and the error is also correct.
try the same with sudo or su, then, before you mount anything:

Code: Select all

chown canti:canti /home/testhome

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: how to create permanent access to folders on other disk?

#17 Post by p.H »

canti wrote:/home -> should be /home/<my username>?
You mount a partition on /home if you want ALL normal user home directories to be stored in that partition.
You mount a partition on /home/<username> if you want <username> home directory contents to be stored in that partition.
You mount a partition on /home/<username>/<somedirectory> if you want <somedirectory> contents in <username> home directory to be stored in that partition.
Alternatively, you can mount a partition on any suitable empty directory (not /media, /mnt or their subdirectories) and create a symlink /home/<username>/<somelink> pointing to the mount point or any of its subdirectories.
canti wrote:noauto -> I took that from https://wiki.archlinux.org/index.php/fs ... _partition. I thought this fits my situation because my sdb is large (1 TB). But I can have understand it wrongly.
"noauto" has nothing to do with the filesystem size. It means "do no try to automatically mount the filesystem at boot or when running mount -a". You can use it when the filesystem is not always present at boot, or when you want to mount it manually.

canti
Posts: 74
Joined: 2011-01-31 12:57
Location: The Netherlands

Re: how to create permanent access to folders on other disk?

#18 Post by canti »

On sdb I have the following path /media/familie/data (when mounted manually to sdb without fstab, I did not choose the name "media", by the way; "familie" is my username). The directories containing data are in the directory "data" .
On sda the corresponding directories are in path /home/familie.

On advise of NFT5 and p.H. I have to create the /home directory on sdb. Probably the best way to do this is to rename "media/familie/data" into "/home/familie/data". But I'm afraid the command

Code: Select all

mv /media /home
will arise conflict with the existing /home/familie (on sda2 where pwd = /home/familie). Or should I use an other, better, way to execute that advise?
HP Envy 17 n120nd containing Debian Bullseye (Gnome 3)

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: how to create permanent access to folders on other disk?

#19 Post by GarryRicketson »

When I have that kind of concern,

Code: Select all

will arise conflict with the existing /home/familie 
I use a different name
IE: /home/familie/familie-1/
If a sub directory is ok, or create another user and have it's own directory :
IE: /home/familie-1
Maybe familie-data ? to be more descriptive.
I do not know if what you are doing would cause a conflict or not, but adding a number or letter would insure there is none. ( I think)

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: how to create permanent access to folders on other disk?

#20 Post by p.H »

canti wrote:

Code: Select all

mv /media /home
You don't want to do that. Really. You want to :
- unmount the filesystem from /media/familie/data
- create a directory /home/familie/data (if you want to access the contents of the filesystem under this path)
- add a line in /etc/fstab to mount the filesystem on /home/familie/data
- mount the filesystem

Note : the filesystem being mounted on /media/familie/data normally means its label is "data" and it was mounted in the GUI session opened by user "familie".

Post Reply