Friday, September 21, 2018

Linux Error: Mount Point Doesn't Exists, Even Though Its There

You might encounter an error in Linux where one of the existing mount point or NFS share has abruptly gone (/mnt/orastore) and when you try to mount it, remount it, recreate the mount point directory or try to check current mounts from df command, you get some errors like below:

# df -kh
df: `/mnt/orastore': No such file or directory
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              30G   12G   17G  40% /
tmpfs                  32G  704M   31G   3% /dev/shm
/dev/mapper/oradata-oracle
                       99G   73G   21G  78% /oracle
/dev/mapper/data_al-archive
                      197G   17G  170G   9% /archivelogs
rmannfs:/bkp_util/production/PLNPRD/
                       42T   14T   28T  34% /backup
rmannfs:/bkp_util/testdev/migrationbkp/
                       47T   20T   28T  42% /mig_backups
/dev/sr0              225M  225M     0 100% /mnt
# df -kh /mnt/orastore
df: `/mnt/orastore': No such file or directory
df: no file systems processed
# umount /mnt/orastore
umount.nfs: /mnt/orastore: not found
umount.nfs: /mnt/orastore: not found
# mount /mnt/orastore
mount.nfs: mount point /mnt/orastore does not exist
# mkdir -p /mnt/orastore
mkdir: cannot create directory `/mnt/orastore': Read-only file system


To sum it up it seems all confusing but if you observe carefully, one of the other mounts has (/mnt) has been done which is hiding the required mount point (/mnt/orastore) to be used for filesystem mount.

A simple solution to above issue is either to unmount (/mnt) and original mount (/mnt/orastore) should become accessible (at least on a re-mount).

The original mount can also be placed somewhere else but since it hasn't been cleanly unmounted, its recommended to follow above solution rather than possible other workarounds.

Monday, September 10, 2018

How to disable SELINUX in RHEL/CentOS/OEL

Below steps covers completely disabling SELINUX on a RHEL or RHEL based OS.

Configure SELINUX=disabled in the /etc/selinux/config file as shown below:
 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.#       permissive - SELinux prints warnings instead of enforcing. 

#       disabled - No SELinux policy is loaded. 
SELINUX=disabled 
# SELINUXTYPE= can take one of these two values: 
#       targeted - Targeted processes are protected, 
#       mls - Multi Level Security protection. 
SELINUXTYPE=targeted 

Reboot your system. After reboot, confirm that the getenforce command returns Disabled:
# getenforce
Disabled

Sunday, September 9, 2018

How to use yum to download a package without installing it

Many a times it happens that we intend to just download RPMs from a repository to act as cache and plan to install it later, may be at scheduled maintenance downtime window. How do you achieve that using yum? Use the following method:

Install the package including "downloadonly" plugin, if you don't have it already:

(RHEL5)
# yum install yum-downloadonly

(RHEL6)
# yum install yum-plugin-downloadonly

Run yum command with "--downloadonly" option as follows:

# yum install --downloadonly --downloaddir=<directory> <package>

--downloaddir argument is optional and without it by default, yum downloads all RPM updates in /var/cache/yum/ in rhel-{arch}-channel/packages.Also you still need to re-download the repodata if the repodata expires before you re-use the cache. By default it takes two hours to expire.

As an alternatively you can also use "yumdownloader" available in "yum-utils" package as follows:


Install the yum-utils package:
# yum install yum-utils 

Run the command followed by the desired package:
# yumdownloader <package>

This works for packages already installed on system too. Also note that the package is saved in the current working directly by default; use the --destdir option to specify an alternate location and be sure to add --resolve if you need to download dependencies.
 

Tuesday, September 4, 2018

Find processes on run queue in Linux / Solaris

Ever encountered a high load average on a Linux box? Most likely reasons of having a high load average is a few processes queuing in CPU run queue. This can be seen from first two columns (r and b) from vmstat output.

# vmstat 5 5
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
67  0      0 552384 264792 12122244    0    0    25    62    5   16  2  1 97  0  0
66  0      0 538480 264848 12135348    0    0  1862  1233 3216 1167 97  3  0  0  0
67  1      0 490832 264912 12144252    0    0   998  1008 3578 1183 96  3  0  0  0
65  0      0 565148 265004 12150368    0    0   458  1228 3629 1357 96  4  0  0  0
64  1      0 522080 265132 12163624    0    0  1722   573 3776 1566 96  4  0  0  0
#


How do you find out which one? Use below commands:

ps -eo stat,pid,user,command | egrep "^STAT|^D|^R"

For Solaris use:

ps -aefL -o s -o user -o comm | egrep "^O|^R|COMMAND" 

Runnable processes have a status of "R", and commands waiting on I/O have a status of "D". On some older versions of Linux may require -emo instead of -eo.

Welcome to Linux/UNIX Tips Blog

Welcome reader!

This is the first article of Linux/UNIX Tips blog. Stick around and subscribe to get the latest news and updates from this blog. New articles discussing cool tips and tricks related to mostly Linux / UNIX OS will be published. I hope you'll enjoy these articles as well as be able to apply them in your daily use.

Thanks,
Abhishek