how to create permanent access to folders on other disk?

Kernels & Hardware, configuring network, installing services

how to create permanent access to folders on other disk?

Postby canti » 2018-10-24 21:11

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 Pavilion Entertainment PC d7 4GB 64bits, containing Debian Jessie (Gnome 3), Ubuntu 15.10 (xfce) and Windows Vista
HP Envy 17 n120nd containing Debian Stretch (Gnome 3)
canti
 
Posts: 69
Joined: 2011-01-31 12:57
Location: The Netherlands

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

Postby bw123 » 2018-10-24 22:05

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.
User avatar
bw123
 
Posts: 3522
Joined: 2011-05-09 06:02
Location: TN_USA

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

Postby Proinsias » 2018-10-25 09:06

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
Proinsias
 
Posts: 4
Joined: 2018-10-18 09:32

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

Postby milomak » 2018-10-25 19:40

what am i missing here?

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

so why does /dev/sda need to be involved?
iMac Late-2015 27" 5K Retina - MacOS and Windows 10 (Bootcamp)/ Debian Sid (External SSD)
Laptop (64-bit) - Debian Sid, Win10,
Kodi Box - Debian Sid
milomak
 
Posts: 1803
Joined: 2009-06-09 22:20

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

Postby p.H » 2018-10-26 07:18

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.
p.H
 
Posts: 631
Joined: 2017-09-17 07:12

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

Postby Proinsias » 2018-10-26 09:34

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.
Proinsias
 
Posts: 4
Joined: 2018-10-18 09:32

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

Postby p.H » 2018-10-26 10:57

Proinsias wrote:http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/media.html

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.
p.H
 
Posts: 631
Joined: 2017-09-17 07:12


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

Postby canti » 2018-10-28 17:08

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 Pavilion Entertainment PC d7 4GB 64bits, containing Debian Jessie (Gnome 3), Ubuntu 15.10 (xfce) and Windows Vista
HP Envy 17 n120nd containing Debian Stretch (Gnome 3)
canti
 
Posts: 69
Joined: 2011-01-31 12:57
Location: The Netherlands

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

Postby canti » 2018-10-28 19:30

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 Pavilion Entertainment PC d7 4GB 64bits, containing Debian Jessie (Gnome 3), Ubuntu 15.10 (xfce) and Windows Vista
HP Envy 17 n120nd containing Debian Stretch (Gnome 3)
canti
 
Posts: 69
Joined: 2011-01-31 12:57
Location: The Netherlands

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

Postby kevinthefixer » 2018-10-28 20:37

Try /home/YourUserNameHere/testhome. Or try it with sudo.
kevinthefixer
 
Posts: 87
Joined: 2018-05-05 22:30

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

Postby NFT5 » 2018-10-29 04:23

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.
User avatar
NFT5
 
Posts: 240
Joined: 2014-10-10 11:38
Location: Canberra, Australia

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

Postby p.H » 2018-10-29 08:49

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.
p.H
 
Posts: 631
Joined: 2017-09-17 07:12

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

Postby canti » 2018-10-29 11:25

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 Pavilion Entertainment PC d7 4GB 64bits, containing Debian Jessie (Gnome 3), Ubuntu 15.10 (xfce) and Windows Vista
HP Envy 17 n120nd containing Debian Stretch (Gnome 3)
canti
 
Posts: 69
Joined: 2011-01-31 12:57
Location: The Netherlands

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

Postby canti » 2018-10-29 11:36

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/fstab#Local_partition. I thought this fits my situation because my sdb is large (1 TB). But I can have understand it wrongly.
HP Pavilion Entertainment PC d7 4GB 64bits, containing Debian Jessie (Gnome 3), Ubuntu 15.10 (xfce) and Windows Vista
HP Envy 17 n120nd containing Debian Stretch (Gnome 3)
canti
 
Posts: 69
Joined: 2011-01-31 12:57
Location: The Netherlands

Next

Return to System configuration

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable