Pages

How to modify and repack an initrd image file

Create a temporary Directory 

#mkdir /root/initrd
#cd /root/initrd

Then uncompress and extract the initrd

#zcat /boot/initrd-2.6.18-164.6.1.el5.img | cpio -idmv

Modify the initrd and repack the intrd as new image

# find . | cpio -o -c | gzip -9 > /boot/test.img


For Redhat-7 use the below mentioned Procedure

Create a temporary Directory 

#mkdir /root/initrd
#cd /root/initrd

Then uncompress and extract the initrd

# xz -dc < initrd.img | cpio --quiet -i --make-directories

Modify the initrd and repack the intrd as new image

find . 2>/dev/null | cpio --quiet -c -o | xz -9 --format=lzma >"new-initrd.img"


How to Find Which Process is using Swap Space

To find which process is Using the swap space use the below Script to find the top 10 Process using Swap

----------------------------------------------------------------------------------------------------------------------------------------------------
ps ax | sed "s/^ *//" > /tmp/ps_ax.output
for x in $(grep Swap /proc/[1-9]*/smaps | grep -v '\W0 kB' | tr -s ' ' | cut -d' ' -f-2 | sort -t' ' -k2 -n | tr -d ' ' | tail -10); do
swapusage=$(echo $x | cut -d: -f3)
pid=$(echo $x | cut -d/ -f3)
procname=$(cat /tmp/ps_ax.output | grep ^$pid)
echo "============================"
echo "Process   : $procname"
echo "Swap usage: $swapusage kB"; done
-------------------------------------------------------------------------------------------------------------------------------------------------------

How to clear the buffer and pagecache

Run "sync" command first to flush pending data out to disk

# sync

To free pagecache

# echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes

# echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes

# echo 3 > /proc/sys/vm/drop_caches


How to start autofs in debug mode

To start autofs with the debug option. Configure the parameter as defined below depending on Redhat version to the configuration file /etc/sysconfig/autofs 

Red Hat Enterprise Linux 4

DAEMONOPTIONS="--debug"

Red Hat Enterprise Linux 5

LOGGING="debug"
or
DEFAULT_LOGGING="debug"

Red Hat Enterprise Linux 6

OPTIONS="--debug"

Restart Autofs

# /sbin/service autofs restart

How to increase number of open files limit in Linux

file-max ==> This is the number of concurrently open file descriptors allowed by the kernel. The default is 8192

.............................................
# vi /etc/sysctl.conf
  fs.file-max = XXXXX
.............................................

For applying above changes run

# sysctl -p

You can verify the current value of the max-open-files limit by


# cat /proc/sys/fs/file-max
or
# sysctl -a | grep fs.file-max