[Hardware] mounting of new drive

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
b1-66er
Posts: 12
Joined: 2024-03-27 11:48
Has thanked: 1 time

[Hardware] mounting of new drive

#1 Post by b1-66er »

i formatted the drive, created the mount point, edited the fstab file and reloaded systemctl like you're supposed to but it didn't work.. trying to copy files over to the new drive doesn't work

the mount -a command gives me an error.

Code: Select all

user@host:~$ sudo mount -a
mount: Partition: mount point does not exist.
       dmesg(1) may have more information after failed mount system call.
the mount command sepcifying the newly formatted drive tells me it's already mounted

Code: Select all

sudo mount /media/Zauberlaterne
mount: /media/Zauberlaterne: /dev/sda1 already mounted on /media/Zauberlaterne.
       dmesg(1) may have more information after failed mount system call.
dmesg gives me this

Code: Select all

[36045.141309] systemd-fstab-generator[79069]: Mount point Partition is not a valid path, ignoring.
[36083.185988] EXT4-fs (sda1): mounted filesystem with ordered data mode. Quota mode: none.
i'm confused
i didn't change anything else in my fstab except for adding the new drive at the bottom..
here's my edited fstab

Code: Select all

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p2 during installation
UUID=1e6068ae-c6a2-4b71-907c-adb9c2797d8a   /           ext4    errors=remount-ro   0 1
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=179C-5FF0                              /boot/efi   vfat    umask=0077          0 1
# /home was on /dev/nvme0n1p6 during installation
UUID=cc77da13-dd86-4731-91d3-d6a614029e63   /home       ext4    defaults            0 2
# /tmp was on /dev/nvme0n1p5 during installation
UUID=1cc13daf-a7cf-43f8-83ea-769bdacbff91   /tmp        ext4    defaults            0 2
# /var was on /dev/nvme0n1p3 during installation
UUID=464abeac-882c-468c-b537-241cce1cbc29   /var        ext4    defaults            0 2
# swap was on /dev/nvme0n1p4 during installation
UUID=3929b0bc-d507-440f-a006-a11aa000fddf   none        swap    sw                  0 0
/dev/sdb1                                   /mnt        exfat   defaults            0 0
#
#Zauberlaterne
UUID=235de5c8-dd4f-40d9-a5d3-c0e18907e606       /media/Zauberlaterne    ext4    defaults        0       0
please help i just wanna archive my movies

:linked:

Dai_trying
Posts: 1173
Joined: 2016-01-07 12:25
Has thanked: 13 times
Been thanked: 30 times

Re: [Hardware] mounting of new drive

#2 Post by Dai_trying »

Does the folder exist /media/Zauberlaterne ?

If so could it be a permissions problem?

My fstab entries for anything mounted at /media are usually used in conjunction with a user, and so would be like /media/dai/Zauberlaterne which is what makes me think it might be permission related.

EDIT Just to add that many on this forum advise against using /media location for mount points that are not system generated (i.e. automount external devices) but I haven't personally had issues arising from this.

User avatar
Trihexagonal
df -h | participant
df -h | participant
Posts: 194
Joined: 2022-03-29 20:53
Location: Land of the Dead
Has thanked: 30 times
Been thanked: 22 times
Contact:

Re: [Hardware] mounting of new drive

#3 Post by Trihexagonal »

I have never edited /etc/fstab once in 25 years. I've never had to.

Code: Select all

sudo mount /dev/sdb1 /media/username
sudo umount /dev/sdb1 /media/username

b1-66er
Posts: 12
Joined: 2024-03-27 11:48
Has thanked: 1 time

Re: [Hardware] mounting of new drive

#4 Post by b1-66er »

Dai_trying wrote: 2024-08-19 11:46 Does the folder exist /media/Zauberlaterne ?

If so could it be a permissions problem?

My fstab entries for anything mounted at /media are usually used in conjunction with a user, and so would be like /media/dai/Zauberlaterne which is what makes me think it might be permission related.

EDIT Just to add that many on this forum advise against using /media location for mount points that are not system generated (i.e. automount external devices) but I haven't personally had issues arising from this.
it was an owner issue
i had used sudo mkdir. now its fixed and works as intended thank you!

i also used /media/user/folder to mount

another question, what's the reason for not using media? i always thought it's intended to be used that way

b1-66er
Posts: 12
Joined: 2024-03-27 11:48
Has thanked: 1 time

Re: [Hardware] mounting of new drive

#5 Post by b1-66er »

Trihexagonal wrote: 2024-09-05 09:38 I have never edited /etc/fstab once in 25 years. I've never had to.

Code: Select all

sudo mount /dev/sdb1 /media/username
sudo umount /dev/sdb1 /media/username
i want the drive to be automountable since some app doesn't recognise it otherwise..

(if there's a better way then please elaborate (i'm still learning))

lindi
Debian Developer
Debian Developer
Posts: 598
Joined: 2022-07-12 14:10
Has thanked: 2 times
Been thanked: 117 times

Re: [Hardware] mounting of new drive

#6 Post by lindi »

/media is handled by udisks, you should not do any manual operations to it. If you use gnome you can use for example the Disks utility to create filesystems or mount them there.

Dai_trying
Posts: 1173
Joined: 2016-01-07 12:25
Has thanked: 13 times
Been thanked: 30 times

Re: [Hardware] mounting of new drive

#7 Post by Dai_trying »

b1-66er wrote: 2024-11-23 11:14 another question, what's the reason for not using media? i always thought it's intended to be used that way
I thought so too when I was early in my Linux journey and it is only using the words of others that I mentioned it, as I said I have never had any issues using this location but have tried to use /mnt when I remember to, this had the added benefit of not having the username in the path and is likely a more "appropriate" location (but I could also be wrong about that).

b1-66er
Posts: 12
Joined: 2024-03-27 11:48
Has thanked: 1 time

Re: [Hardware] mounting of new drive

#8 Post by b1-66er »

lindi wrote: 2024-11-23 13:50 /media is handled by udisks, you should not do any manual operations to it. If you use gnome you can use for example the Disks utility to create filesystems or mount them there.
thanks! the tutorial i used on youtube told me to use /media.. i fixed it for all the ssd's now :D

is there another way to add drives so they mount at boot without having to edit the fstab file?

Dai_trying
Posts: 1173
Joined: 2016-01-07 12:25
Has thanked: 13 times
Been thanked: 30 times

Re: [Hardware] mounting of new drive

#9 Post by Dai_trying »

b1-66er wrote: 2024-11-24 09:00 is there another way to add drives so they mount at boot without having to edit the fstab file?
There are, as always "many ways to skin a cat" If this is an always connected device i.e. a second hdd/ssd then you could always write a very short shell script to run at startup, if it is a removable device i.e. usb drive or external drive you could write a udev rule to mount it when inserted, there are other ways to do most things with Linux but the most common way (in this case editing fstab) is usually the best/easiest method really IMHO.

b1-66er
Posts: 12
Joined: 2024-03-27 11:48
Has thanked: 1 time

Re: [Hardware] mounting of new drive

#10 Post by b1-66er »

Dai_trying wrote: 2024-11-24 08:21 I thought so too when I was early in my Linux journey and it is only using the words of others that I mentioned it, as I said I have never had any issues using this location but have tried to use /mnt when I remember to, this had the added benefit of not having the username in the path and is likely a more "appropriate" location (but I could also be wrong about that).
i read a bit up on it and it seems /mnt is for drives and /media is the newer thing made for removable drives mostly managed by udisk. mounting drives in media might cause udisk wanting to mount an already mounted drive but that's no big deal i guess? since both mounting points worked equally well for me..

and i also find editing fstab the easiest way. i don't see why making a bash script when there's already a file and a step at boot that does that..

lindi
Debian Developer
Debian Developer
Posts: 598
Joined: 2022-07-12 14:10
Has thanked: 2 times
Been thanked: 117 times

Re: [Hardware] mounting of new drive

#11 Post by lindi »

FHS says that /mnt is reserved as a temporary mount point. But you can of course create a new directory for this purpose.

Dai_trying
Posts: 1173
Joined: 2016-01-07 12:25
Has thanked: 13 times
Been thanked: 30 times

Re: [Hardware] mounting of new drive

#12 Post by Dai_trying »

lindi wrote: 2024-11-24 13:29 FHS says that /mnt is reserved as a temporary mount point. But you can of course create a new directory for this purpose.
yes,I probably should have stated that I use directory names in that location i.e. my nas drive is /mnt/nas and so on...

CwF
Global Moderator
Global Moderator
Posts: 3144
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 63 times
Been thanked: 269 times

Re: [Hardware] mounting of new drive

#13 Post by CwF »

Here's my two cents to confuse the situation...

There are factors not mentioned in all of this concerning the purpose of the drive in question. It is a root owned drive, not used by non-interactive local users, without user login or maybe even without a DE? In my thinking that's the only time fstab needs to be used. Both /mnt and /media have similar usefulness that should be automated outside of user interaction - they are not initiated by the user but on behalf of the user via DE interactions, as in automagic.

If the drive is intended for user interaction within a DE then a few of those points are clarified. First, there is no need to mount at boot when mounting at logon for all practical purposes has the same effect. With automount declarations in ~/.profile there is no root involvement needed in the setup. If the mount points are within /home, then there is no root space cruft at all, unless we chose to hide drives from the DE with udev. Many DE's will do their automagic independently from and in parallel to the ~/.profile automounts.

So this drive in question is going to be single user path, or multi-user path, is owned by the local user, or is a temporary mount of a foreign device. Not all the same solution!

So I continue to recommend for a single user system ‘systemd-mount --automount=yes what where’ declared in ~/.profile with 'what' typically '/dev/disk/by-label/label' and ‘where’ always ‘~/$XDG/.somewhere’, that's somewhere in user home...

Short, single line, to the point, simple. And likely a solution too new to compete with obsolete archaic norms. You might see it on page 50 of the google search ‘How to mount a drive in Linux’

You do need configured polkit authority for this user. When drives are not mounted they will not show for ‘df’ but do show for ‘lsblk’
Examples: the first are virtual drives in a vm, the second are real devices on a host server;

Code: Select all

 $  lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 111.8G  0 disk 
└─sda1   8:1    0 111.8G  0 part 
sdb      8:16   0  30.5G  0 disk 
└─sdb1   8:17   0  30.5G  0 part 
sdc      8:32   0  30.5G  0 disk 
└─sdc1   8:33   0  30.5G  0 part 
sdd      8:48   0  95.4G  0 disk 
└─sdd1   8:49   0  95.4G  0 part 
sde      8:64   0   8.4G  0 disk 
└─sde1   8:65   0   8.4G  0 part 
zram0  251:0    0   3.1G  0 disk [SWAP]
vda    254:0    0   8.4G  0 disk 
└─vda1 254:1    0   8.4G  0 part /

$  lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 111.8G  0 disk 
└─sda1   8:1    0  16.8G  0 part /
sdb      8:16   0 931.5G  0 disk 
└─sdb1   8:17   0 931.5G  0 part
sdc      8:32   0 931.5G  0 disk 
└─sdc1   8:33   0 931.5G  0 part 
sdd      8:48   0   1.8T  0 disk 
└─sdd1   8:49   0   1.8T  0 part 
sde      8:64   0 953.9G  0 disk 
└─sde1   8:65   0 953.9G  0 part 
zram0  252:0    0  25.2G  0 disk [SWAP]
Mottainai

User avatar
sunrat
Site admin
Site admin
Posts: 7451
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 134 times
Been thanked: 665 times

Re: [Hardware] mounting of new drive

#14 Post by sunrat »

CwF wrote: 2024-11-24 17:20
So I continue to recommend for a single user system ‘systemd-mount --automount=yes what where’ declared in ~/.profile with 'what' typically '/dev/disk/by-label/label' and ‘where’ always ‘~/$XDG/.somewhere’, that's somewhere in user home...
[/code]
Could you please show an actual example of the line added to ~/.profile ?
I have always used fstab entries and mount in a subdirectory of /mnt which work fine, but this seems like a good and simpler solution.

I create another /mnt subdirectory called /temp for any temporary manual mounts I wish to do. Never had anything automatically try to mount in /mnt. udev always uses /media.

Code: Select all

ls /mnt
music  sessions  stash  temp  vault
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

CwF
Global Moderator
Global Moderator
Posts: 3144
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 63 times
Been thanked: 269 times

Re: [Hardware] mounting of new drive

#15 Post by CwF »

sunrat wrote: 2024-11-24 21:44 Could you please show an actual example of the line added to ~/.profile ?
The above systems:
‘front end’ vm

Code: Select all

#create tmpfs disk savers
systemd-mount -t tmpfs -o size=12G ramdesk ~/Desktop
systemd-mount -t tmpfs -o size=8G dram ~/Downloads
systemd-mount -t tmpfs -o size=1G thram ~/.cache/thumbnails
systemd-mount -t tmpfs -o size=1G mram ~/.cache/mozilla

#start cow automounts
systemd-mount --automount=yes --timeout-idle-sec=60 /dev/disk/by-label/m4av ~/Music/.m4av
systemd-mount --automount=yes --timeout-idle-sec=60 /dev/disk/by-label/music ~/Music/.music
systemd-mount --automount=yes --timeout-idle-sec=60 /dev/disk/by-label/noise ~/Music/.noise
host, by the way all the above cow's and OS / disk reside on 'images'

Code: Select all

# tmpfs disk savers
systemd-mount -t tmpfs -o size=1G thram ~/.cache/thumbnails
systemd-mount -t tmpfs -o size=4G dram ~/Downloads
systemd-mount -t tmpfs -o size=80G vram ~/Videos/vram
systemd-mount -t tmpfs -o size=60G ram ~/Public/ram

# off disk automounts
systemd-mount /dev/disk/by-label/images ~/Public/.images
systemd-mount --automount=yes --timeout-idle-sec=60 /dev/disk/by-label/dvr ~/Videos/.dvr
systemd-mount --automount=yes --timeout-idle-sec=60 /dev/disk/by-label/vcr ~/Videos/.vcr
systemd-mount --automount=yes --timeout-idle-sec=60 /dev/disk/by-label/tree ~/Public/tree
Mottainai

CwF
Global Moderator
Global Moderator
Posts: 3144
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 63 times
Been thanked: 269 times

Re: [Hardware] mounting of new drive

#16 Post by CwF »

Note, this can be tried in a terminal to verify things work as expected.

for a USB, I've used

Code: Select all

systemd-mount --owner=1001 --automount=yes --timeout-idle-sec=60 /dev/disk/by-label/USB_POOL ~/Public
formats w/o permissions need --owner. Disk formats with rights should be formatted w/ user rights. or fixed after. So in the examples above without --owner, the initial format is done with specified permissions, eg

Code: Select all

/sbin/mkfs.ext4 -L images -E root_owner=1000:50 /dev/vdb1
To dismount on recent editions

Code: Select all

systemd-umount ~/Public
Or a systemctl stop on older editions. Either way there are two systemd units created, one mount and one automount - systemd-umount will stop both.

These systemd-mount declarations are tolerant. On a logoff/logon cycle they are ignored. If the storage doesn't exist, it is ignored. The user can dismount at any time. They are invoked with a remote login and autologins. They can ask for a password, or not. Root involvement is limited to one time actions of formatting the disk and setting up the user with the permissions to mount. fstab remains untouched. Easy.
Mottainai

User avatar
sunrat
Site admin
Site admin
Posts: 7451
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 134 times
Been thanked: 665 times

Re: [Hardware] mounting of new drive

#17 Post by sunrat »

I'm more confused now @CwF :lol:

Looking into this a bit more, the normal way to mount a local disk with systemd would be to write a systemd .mount unit as described at https://hackmd.io/@yujungcheng/BJ8ezKAQ6
Example:
create systemd file "/etc/systemd/system/mnt-data.mount". The unit filename must reflect to the mount point path. For example, path "/mnt/data" has unit filename "mnt-data.mount".

Code: Select all

[Unit]
Description = mount /dev/sda to /mnt/data

[Mount]
What = /dev/sda
Where = /mnt/data
Type = ext4
Options = defaults

[Install]
WantedBy = local-fs.target
Then start the unit and it should mount at boot (or also immediately?)

Code: Select all

# systemctl start mnt-data.mount
More explanation and options - https://manual.siduction.org/systemd-mount_en.html
man page - https://www.freedesktop.org/software/sy ... mount.html

One thing I'm wondering about is mounting by LABEL, would this be correct?:

Code: Select all

What = LABEL=Music
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

CwF
Global Moderator
Global Moderator
Posts: 3144
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 63 times
Been thanked: 269 times

Re: [Hardware] mounting of new drive

#18 Post by CwF »

Secret, I tend not to ask how and just do...
I didn't look up this technique, it occurred to me and I tried it. Since stretch!

Point - ~/.profile can execute stuff - check
Point - systemd has a facility to mount and dismount ad hoc on the cli - check
...and that's all there is to it!
Things did come together over the last few releases and it really wasn't complete until bookworm.
sunrat wrote: 2024-11-25 01:47 the normal way to mount a local disk with systemd would be to write a systemd .mount unit
Ya, normal sure, skip all that...systemd-mount on the command line will dynamically create and destroy the units that typical we would think of as persistent files describing the unit. Manually creating the units is necessary only if no user will be logging in. Those mounts happen seconds after boot. Simple question, do they need to?

If a user is going to log in then the ~/.profile invocation will happen a few seconds after the drives could have already been mounted...not pertaining to anything required by the system to get to the 'target', overall time to the desktop is unaffected. Actually the tmpfs mounts are much slower than the disk mounts, the request gets a pause as the host says - wait, you want what?..really, ok. The above vm:

Code: Select all

$  systemd-analyze
Startup finished in 4.270s (kernel) + 3.730s (userspace) = 8.001s 
graphical.target reached after 3.579s in userspace.
It's a lazy computer.

Your profile line @sunrat; if 'Music' is the label and you want it to swallow the whole directory '~/Music'

Code: Select all

systemd-mount --automount=yes --timeout-idle-sec=60 /dev/disk/by-label/Music ~/Music
I typically don't use the existing Music directory directly, but we can. I use a subdirectory for the mount point, ~/Music/.music
The ‘dot’ in ~/Music/.music in my scenario hides the mount from display as an automount device in the file manager, thunar, others may act different. A device for the mount may be displayed also, I hide that with udev. Those details are essentially to disable DE automagic that will not respect systemd's ad hoc ‘where’ - so will mount them if enabled in parallel in /mnt/user/label. We don't want that...but it shares fine if by accident.

Note that without a ‘where’ ad hoc cli systemd-mount will mount at /run/media/system/label. Why, I have no idea?

Better?
Mottainai

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5465
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 21 times
Been thanked: 93 times

Re: [Hardware] mounting of new drive

#19 Post by dilberts_left_nut »

@Best_Threads
AdrianTM wrote:There's no hacker in my grandma...

Post Reply