Automount User data partitions

8 risposte [Ultimo contenuto]
Iscritto: 01/03/2015

After several years of squirreling away data and discovering with hw-probe that a couple of data-only hard drives
are at risk of imminent failure, I'm consolidating data onto the surviving hard drives. It happens that there are
ten such drives, plus the Data partition in the active OS's drive. I would like the nine "unattached" hard drives
to be automounted on startup of the operating system on my Lenovo Thinkpad T420, which is Trisquel_10 (nabia).

This has become necessary because there is a competing application that automounts some of those drives using their
UUID's, but I'd like to use user-readable names that I assign to each data partition with GPartEd. I've filled out
my /etc/fstab file with those assigned names, and now I'm looking for an application that will automount the listed
partitions upon startup of the 'puter with GRUB.

I've made a list of the locations where each of the ten partitions end up after startup, and I can use terminal
to mount each one at the respective named mount points in /media/george/, but the partitions in /media/george/
include several additional ones that duplicate the ones I've created, causing the same partitions to be mounted
under different names in /media/george/. That won't do, but I'm clueless regarding the competing automount .conf

I'm aware that I cannot control the order in which the various hard drives are recognized in /dev; hence, the careful
naming of the Data partitions to avoid collisions. The 'puter is plugged into a Lenovo 4336 Port Replicator that adds
four USB ports to complement the four that the T420 provides. There is also another hard drive plugged into the CD/DVD
drive bay on an aftermarket caddy, and the target recipient 4TB hard drive that has four named Data partitions. What
with the mouse and external ThinkPenguin WiFi, seven of the USB ports are taken, leaving one USB port for hot plugging
an additional Data drive. If I do this right, I'll be able to plug any of my working Thinkpads (two T420's and one T430)
into the port replicator, with only minor changes needed in the /etc/fstab file to manage the automounting of the Data

I's the automount step that's slowing progress right now.

Magic Banana

I am a member!

I am a translator!

Iscritto: 07/24/2010

Don't you just want to name the filesystems on the external drives? If so, please read

Iscritto: 01/03/2015

OK ... I've executed everything in the recommended website down to where it's said:
Verify the Change
Now for the easiest part: unplug the drive, wait a second, then plug it back in.
It should appear on your desktop with the new label and have its new mount point.
Without unplugging and having the device remount, you can also just run:

sudo blkid ... but tldr says:
List all partitions in a table, including current mountpoints:
sudo blkid -o list with the result indicated in the accompanying screenshot of the desktop.

Can I expect that the mounted partitions will appear again after a reboot ?
Up until now, there have been competing labels on the various drives that have been automounting,
from whatever mechanism I can no longer recall.

................ Pause while the system reboots .................

Not finished: All that appear are the original competing automounted partitions.
Here are what's listed in /media/george/:
/media/george$ ls
1pt8TB-Data 523ff5d3-64ea-486d-ba82-58721680b667 c2a79a42-b2ba-47fd-84a7-68a69be83cfe Data-1
Data-A Data-C e7da792a-af1e-4c3b-9384-e105a7249dab GBData 3651f1de-6ae4-40f1-8965-94ef93dfd536
700a21ec-1dda-4460-ab63-0972108e1a5e Data-0 Data-2 Data-B Data-D Expansion

Three folders populated with the competing filesystems first have to be unmounted:
umount /media/george/523ff5d3-64ea-486d-ba82-58721680b667
umount /media/george/e7da792a-af1e-4c3b-9384-e105a7249dab
umount /media/george/700a21ec-1dda-4460-ab63-0972108e1a5e

It turns out that the others are simply the folders in which the various filesystems are to be mounted:
sudo mount /dev/sdc6 /media/george/1pt8TB-Data
sudo mount /dev/sda5 /media/george/GBData
sudo mount /dev/sde2 /media/george/Data-0
sudo mount /dev/sdb3 /media/george/Data-1
sudo mount /dev/sdd3 /media/george/Data-2
sudo mount /dev/sdf1 /media/george/Data-A
sudo mount /dev/sdf2 /media/george/Data-B
sudo mount /dev/sdf3 /media/george/Data-C
sudo mount /dev/sdf4 /media/george/Data-D
sudo mount /dev/sdf5 /media/george/Expansion

In the midst of all this, the 4TB HDD goes to sleep and wrecks the labels of its five partitions,
Data-A (becomes Data-A1 Data-B (becomes Data-B1) and so on ...
Apparently that HDD has a go-to-sleep feature that has to be rectified to "never-sleep".

........... Pause for another reboot ..........

Followed by quickly re-executing umount and mount scripts, whereupon the intended filesystems
reappear on the home screen (but none seen in the Desktop folder) with the original labels, but
the correct filesytems, to wit:
Data-0 appears as 943 GB Volume
Data-1 appears as 958 GB Volume
Data-2 also appears as 958 GB Volume
1.8TB-Data appears as 2.0 TB Volume
The five data partitions of the 4.0 TB drive are now correctly listed, named & populated.

How am I to automount the filesystems instead of having to execute over a dozen scripts
after each reboot and after restarting the 4.0 TB HDD from its slumber ?

Regarding the show-stopping "go-to-sleep" behavior of the 4.0 TB HDD:
This feature can be controlled with hdparm with the command
hdparm -S0 /dev/sdf whereupon the response is setting standby to 0 (off) which is explained by man hdparm thusly:
A value of zero means "timeouts are disabled": the device will not automatically enter standby mode.

An unseen hand lets /dev/sdf enter standby mode anyway, whereupon it disappears and can no
longer be controlled by hdparm. What is that unseen hand ?

Screenshot at 2022-08-26 09-20-21.png

I am a translator!

Iscritto: 08/18/2020

> I've filled out my /etc/fstab file with those assigned names

Can you show the whole contents of your /etc/fstab?

Iscritto: 01/03/2015

Avron requested my /etc/fstab table:

# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
UUID=d1457cab-df45-42f4-abdf-b768bec0e30d / ext4 errors=remount-ro 0 1
Data-A /media/george/Data-A ext4 errors=remount-ro 0 1
Data-B /media/george/Data-B ext4 errors=remount-ro 0 1
Data-C /media/george/Data-C ext4 errors=remount-ro 0 1
Data-D /media/george/Data-D ext4 errors=remount-ro 0 1
Expansion /media/george/Expansion ext4 errors=remount-ro 0 1
1pt8TB-Data /media/george/1pt8TB-Data ext4 errors=remount-ro 0 1
Data-0 /media/george/Data-0 ext4 errors=remount-ro 0 1
Data-1 /media/george/Data-1 ext4 errors=remount-ro 0 1
Data-2 /media/george/Data-2 ext4 errors=remount-ro 0 1
GBData /media/george/GBData xfs errors=remount-ro 0 1
# swap was on /dev/sda7 during installation
UUID=67565b77-4da7-4b46-a159-b25ff8ce9b0d none swap sw 0 0
# swap was on /dev/sdb2 during installation
UUID=0f96301f-c389-413a-aa3f-1e2afda0bdf6 none swap sw 0 0
# swap was on /dev/sdc2 during installation
UUID=8aebff45-3cb8-433a-8b90-b124bfcfb0c9 none swap sw 0 0

That's what I wish it would be, but there isn't any automount in effect, so I've had to execute
some thirteen umount and mount scripts to get that set to happen; but it's lost on a reboot.

That first uncommented line starting with "UUID" is a holdover from the previous fstab file
which I updated to produce the present list. The affected partition goes with Data-2 on the
same HDD.


I am a translator!

Iscritto: 08/18/2020

The first exmaple given by "man fstab" is:
LABEL=t-home2 /home ext4 defaults,auto_da_alloc 0 2

So I would add "LABEL=" but I am not sure this is actually the cause of your problem.

Another thing is that I noticed that /media/<username> is where USB keys are mounted automatically when inserted, these keys are not in /etc/fstab but still they appear with a name (not UUID) that might come from the label on the file system.

I am wondering what happens if you comment (add # at the begining of the line) all drives with labels in /etc/fstab, whether some won't actually be mounted where you want.

You could also try to keeping your drives not commented in /etc/fstab but replace /media/george/yourDriveName with another directory not in /media (you need to create them first).

If you need to mount everything in /etc/fstab manually, perhaps "sudo mount -a" would be enough (no need to do it one by one).

Iscritto: 01/03/2015

Avron Inquired:
The first exmaple given by "man fstab" is:
LABEL=t-home2 /home ext4 defaults,auto_da_alloc 0 2

So I would add "LABEL=" but I am not sure this is actually the cause of your problem.

What I actually did was use GPartEd to label the Data partitions wherein I could carefully
make sure that the labels are all different and applied to the locations of the partitions
in /dev/.
In the distant past several drives were configured to automount on rebooting the 'puter,
and now they still automount, but the actual labels in the path statements have my intended
labels even though the home screen displays their former labels.

Magic Banana

I am a member!

I am a translator!

Iscritto: 07/24/2010

I am wondering what happens if you comment (add # at the begining of the line) all drives with labels in /etc/fstab, whether some won't actually be mounted where you want.

I also believe that amenex only wanted to name filesystems (what I made him do), and that those filesystems should not be listed in /etc/fstab.

Also, that /etc/fstab contains three swap partitions. I may miss something, but I see little reason to have more than one (it can be used by several systems, if several systems are installed): probably disk space that can be saved.

Iscritto: 01/03/2015

Progress: On reboot if I first restart the Seagate 4TB drive with its handy on/off button
and executehdparm -Z /dev/sdf to shut off Seagate's power-saving feature, and then
execute the following commandsumount /media/george/d1457cab-df45-42f4-abdf-b768bec0e30d
umount /media/george/c2a79a42-b2ba-47fd-84a7-68a69be83cfe
umount /media/george/d1457cab-df45-42f4-abdf-b768bec0e30d
umount /media/george/523ff5d3-64ea-486d-ba82-58721680b667
umount /media/george/e7da792a-af1e-4c3b-9384-e105a7249dab
umount /media/george/700a21ec-1dda-4460-ab63-0972108e1a5e
sudo mkdir /media/george/1pt8TB-Data
sudo mkdir /media/george/GBData
sudo mkdir /media/george/Data-0
sudo mkdir /media/george/Data-1
sudo mkdir /media/george/data-2
sudo mount /dev/sde2 /media/george/Data-0
sudo mount /dev/sdb3 /media/george/Data-1
sudo mount /dev/sdd3 /media/george/Data-2
sudo mount /dev/sda5 /media/george/GBData
sudo mount /dev/sde2 /media/george/Data-0
sudo mount /dev/sdb3 /media/george/Data-1
sudo mount /dev/sdd3 /media/george/Data-2

The first three unmount steps eliminate the gratuitously mounted O/S
partitions that aren't for user data.
The second three unmount/remount steps eliminate the confusing UUID's
and put the incorrectly named data partitions mounted on the dsesktop
but whose Paths actually point to the desired data partitions.
Restarting the Seagate 4TB drive puts its five data partitions,
suitably named, mounted on the desktop. (attached)

On further inquiry using the search term HDIO_DRIVE_CMD(seagatepwrsave) failed: Input/output error
Seagate drives that have the power saving feature of shutting down when idle for rather too short periods
not only enter sleep mode but also break their USB connection and cannot be restarted with any script.
My workaround is to cycle the power off and back on, whereupon the five Data directories are remouted,
albeit annoyingly slowly.
How to keep the Seagate drive active ?

Update: There's no way to fool the Seagate power-saving function. Modify and save your working file to a
non-Seagate HDD only save the finished product to the Seagate 4TB drive when your work is finished. The
five data partitions will always disappear (unmount) from the desktop after a period of inactivity given
by sudo hdparm -S 255 /dev/sdf which is 21 minutes, 15 seconds. The unmount happens because
sleep mode causes a disconnect from the USB port. If those five Data partitions (Data-A through Data-D
and Expansion) disappear, they can be reinstated by cycling the Seagate 4TB HDD with its built-in On/Off

Monday's revelation: The case of the Seagate 4TB HDD is warm ... why would that be so it was "asleep" all
night ?

Workaround started Monday afternoon:
See: >em>
where it's said:
while :
date +%s > /second_drive/keepalive_linux.txt
sleep 2

which I adapted to the present situation:
while :
date +%s > /media/george/Expansion/george/keepalive_linux.txt
sleep 10m

Saved as KeepAliveScript-08292022.txt in /media/george/GBData/george/Scripts/KeepAliveScript.txt
cp /media/george/GBData/george/Scripts/KeepAliveScript-08292022.txt /media/george/GBData/george/Scripts/KeepAliveScript
sudo chmod +x /media/george/GBData/george/Scripts/KeepAliveScript

Apply the following two scripts right after starting or restarting /dev/sdf:
cd /media/george/GBData/george/Scripts

Screenshot at 2022-08-27 17-11-40.png