Linux CentOS 7 autofs does not mount network share after reboot - linux

Problem:
I have CentOS 7 Linux VM with cifs installed. I added a mount point using autofs where the whole idea was to automatically mount a network share every time VM boots. However, when I run this command:
ls /mnt/vmshare/trinity
I get
ls: cannot access /mnt/vmshare/trinity: No such file or directory
Workaround:
What I'm having to do is run this command after each reboot
/sbin/service autofs start
Then I can see the files in trinity.
Maybe autofs does not even start by default on reboot. How to make sure autofs starts on reboot? Or in general, how to solve my problem above?
Thanks so much!

for CentOS 7:
systemctl enable autofs
check with:
systemctl is-enabled autofs

I don't recall exactly what I used to figure this one out, but maybe it will get you on the right track.
I did some research on this a few years ago, and I believe the term you're looking for is "persistent mount."
You'll need to create or find the local mount point for your network directory. For instance, in mine.. /media/disco/disknamehere.../.../Share
This must be added to /etc/fstab with the correct options in place. Sorry I couldn't be more help.

Try to run
chkconfig autofs on
that will enable autofs service to start on boot.

Related

Docker container is not removable

What I have tried:
sudo service docker restart doesn't change the result
Exact containers behind are:
Suprised that sudo is still not enough
Working solution is to reboot system to kill dockers... But this is not a solution. Thanks in advance if anybody knows what to do with this

Snap-confine has elevated permissions and is not confined but should be. Is there a permanent fix?

lately I've been getting an error for some applications. They are not working as normally before. I think some system update caused this issue. I'm using ubuntu 22.04.
I've already check this: Snap-confine has elevated permissions and is not confined but should be. Refusing to continue to avoid permission escalation attacks
and Diego V's answer is working for me. However, it only works until system reboot, after system restart the problem is re-occurring, and I have to do the fix (with the cmds) every time after reboot. Is there a permanent fix for this problem ?
I was having the exact same issue (also on Ubuntu 22.04) and found that apparmor was inactive:
$ systemctl status apparmor
I enabled apparmor:
$ sudo systemctl enable apparmor
which starts appormor at boot (it does not start it in the current session: sudo systemctl start apparmor).
https://www.linuxcapable.com/how-to-enable-disable-apparmor-on-ubuntu-22-04-lts
I don't have rights to comment so I can only reply here that it remains an issu and like Null I seek an answer other than provided by Diego V, which works until reboot where apparmor is already enabled/running so doesn't require trekerj's answer.

Mount share folder on windows

I am trying to mount to a Windows share folder from RedHat Linux, I have below code in /etc/fstab
//TheWindowsIP/ShareFolder /LinuxPath/LinuxFolder cifs username=username,password=password,domain=windowsDomain,dir_mode=0777,file_mode=0777 0 0
When I run "mount -a" I got a "Resource temporarily unavailable" error, can someone tell me how can I solve this issue? Or maybe advise another way to access the window folder from RedHat Linux(cifs is driving me crazy)
OK, after the tremendous effort of searching and trying in different ways, turns out the only action I need to solve this problem is reboot. I guess, somehow, the content in /etc/fstab will be mount correctly when the Linux start, but cannot be mount properly when I run mount -a. Ahhh what can I say...

Install/Update cifs-utils before mount smb

I'm currently trying to get Vagrant to provision a working CentoOS7 image on Windows10, using Hyper-V. Vagrant 1.8.4, current latest.
I envcounter a problem where the provisioning fails and I need to workaround each time. The CentOS7 image is a minimal image and does not include cifs-utils, therefore the mount wont work. So, I need cifs-utils installed before mount.
Error:
==> default: Mounting SMB shared folders...
default: C:/Programs/vagrant_stuff/centos7 => /vagrant
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t cifs -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3`,sec=ntlm,credentials=/etc/smb_creds_4d99b2
d500a1bcb656d5a1c481a47191 //192.168.137.1/4d99b2d500a1bcb656d5a1c481a47191 /vagrant
mount -t cifs -o uid=`id -u vagrant`,gid=`id -g vagrant`,sec=ntlm,credentials=/etc/smb_creds_4d99b2d500a1bcb656d5a1c481a
47191 //192.168.137.1/4d99b2d500a1bcb656d5a1c481a47191 /vagrant
The error output from the last command was:
mount: wrong fs type, bad option, bad superblock on //192.168.137.1/4d99b2d500a1bcb656d5a1c481a47191,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so.
As it is now, the provisioning has to fail, and I need to:
vagrant ssh (powershell)
(connect to instance via putty/ssh)
sudo yum install cifs-utils -y (putty/ssh)
(wait for install...)
exit (putty/ssh)
vagrant reload --provision (powershell)
This is obviously a pain and I am trying to streamline the process.
Does anyone know a better way?
You can install the missing package in your box and repackage this box so you can distribute a new version of this box containing the missing package.
In order to provision a vagrant box you need to create it from an iso. While preparing the box you can install all needed packages for you. In your case it is Hyper-v - https://www.vagrantup.com/docs/hyperv/boxes.html
Best Regards
Apparently my original question was downvoted for some reason. #whatever
As I mentioned in one of the comments above:
I managed to repackage and upload an updated version. Thanks for the advice. Its available in Atlas as "KptnKMan/bluefhypervalphacentos7repack".
Special thanks to #frédéric-henri :)

Fail2Ban Will Not Start

I am running Centos 6.5 (Kernel Linux jspring 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux) and I was wondering if someone could assist - Im installing Fail2Ban through yum however when I go to run it I am getting the following error;
service fail2ban start
Starting fail2ban: ERROR Directory /var/run/fail2ban exists but not accessible for writing
[FAILED]
If anyone could advise me how to fix this that would be great.
Thanks!
There are several things that could be causing this.
First make sure the permissions and ownership are correct as the other answers state. The directory permissions should be drwxr-xr-x (a.k.a. 644) and it should be owned by root:root.
Now make sure you are attempting to run the start command with the proper authority. If service fail2ban start does not work, try sudo service fail2ban start. Using sudo is recommended but you could also switch to or login as the root user.
You may also want to reboot after you get it running and then run sudo service fail2ban status to make sure it successfully started up again.
You need to set the appropriate rights on the mentioned directory:
drwxr-xr-x root:root
You should set the permissions like this: chmod -R 644 /var/run/fail2ban/
As people have mentioned, this is clearly a permissions issue. I'm not sure if this applies to your version but fail2ban in 2018 has a client, run as:
sudo fail2ban-client start
(or restart or status). It must be run as sudo though.
As is documented in the official commands list here the command fail2ban start <jail> is clearly used to start jails and not to start fail2ban. So you completely missunderstood it's usage.
Try to first stop and then quickly start again the jail sshd that is enabled by default:
fail2ban-client stop sshd
fail2ban-client start sshd
Hey! It works!

Resources