Disclaimer

These scripts come without warranty of any kind. Use them at your own risk. I assume no liability for the accuracy, correctness, completeness, or usefulness of any information provided by this site nor for any sort of damages using these scripts may cause.
Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, September 1, 2023

NFS not mounting on Linux

 NFS not mounting

================

Seen below messages in /var/log/messages

Sep  1 08:57:45 server-app1 systemd[1]: u01.mount: Unit is bound to inactive unit dev-oracleoci-oraclevdb1.device. Stopping, too.

Sep  1 08:57:45 server-app1 systemd[1]: Unmounting /u01...

Sep  1 08:57:45 server-app1 nfsrahead[8179]: setting /u01 readahead to 128

Sep  1 08:57:45 server-app1 systemd[1]: u01.mount: Succeeded.

Sep  1 08:57:45 server-app1 systemd[1]: Unmounted /u01.

 

Change:

Created a new compute instance from a custom image which already has the mountpoint reference in fstab which we are trying to use (u01)

 

Solution:

-----------

After altering fstab, systemd need to reparse /etc/fstab and pick up the changes or else the mount point will be unmounted automatically by systemd.

Correct the entry in the /etc/fstab . Make sure that required mount point entry is fstab and unwanted is reqmoved.

Also, make sure to unmount if same nfs export is mounted in other mount point on this server

 

Reload systemctl or reboot the server to avoid this issue.

 

# systemctl daemon-reload

 

We have executed systemctl daemon-reload command and ran mount -a

Issue solved.

Monday, November 27, 2017

How to move files from one directory to another using find and xargs command



find - search for files in a directory hierarchy
xargs - build and execute command lines from standard input

Using find and xargs we can search any file in the directory hiearchy and xargs execute the command accepting the output of find command as input.

Use xargs with -I option to replace occurrences of replace-str in the initial-arguments with names read from standard input(In our case from find command). The placeholder following the -I is a string that can appear multiple times in the command.

Example: Below command will find all files with pattern *.txt in current directory and move to /NewDir/.

find . -name "*.txt" | xargs -I '{}' mv '{}' /NewDir/'{}'


Here '{}' is placeholder



Sunday, September 11, 2016

Command Equivalent to "grep" in Windows

grep in Linux/Unix, find in Windows


Many times you might have wondering what is the command available in Windows which is  equivalent for "grep" in Linux/Unix. You can use findstr command in Windows

grep
The grep command in Linux/Unix is one of the most used command.  This is used for searching patterns in text.  grep process text line by line and prints any line that matching the specified pattern. Regular Expressions can be used searching.

grep can be used in many scenarios.

Examples: Search for a file Starting with "XX" in a directory

$ ls | grep XX

List all files except file Starting with "XX" in a directory

$ ls  | grep -v XX

Search for pattern in a file and list file names and lines

$ grep 187 *

Windows - findstr

findstr command in Windows can be used for similar purpose. Now let us see how above scenarios can  be achieved using findstr command.

Examples: Search for a file Starting with "XX" in a directory

c:\ dir | findstr "XX"

List all files except file Starting with "XX" in a directory

c:\ dir | findstr /v "XX"

Search for pattern in a file and list file names and lines


c:\ findstr "Internal" *

There are more parameters that can be used in combination to get the output.

Friday, December 2, 2011

Steps to add/increase the swap partition on Linux (Using Logical Volume).

In certain situations you may need to increase the swap space on your linux server. For example, installing new version of Oracle on an existing linux server.

Linux has two types of swap space:
1) The swap partition. The swap partition is an independent section of the hard disk used solely for swapping; no other files can exist there.

2) The swap file.  The swap file is a special file in the filesystem that exists with your other files.
Below steps are showing how to increase space swap space by adding another swap partition using logical volume.

All these steps has to be done as root user.

1. Create a logical volume
   
    Pre-req: Enough free space must be available on volume group.


 a) open logical volume manager using system-config-lvm
 b) Click on logical view
 c) Click on "Create New Logical Volum Button"
 d) Give the LV name like "swap2"
 e) Specify the size required in GBs
 f) Keep all other values unchanged and click OK to create volume
 g) Note down the new logical volume full path (ex: /dev/vgdata/swap2) from voluem properties and close the GUI.


2. Format the newly created volume with swap file system

   a) # mkswap </full/path to/new volume>
   ex: mkswap /dev/vgdata/swap2


3. Activate the new swap
     a) # swapon </full/path to/new volume>
  ex: swapon /dev/vgdata/swap2


4. Add the following line to fstab to persist swap configuration after re-boot.
   </full/path to/new volume> swap swap defaults 0 0
 ex: /dev/vgdata/swap2 swap swap defaults 0 0

5. verify the swap
  
a) free -m
 b) cat /proc/swaps