Automount secondary drive, and move some mountpoints there

I have an SSD and a general SATA drive with 1TB. However one of the things that Im missing is integration, I wish I could mount the secondary drive at boot and also have it mount some directories that usually take some space like /var or /home/$user/Videos…
Is there a way I can edit the configuration files so it can automount those points.

Regards.

First off, welcome to the EndeavourOS forum. I hope you enjoy your time here.

Are both drives attached to the internal Sata connectors, or is one drive on a USB port?

The best way to mount drives at log-in is by editing the /etc/fstab file.
The first step is to find the UUIDs and device numbers for the drives. As root
# ls -l /dev/disk/by-uuid
OR
# blkid

Next, cat out /etc/fstab
# cat /etc/fstab
UUID=0a26cdb6-56fc-4601-a680-8a7d4bc7bd51 / ext4 defaults 1 1
UUID=e10d3dbd-c62d-4f67-aca9-6493a8eb0a9e /boot ext4 defaults 1 2
UUID=6311-6E4A /boot/efi vfat umask=0077,shortname=winnt 0 2
UUID=93b94717-c56b-4cb4-9222-4d6a5cb6c741 /home ext4 defaults 1 2
UUID=0b396cc9-b93d-4b21-8d3f-0bad63e34f5d none swap defaults 0 0

Each partition will have a UUID number then mount point then filesystem type then options then Dump and fsck options

All this is further explained at this web site
A duckduckgo.com search will supply further sites you might want to explore. Just type in
/etc/fstab in the search input

Pudge

1 Like

Thank you, both are internal disks, this is a new install so I am open to modifying the layout of the installation. I am also open for suggestion. My big question here is the last 2 options (the last 2 digits of the instruction set). What does 0 0 means or 0 2 or 1 1. etc.

I was able to get the UUID of the hard disk and put it on the fstab.

The other question is how to put the mountpoints. If for example, my /home /opt and /var how would it look on fstab.

man fstab

Could you please show the output of
lsblk -fm
and explain which mount settings you’d like to have in /etc/fstab?

On the last 2 digits, the first digit is the dump(8) command If it is 0 that partition will NOT be dumped. If it is 1 that partition will be dumped. If you don’t know what dump is, enter 0. Unless you have a very specific reason to use dump, enter 0. As far as I know dump is deprecated and very few, if any distributions, even install dump anymore. It’s not installed on my EndeavourOS (Arch) Gnome install, and when I tried to install it, pacman didn’t know anything about it.

On the last two digits, the second digit is fsck.
fsck (file system consistency check). fsck will check a filesystem for errors, and if possible correct the errors. This check can be done automatically during boot time or ran manually. To run fsck manually , you will need to ensure that the partition you are going to check is not mounted. Which is quite difficult for the root directory. So most users run fsck at boot up as part of /etc/fstab.

In fstab, the digit zero indicates that partition will NOT be checked, the digit 1 indicates that partition will be checked first, the digit 2 indicates that partition will be second in the fsck order. The order can go as high as 16, but as a convention, most administrators check /boot first, and all other partitions are listed as 2 and let fsck figure the order out.

One more thing about fsck. In the bad old days of PATA spinning hard drives, fsck was a very useful utility to have around. Now the new SATA spinning hard drives have features built into the onboard controller chip such as S.M.A.R.T. technology and other error checking. SSDs have even more features built into their controllers such as TRIM, and other technology to the point that most users set fsck to 0 for SSDs and don’t bother running fsck. Some people even argue that running fsck at every boot up is detrimental to SSDs, although I haven’t any strong convictions on that either way.

Also, I forgot to point out in my last post:
fstab mounts the partitions in the order they are listed in fstab from top to bottom.
Here is my EndeavourOS Gnome fstab with UUID numbers, truncated for brevity, as created by genfstab during installation.

<file system>  <mount point> <type>  <options>                <dump> <pass>
UUID#            /boot/efi    vfat    umask=0077                 0     2
UUID#             /boot       ext4    defaults,noatime,discard   0     2
UUID#               /         ext4    defaults,noatime,discard   0     1
UUID#              swap       swap    defaults,noatime,discard   0     2
tmpfs              /tmp       tmpfs   defaults,noatime,mode=1777 0     0

Notice the boot order

/boot/efi      /boot      /     swap

Also notice that dump is 0 for everything

for fsck, root is 1 or first, everything else is 2 except tmpfs which is 0

As for “options” If this is what the Arch developers determined to use, who am I to question it? They probably know what’s best for this distribution.

Pudge

In reference to the above post

<file system>  <mount point> <type>  <options>                <dump> <pass>
UUID#            /boot/efi    vfat    umask=0077                 0     2
UUID#             /boot       ext4    defaults,noatime,discard   0     2
UUID#               /         ext4    defaults,noatime,discard   0     1
UUID#              swap       swap    defaults,noatime,discard   0     2
tmpfs              /tmp       tmpfs   defaults,noatime,mode=1777 0     0

In addition, you could add before tmpfs the following:

UUID# /home ext4 defaults,noatime,discard 0 2

and use the UUID for the 1 Tb general disk and maybe substitute your fstype if necessary such as xfs or whatever

I am a staunch supporter of the KISS methodology. As so I would leave /var and /opt as is, and move /home to the 1 TB drive and let the 1 TB drive be entirely /home

but if you decide to move /var and /opt:

UUID# /var ext4 defaults,noatime,discard 0 2
UUID# /opt ext4 defaults,noatime,discard 0 2

In both cases, the UUID would be a separate partition on the 1 TB disk

Pudge

1 Like

bind is also possible… but changing this after you already install the system will need also to copy the files over to new places…

i use this in fstab:
it mounts the “bigdatadisk” under /mnt/bigdatadisk
then bind the directories on it to users home (pics/docs/music/video)

UUID=XXX /mnt/bigdatadisk ext4 defaults,relatime,data=ordered 0 0

/mnt/bigdatadisk/pictures	/home/joekamprad/pictures	auto	bind	0 0
/mnt/bigdatadisk/documents	/home/joekamprad/documents  auto    bind    0 0
/mnt/bigdatadisk/videos	    /home/joekamprad/videos     auto    bind    0 0
/mnt/bigdatadisk/music	    /home/joekamprad/music      auto    bind    0 0

I tried doing what you had @joekamprad but got a bunch of errors when trying to mount the disk. The error was a bit generic so not sure what can I do to make it work. This is the image that was shown:

mount: /run/media/jza/data: wrong fs type, bad option, badsuperblock...
run-media-jza-data.mount: Mount process exited, code=exited, status=32
run-media-jza-data.mount: Failed with result 'exit-code'.
Faied to mount /run/media/data.

Adding some images from the screen…

My current fstab is this:

# UUID=a0bd471c-d3e5-4cc6-ab7e-b8b7ecf7da5f /run/media/jza/data ext4    defaults,relatime,data=ordered 0 0 
# /run/media/jza/data   /home/jza/Pictures      auto    bind    0 0
# /run/media/jza/data   /home/jza/Music         auto    bind    0 0
# /run/media/jza/data   /home/jza/Videos        auto    bind    0 0
# /run/media/jza/data   /home/jza/Projects      auto    bind    0 0
# /run/media/jza/data   /home/jza/Documents     auto    bind    0 0

Your fstab has all lines commented out?
If not, does single “…/jza/data” contain all files for Pictures, Music, … ?

Can you show the output of command

    lsblk -fm

Umm… the coments are there so the system can boot fully.

I already did that… is on the UUID for my disk.

NAME   FSTYPE LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINT   SIZE OWNER GROUP MODE
sda                                                                                931.5G root  disk  brw-rw----
└─sda1 btrfs  data  a0bd471c-d3e5-4cc6-ab7e-b8b7ecf7da5f                           931.5G root  disk  brw-rw----

You could also generate a new fstab as the image indicates …nuevo%20fstab

Dont know if a generated fstab will actually achieve what I want to do with my secondary drive.

Any advice on this, should I have the folders available in the /home/xxx/ or will they be put by fstab/bind?

I can help you out over tomorrow…

That would be good, been reading the man for mount, saw some other options similar to bind like move, and rbind.

—> UUID=a0bd471c-d3e5-4cc6-ab7e-b8b7ecf7da5f /run/media/jza/data ext4

but:

sda 931.5G root disk brw-rw----
└─sda1 btrfs data a0bd471c-d3e5-4cc6-ab7e-b8b7ecf7da5f

so it is indeed the wrong filesystemtype ypu need to use btrfs instead of ext4 inside fstab entry.

:::

UUID=a0bd471c-d3e5-4cc6-ab7e-b8b7ecf7da5f /run/media/jza/data btrfs    defaults      0  0 
/run/media/jza/data/pictures   /home/jza/Pictures      auto    bind    0 0
/run/media/jza/data/music   /home/jza/Music         auto    bind    0 0
/run/media/jza/data/videos   /home/jza/Videos        auto    bind    0 0
/run/media/jza/data/projects  /home/jza/Projects      auto    bind    0 0
/run/media/jza/data/documents   /home/jza/Documents     auto    bind    0 0

first entry for bind must be the mountpoint + the path to the folder you want to bind to another forlder…

https://btrfs.wiki.kernel.org/index.php/Main_Page
https://wiki.archlinux.org/index.php/Btrfs

is what you will need to read to choose the right mount options on that filesystem…

no, thats outdated, the fstab is btrfs… and gave me an error. I tried putting ext4 as an alternative but didnt fix it either. I just never changed it back. I still cant mount with btrfs. However I will try to get rid of the options just like you showed.

ok the mount got fixed after removing the other options like relatime,data=ordered

yea they are for ext4 only… btrfs do not need thouse…