How to mount and unmount a storage without reboot?

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
863
Reaction score
714
Credits
5,825
I have a storage which I've dedicated it to be for backup of files. It's written in fstab but even if I remove the # from its line, its contents won't appear.
I've heard there's a way to mount and unmount a storage whenever you need it (or not need it) with the mount point from fstab without having to reboot the PC but I can't find anything in Google or I'm probably asking it the wrong way.

I know gnome-disks can mount it but in this case I prefer a terminal command.

Any suggestions?
 


mount /mnt/point

cd /someplace/besides/the/mount/point

umount /mnt/point
 
I have a storage which I've dedicated it to be for backup of files. It's written in fstab but even if I remove the # from its line, its contents won't appear.
I've heard there's a way to mount and unmount a storage whenever you need it (or not need it) with the mount point from fstab without having to reboot the PC but I can't find anything in Google or I'm probably asking it the wrong way.

I know gnome-disks can mount it but in this case I prefer a terminal command.

Any suggestions?
It may be useful if the relevant line in the /etc/fstab file is shown here so readers can get a better handle on it.

In the past here it was the use of the mount options "noauto" and "user" in the mount options field in the configuration that enabled the external drive to be mounted by a user at will without the drive being mounted at boot.

For example, in the case of an external cdrom drive the line looked like so:
Code:
/dev/sr0   /media/cdrom0   udf,iso9660   user,noauto   0 0
That configuration enabled the cdrom to be mounted by any user with the command:
Code:
mount /dev/sr0
The noauto option meant the drive would not be mounted at boot, but had to be called by command whereupon it would be mounted at /media/cdrom which was a directory that had to exist.

In the case of an external hard drive, one of which I don't have at the moment, the UUID of the drive may have been used for its device name in the first field, and the filesystem was ext4, and, if I recall correctly, the "rw" option was also there. There may have been other mount options, but I can't recall precisely.

EDIT: Now thinking about it again, there was a slight complication because of the kernel's tendency to name drives in unpredictable ways, so sometimes one drive was /dev/sda one day, but /dev/sdb another, so I always checked with the command: lsblk, to see which drive had which name so I could use the right /dev name to call it.
 
Last edited:
I have a storage which I've dedicated it to be for backup of files. It's written in fstab but even if I remove the # from its line, its contents won't appear.
I've heard there's a way to mount and unmount a storage whenever you need it (or not need it) with the mount point from fstab without having to reboot the PC but I can't find anything in Google or I'm probably asking it the wrong way.

I know gnome-disks can mount it but in this case I prefer a terminal command.

Any suggestions?
you can use GParted on linux and unmount the disk u stored your data and later mount it back and get the backup
 
If you specify user in /etc/fstab the any user may mount the drive, but only the user that mounted it may unmount it. If you use users instead then any user may mount it and then any user may unmount it, provided nothing on it is being used at the time. If someone or a running program has a current working directory in that space the user will get the device is busy error.

It's generally best to leave system administration to root and let root mount and unmount file systems.

You don't need a file system to be listed in /etc/fstab in order to mount it. This file is a guide used by mount, but you can directly tell mount what you want it to do. Peruse the list of options in the man page, which start on page 497 on my system, to see which ones you want to use.

If the file system is used for backups and nothing should be run from it then I would suggest using the nodev and noexec options when mounting it..

Signed,

Matthew Campbell
 
It may be useful if the relevant line in the /etc/fstab file is shown here so readers can get a better handle on it.

Code:
UUID="b46ea985-8f41-4d24-a4e0-e4f705a96fa9" /BACKUP xfs defaults,relatime,discard,auto 0 0
 
Don't forget that if you manage to mount a disk without booting the server, the mount may disappear after a boot, depending on how you set it up.
 
UUID="b46ea985-8f41-4d24-a4e0-e4f705a96fa9" /BACKUP xfs /BACKUP xfs defaults,relatime,discard,auto 0 0
To automount you should lose quotation marks:
UUID=b46ea985-8f41-4d24-a4e0-e4f705a96fa9 /BACKUP xfs /BACKUP xfs defaults,relatime,discard,auto 0 0

Note added later:
if you want to be able to mount unmound on demand:
UUID=b46ea985-8f41-4d24-a4e0-e4f705a96fa9 /BACKUP xfs /BACKUP xfs noauto,defaults,relatime,discard 0 0
then use
sudo mount /BACKUP
sudo umount /BACKUP

in fact for manual mount unmount you don't need this entry in /etc/fstab. This is just a convenience. Reboot never was/is needed
 
Last edited:

Members online


Top