Jan 20, 2017

Restore linux server in as is state from restricted mode

Issue: Recently I faced ..
After rebooting server, GUI window not coming. Server only able to start in restrict mode. NAS storage is attached to server. What could be the reason? How it will be fixed and server can be started in good condition again?

Ans:
I did below workaround to fix the issue.


-- before reboot server ( for NAS connected)

step-1: umount NAS connected vg
step-2: coment same in /etc/fstab

-- If rebooted forcefully

Step-1: Start the server in maintenance mode

Step-2: Convert the filesystems in R/W mode

# mount -o remount, rw /

Step-3: scan lv and vg, It will show you as "inactive"

# lvscan
  inactive          '/dev/oradev/datalv' [299.00 GiB] inherit
  inactive          '/dev/orasit/datasitlv' [299.00 GiB] inherit
[root@DEVDB02 sysconfig]#

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              25G  7.8G   16G  34% /
tmpfs                 5.8G  100K  5.8G   1% /dev/shm
/dev/sda1             504M   60M  420M  13% /boot
/dev/sda5             9.9G  151M  9.2G   2% /home
/dev/sda6             5.0G  148M  4.6G   4% /tmp
# cd

# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "oradev" using metadata type lvm2
  Found volume group "orasit" using metadata type lvm2
#


Step-4 : Activate vg

# vgchange -a y oradev
  1 logical volume(s) in volume group "oradev" now active

# vgchange -a y orasit
  1 logical volume(s) in volume group "orasit" now active
#

Step-5 : check now

# lvscan
  ACTIVE            '/dev/oradev/datalv' [299.00 GiB] inherit
  ACTIVE            '/dev/orasit/datasitlv' [299.00 GiB] inherit
#

# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "oradev" using metadata type lvm2
  Found volume group "orasit" using metadata type lvm2

Step-6 : Uncomment in /etc/fstab

# vi /etc/fstab
..
/dev/oradev/datalv              /u01            ext4    defaults        1 2
/dev/orasit/datasitlv           /u02            ext4    defaults        1 2

:wq!

Step-7 : Mount now
#
# mount /u01
# mount /u02

Step-8 : Check mount points now

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              25G  7.8G   16G  34% /
tmpfs                 5.8G  100K  5.8G   1% /dev/shm
/dev/sda1             504M   60M  420M  13% /boot
/dev/sda5             9.9G  151M  9.2G   2% /home
/dev/sda6             5.0G  148M  4.6G   4% /tmp
/dev/mapper/oradev-datalv
                      295G  191M  280G   1% /u01
/dev/mapper/orasit-datasitlv
                      295G  191M  280G   1% /u02
#



Additional Knowledge - Change hostname in Linux:

1) Add/Edit hostname in /etc/hosts

e.g.,

# vi /etc/hosts

10.20.30.40     myhost

:wq!

2) Edit network file from /etc/sysconfig/

# cd /etc/sysconfig/
vi network
NETWORKING=YES
HOSTNAME=myhost

:wq!

3) Apply the hostname

# hostname myhost



Jan 12, 2017

Edit Swap size in linux - dynamically

-- To increase swap file in existing system

Cuurent swap size :
# free -g
             total       used       free     shared    buffers     cached
Mem:             7          0          6          0          0          0
-/+ buffers/cache:          0          7
Swap:            3          0          3

i.e., Avaialble is : 3G

Pre-requisites : Required space must be available in / ( root)

-- Add swap file

# dd if=/dev/zero of=/swapfile bs=1024 count=16777216
16777216+0 records in
16777216+0 records out
17179869184 bytes (17 GB) copied, 124.992 s, 137 MB/s
[root@dr1-oracle /]# 

Calculation:
bs : block size ( 1024)
count : Required value to add ( e.g., to increase 16GB, 16x1024x1024=16777216)

But, As per Oracle recommendation use 16G swap memory. So add 13GB in this scenario.

-- To setup swap

# mkswap /swapfile 
mkswap: /swapfile: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 16777212 KiB
no label, UUID=a02686f1-3c9b-46f7-bebc-cc839adfcc2e

-- To Enable swap file immediatly

# swapon /swapfile

-- Check swap size now

# free -g
             total       used       free     shared    buffers     cached
Mem:             7          7          0          0          0          6
-/+ buffers/cache:          0          6
Swap:           19          0         19


-- Add in fstab to make permanent

# vi /etc/fstab

/swapfile swap swap defaults 0 0


==================
To remove swap file
==================

# swapoff /swapfile
# rm /swapfile

Translate >>