Linux remount all fstab

Quick way to restore or reload /etc/fstab settings?

I’m working with a complex /etc/fstab on a RHEL 6.x-based server. The system has a variety of mount options in use across eight partitions, including several bind mounts. I’m testing options and their effect on the image I’m working on. e.g. options like nodev , nosuid , noexec , nobarrier and several XFS filesystem parameters are in place. While I know it’s possible to remount with specific options, is there a quick way to revert all mounts to the persistent settings hardcoded in /etc/fstab ? For instance sysctl -p loads the /etc/sysctl.conf values and applies them. Is there a mount equivalent? Edit: An example config:

# # /etc/fstab # UUID=e6ca80cd / ext4 noatime,nobarrier 1 1 UUID=a327d315 /boot ext4 defaults 1 2 UUID=333ada18 /home ext4 noatime,nobarrier,nodev 1 2 UUID=7835718b /tmp ext4 nodev,nosuid,noexec 1 2 UUID=4dd2e9d4 /usr ext4 defaults 1 2 UUID=c274f65f /var ext4 noatime,nobarrier 1 2 UUID=5b5941e0 /var/log ext4 defaults 1 2 UUID=3645951a /var/log/audit ext4 defaults 1 2 UUID=3213123c /vol1 xfs noatime,logbufs=8,nobarrier 1 2 UUID=1ee1c070 swap swap defaults 0 0 # Bind mount for /tmp /tmp /var/tmp none bind 0 0 tmpfs /dev/shm tmpfs nodev,nosuid,noexec 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 

Of course, a developer asks for execute permissions on /tmp in order to install an application. I’m finding that the remount option does not work on this system without specifying the device and (re)mountpoint. This is a security-hardened server, so the issues I’m seeing may be SElinux-related or a result of the bind mounts, or maybe even the presence of negated options (noexec versus exec).

Источник

HowTo: Remount /etc/fstab Without Reboot in Linux

The configuration file /etc/fstab contains the necessary information to automate the process of mounting partitions.

You would normally have to reboot your Linux system, after editing this file.

There is a simple way which will remount all the partitions from your /etc/fstab file without restarting the system.

Run the following command as root:

This simple command causes all filesystems mentioned in /etc/fstab to be remounted, except the partitions with noauto option.

10 Replies to “HowTo: Remount /etc/fstab Without Reboot in Linux”

So if I change what is mounted on /mnt/myshare , and execute mount -a, it will unmount was there, and mount what I changed it to? it //server/share1 /mnt/share
I change it to //server/share2 /mnt/share
then execute mount -a
//server/share2 will be mounted on /mnt/share ?

mount: /mnt/$PATH_I_CHOSE: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount. helper program. I think this method needs some updating…

which method? “mount -a”? It works flawlessly for me in Debian 10.5 and LMDE 4, so Im not sure if it really needs an update. In the past, I have gotten the “mount: /mnt/$PATH_I_CHOSE: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount. helper program.” error, mainly when I tried to mount an nfs share with no ‘nfs-common’ installed on my client computer.

Doesn’t seem to be working for me on Gentoo. I have a tmpfs mounted @ /var/tmp/portage and wanted to change the size. It doesn’t seem to be happening after running mount -a

Читайте также:  Остановить выполнение команды linux

You are a saint! This is also really useful if you have an NFS mount that timed out at boot, so it did not mount, but is now available. Thanks!

Hi, is it possible to define an env var in /etc/profile, such as:
export RAMDISK=/home/pi/myvirtualdisk and have that var be included in fstab as follows?
tmpfs $RAMDISK tmpfs nodev,nosuid,size=1500M 0 0 In this way I can easily change location of my ram disk. Thanks!

Источник

Introduction to fstab

RocketShipIt - Shipping made easy

The fstab is one of the first configuration files new Linux users get their hands on. Fstab stands for File System Table. It is basically a config file that will tell your computer which devices (or virtual devices) to use on boot.

The Fstab

In almost all distributions the fstab file is located in ‘/etc/fstab/’. You can open it up with your favorite editor:

Syntax

File System

The first one, file system revers the block device:

Dir

This will be the directory where the device will be mounted to. In other words this will be the directory you will need to access in order to view the contents of the device. The general rule of thumb is that physical internal mounts are stored in /mnt and removable media is stored in /media.

Type

The type specifies which type of file system you are trying to mount.

  • ext3 — Linux FS
  • ext4 — Version 4 of ext
  • auto — Usually used for CD-ROM mounts
  • ntfs-3g — NTFS (Windows)
  • cifs — Windows file sharing
  • nfs — Linux file sharing

To see all the file systems you have currently supported, do:

Options

This section is where you specify file system specific options.

Dump

This field is used for file systems that use the dump command. A zero here will mean that the file system does not need to be “dumped”. Dump is a utility that will do a backup on the file system. Usually this value is set to zero.

Pass

Pass is the fsck (file system check) order. There are only 3 valid options here.

  • 0 — do not check.
  • 1 — check this partition first.
  • 2 — check this partition(s) next

Usually you set your root partition to be checked first with ‘1’ and set all other partitions to ‘2’.

If you want to disable file system checking all together on the device use a ‘0’. This is commonly done on network shares and remote file systems.

Remount Everything in Fstab

It is common to want to update the system after you have made changes to the fstab config without having to reboot the computer.

To remount everything in fstab without restarting do:

Mount by UUID

You can run into problems when mounting removable devices using the ‘/dev/sdb1’ style. This style of pointing to devices depends on the order in which they are detected in boot which can change depending on if you add or change a hard drive or plug multiple USB devices in. For this reason I have been mounting all of my devices with the UUID instead.

Using the UUID of the hard drive we can mount the same drive no matter which order it comes up in boot or when it is detected. The UUID is a unique identifier for that particular drive. Linux will make no mistake when it comes to mounting file systems that are mapped by their UUID in fstab.

Читайте также:  Create run file linux

For example:

UUID=18EC910AEAEA90D084 /mnt/someDrive ntfs-3g defaults,user 0 1 

This drive will always be mounted at the mount point ‘/mnt/someDrive’ even if we add or remove one of the other drives in the system.

To get the UUID of a drive first find traditional unix stlye map with:

This will give you a list of drives with some good identifying material, such as file system type and disk size. Look for the section that starts with ‘/dev/’ and remember what it says. For example mine says, ‘/dev/sdd1’.

This will print out all the UUIDs for each device.

Mounting NFS Shares

Here is an example of mounting an NFS share.

192.168.1.X:/media/sharename /media/sharename nfs rsize=8192,wsize=8192 0 0 

Mounting Samba (Windows) Shares

Many systems are in a network with other operating systems. In order to communicate with Windows shares you will need to use cifs or smbfs.

//192.168.1.X/sharename /media/sharename cifs rw,user,username=username,password=password 0 0 

Inevitably you are going to run across a Windows share that has a space in its name. Be sure to read: Mounting a Samba Share that has Spaces to find out how to work around the problem.

Mounting NTFS Shares

In order to mount NTFS (Windows) drives in Linux you will need to get the ntfs-3g driver. Which is the third generation of NTFS drivers. Ntfs-3g supports reading and writing to NTFS drives where older NTFS drivers only support reading.

UUID=18EC910AEAEA90D084 /mnt/someDrive ntfs-3g defaults,user 0 1 

You might also want to check out Setting up sshfs. To mount directories over the secure protocol, SSH.

Источник

(Re)mount all network drives from fstab

I would prefer a maintained 3rd party solution over a one-line shell hack.

Thanks, that’s indeed a good answer. I just found out that the -t option to mount can be used in conjunction with -a , such that sudo mount -a -t cifs does what I need.

How should I proceed with this question? While you were giving the answer in your comment, I was wondering whether I should answer myself? Should you give an official «answer» that I can accept? Should I delete the question?

Feel free to post your own answer. That is both allowed and encouraged on the stack exchange network. I have also posted mine but that does not mean you should feel pressured to accept it if it’s not the approach you prefer. You are, of course, welcome to accept it if that’s what you want 😉

2 Answers 2

You’re looking for the -t flag for mount . From man mount :

 -t, --types vfstype [. ] More than one type may be specified in a comma separated list. The list of filesystem types can be prefixed with no to specify the filesystem types on which no action should be taken. (This can be meaningful with the -a option.) For example, the command: mount -a -t nomsdos,ext 

So, this command would mount all cifs filesystems:

I don’t understand why -O should be better in general, since it depends on some option to be set in the network filesystems. In fact, it does not work for me (while -t does), since it does not match the fstype column.

Читайте также:  Файловая система под линукс

It seems like every question that asks how to do something with fstab is answered with «use mount», and every question about using mount says to use fstab. People, sometimes these questions are here for a reason. If I am mounting a network drive with fstab, it is probably because the mount command requires root, and that even if you use sudo, the mounted folders are then OWNED by root and therefore are read only by all commands that are not also executed with sudo.

@Nuzzolilo, the OP was asking for a quick, manual way of mounting all network mounts from fstab . Of course the answer was mount , what else would it be? If you have a different question, please ask it instead of complaining about how the answers to somebody else’s question don’t answer yours. Also, there’s no reason why root should own the mounted directories, nor why they should be read only. Have a look at the mount man page.

@terdon How would I know what it should be? And since you asked, yes I have been asking my own questions, feel free to answer them if you think you can swing it.

Источник

How to force OS reload of fstab?

I suspect this is caused by systemd’s conversion of /etc/fstab ; traditional mount doesn’t remember the contents of /etc/fstab .

To refresh systemd’s view of the world, including changes to /etc/fstab , run

Sigh. An auto-generated comment in the top of /etc/fstab reminding/advising people it has now been deprecated — and how to update systemd — would go a long way.

Thanks! You can imagine Google returned nothing but ‘mount -a’ hits for this query. Are there any unwanted side-effects when doing this on-the-fly re-gen of the tables? Doesn’t seem to be.

For more, see unix.stackexchange.com/a/236968/5132 and unix.stackexchange.com/questions/90723 . Note that the Debian service that used to run mount -a is nowadays masked.

To elaborate the answer from @Stephen Kitt: for example I have this entry in /etc/fstab :

vnetsvr-home:/etc/skel /etc/skel nfs4 sec=krb5p,noauto,x-systemd.automount,x-systemd.idle-timeout=10min 0 0 

and only doing sudo systemctl daemon-reload doesn’t reloaded the fstab. I have to do:

rpi ~$ sudo systemctl daemon-reload rpi ~$ sudo systemctl restart remote-fs.target 

To reload an entry to mount a local filesystem you should use:

rpi ~$ sudo systemctl daemon-reload rpi ~$ sudo systemctl restart local-fs.target 

I know that these solutions might not work in every linux distro and version. However this method would generally works for all Linux versions.
1- Do your configuration and change the fstab file
2- Use this command to remount the device_file you have changed its configuration in the fstab file:
# mount -o remount [device_file]
This way you will mount the partition with its new configuration read from «fstab» file.
If you removed a partition from «fstab» file, simply umount [device_file] . Be sure, the partition stays unmounted after the reboot.

Any time you can check the result by running mount command.

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Источник

Оцените статью
Adblock
detector