Tuesday, May 6, 2014

Faking problem with a smile

Are we really living life
Or it's just faking it, 

Driving car means proud for some one, 
But with speeding car it's easy to kill person, 
Breaking rules on road is easier but following the same is difficult one. 

It's hurry in us or we don't have faith on our selves,
It's anger in us or we don't have love to love ourselves, 
It's frustration in us or we can't find a space in us to sit calmly. 

It's not about rich or poor, both are running for money, the way differs. 
We all are faking our lives, but only the way differs,

If yes we are faking our lives than atleast we should fake with smile to it,
Fake life difficulties and tension with Opposite of frustration that is quite mind, 
With Opposite of anger that is love. 
Opposite of sadness that is being happy. Push problems with love 
Pull love with love only....... 



Love sharing 
Amit chopra 








Thursday, May 1, 2014

drm: module has bad taint, not creating trace events

Hi Friends,

I am running my Linux Machine with kernel version 3.14.1, and facing below message at system shutdown or restart.

drm: module has bad taint, not creating trace events



Please help..


Love Sharing
Amit Chopra
 

Friday, April 25, 2014

fsadm, lvresize, resize2fs command usage Red Hat Linux

Hi Friends,

I never like reducing the File system in Redhat Linux or Linux. As it needs un-mounting of the file system. That most of the time is very tidy and asking downtime for it doesn't look good to me. Where increasing file system size can be done online.

Learned about a "FSADM" utility in HP UNIX 11i V3 that comes with Online JFS. which allows to reduce the file system size in Hp Unix online that is without un-mounting a file system. That removes the headache of downtime. Searching for the same kind in RedHat Linux found fsadm and learned about it, tried the same and thought to share with all.

Below are the steps including creation, extension and reduction of the size of an Logical Volume {LV named as Test in VG named as VolGroup}.

Creating an LV of 500 MB size naming as  test in VG VolGroup.



[root@localhost /]# lvcreate -L 500M -n test VolGroup
  WARNING: Failed to connect to lvmetad: No such file or directory. Falling back to internal scanning.
  Logical volume "test" created


for me lvmetd message was coming due to lvmetd daemon and cfdisk which worked for recovery of  external USB for me. It helped me in saving my data on USB. so for now please ignore above warning, It happened in my case only.

Command "lvs"showing the output of the available LV. it shows to which Volume Group an LV belongs and of what size.




[root@localhost /]# lvs
  WARNING: Failed to connect to lvmetad: No such file or directory. Falling back to internal scanning.
  LV      VG       Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_home VolGroup -wi-ao--- 100.10g                                             
  lv_root VolGroup -wi-ao---  50.00g                                            
  lv_swap VolGroup -wi-ao---   3.91g                                            
  test    VolGroup -wi-a---- 500.00m                                             
[root@localhost /]#
[root@localhost /]# mkf
mkfifo        mkfontscale   mkfs.cramfs   mkfs.ext3     mkfs.ext4dev  mkfs.msdos   
mkfontdir     mkfs          mkfs.ext2     mkfs.ext4     mkfs.gfs2     mkfs.vfat    
[root@localhost /]# mkfs.ext4
mkfs.ext4     mkfs.ext4dev 
[root@localhost /]# mkfs.ext4 /dev/mapper/VolGroup-
VolGroup-lv_home  VolGroup-lv_root  VolGroup-lv_swap  VolGroup-test    
[root@localhost /]# mkfs.ext4 /dev/mapper/VolGroup-test
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
128016 inodes, 512000 blocks
25600 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
63 block groups
8192 blocks per group, 8192 fragments per group
2032 inodes per group
Superblock backups stored on blocks:
      8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done                           
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost /]# 
above created a EXT4 file system using mkfst.ext4 command. 

[root@localhost /]# mount /dev/mapper/VolGroup-test /test1/
[root@localhost /]#
[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   12G   36G  24% /
tmpfs                 926M  224K  926M   1% /dev/shm
/dev/sda1             477M   56M  393M  13% /boot
/dev/mapper/VolGroup-lv_home
                       99G   38G   56G  41% /home
/dev/mapper/VolGroup-test
                      477M  2.3M  445M   1% /test1
[root@localhost /]#
[root@localhost /]#
[root@localhost /]#
[root@localhost /]# pwd
/
[root@localhost /]# man fsadm
[root@localhost /]#
[root@localhost /]# fsadm -e -y /dev/mapper/VolGroup-test 1000M
fsadm: Wrong argument "/dev/mapper/VolGroup-test". (see: fsadm --help)
[root@localhost /]# man fsadm
[root@localhost /]# 
Here I tried with increasing the test file system size online using fsadm to 1000MB size. It failed. 
[root@localhost /]# fsadm -e -y resize /dev/mapper/VolGroup-test 1000M
Do you want to unmount "/test1"? [Y|n] y
fsck from util-linux-ng 2.17.2
/dev/mapper/VolGroup-test: 11/128016 files (0.0% non-contiguous), 26666/512000 blocks
resize2fs 1.41.12 (17-May-2010)
The containing partition (or device) is only 512000 (1k) blocks.
You requested a new size of 1024000 blocks.

fsadm: Resize ext4 failed

[root@localhost /]# fsadm -e -y resize /dev/mapper/VolGroup-test 400M
Do you want to unmount "/test1"? [Y|n] y
fsck from util-linux-ng 2.17.2
/dev/mapper/VolGroup-test: 11/128016 files (0.0% non-contiguous), 26666/512000 blocks
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-test to 409600 (1k) blocks.
The filesystem on /dev/mapper/VolGroup-test is now 409600 blocks long.

[root@localhost /]# 
It allowed reduction within the size given to it at the time of creation. Lets see can we increase the size back to 500MB with this command or not.
[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   12G   36G  24% /
tmpfs                 926M  224K  926M   1% /dev/shm
/dev/sda1             477M   56M  393M  13% /boot
/dev/mapper/VolGroup-lv_home
                       99G   38G   56G  41% /home
/dev/mapper/VolGroup-test
                      380M  2.3M  354M   1% /test1

[root@localhost /]#
[root@localhost /]#
[root@localhost /]# fsadm -e -y resize /dev/mapper/VolGroup-test 500M
Do you want to unmount "/test1"? [Y|n] y
fsck from util-linux-ng 2.17.2
/dev/mapper/VolGroup-test: 11/101600 files (0.0% non-contiguous), 23338/409600 blocks
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-test to 512000 (1k) blocks.
The filesystem on /dev/mapper/VolGroup-test is now 512000 blocks long.

[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   12G   36G  24% /
tmpfs                 926M  224K  926M   1% /dev/shm
/dev/sda1             477M   56M  393M  13% /boot
/dev/mapper/VolGroup-lv_home
                       99G   38G   56G  41% /home
/dev/mapper/VolGroup-test
                      477M  2.3M  445M   1% /test1
[root@localhost /]#

[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   12G   36G  24% /
tmpfs                 926M  224K  926M   1% /dev/shm
/dev/sda1             477M   56M  393M  13% /boot
/dev/mapper/VolGroup-lv_home
                       99G   38G   56G  41% /home
/dev/mapper/VolGroup-test
                      477M  2.3M  445M   1% /test1
[root@localhost /]#
[root@localhost /]# 
As seen above the file system size increase without using lvextend command and resize2fs command, but it did it to the limits of 500MB only, which we have given to it at the time of creation. 
Now Back to old method of extending the Logical Volume using lvextend command. 

[root@localhost /]# lvextend -L +500M /dev/mapper/VolGroup-test
  WARNING: Failed to connect to lvmetad: No such file or directory. Falling back to internal scanning.
  Extending logical volume test to 1000.00 MiB
  Logical volume test successfully resized
[root@localhost /]#
[root@localhost /]#
[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   12G   36G  24% /
tmpfs                 926M  224K  926M   1% /dev/shm
/dev/sda1             477M   56M  393M  13% /boot
/dev/mapper/VolGroup-lv_home
                       99G   38G   56G  41% /home
/dev/mapper/VolGroup-test
                      477M  2.3M  445M   1% /test1
[root@localhost /]#
The size after extending through LVEXTEND command will not be visible until we resize the file system, where this was not in the case of fsadm command shown above.
[root@localhost /]# resize
resize2fs   resizecons 
[root@localhost /]# man resizecons
[root@localhost /]#
[root@localhost /]# resize2fs /dev/mapper/VolGroup-test
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-test is mounted on /test1; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 4
Performing an on-line resize of /dev/mapper/VolGroup-test to 1024000 (1k) blocks.
The filesystem on /dev/mapper/VolGroup-test is now 1024000 blocks long.

[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   12G   36G  24% /
tmpfs                 926M  224K  926M   1% /dev/shm
/dev/sda1             477M   56M  393M  13% /boot
/dev/mapper/VolGroup-lv_home
                       99G   38G   56G  41% /home
/dev/mapper/VolGroup-test
                      961M  2.5M  910M   1% /test1

[root@localhost /]# 
Size Increased.
[root@localhost /]# fsadm -y resize /dev/mapper/VolGroup-test 800M
Do you want to unmount "/test1"? [Y|n] y
fsck from util-linux-ng 2.17.2
/dev/mapper/VolGroup-test: 11/254000 files (0.0% non-contiguous), 42797/1024000 blocks
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-test to 819200 (1k) blocks.
The filesystem on /dev/mapper/VolGroup-test is now 819200 blocks long.

[root@localhost /]# 
Now we have reduced the size of 1000MB extended above using lvextend and resize2fs with fsadm command to size 800MB. 

[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   12G   36G  24% /
tmpfs                 926M  224K  926M   1% /dev/shm
/dev/sda1             477M   56M  393M  13% /boot
/dev/mapper/VolGroup-lv_home
                       99G   38G   56G  41% /home
/dev/mapper/VolGroup-test
                      767M  2.5M  725M   1% /test1
[root@localhost /]# man fsadm
[root@localhost /]#
[root@localhost /]# e2fsck /dev/mapper/VolGroup-test
e2fsck 1.41.12 (17-May-2010)
/dev/mapper/VolGroup-test is mounted.
e2fsck: Cannot continue, aborting.



[root@localhost /]# resize2fs /dev/mapper/VolGroup-test 700M
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-test is mounted on /test1; on-line resizing required
On-line shrinking from 819200 to 716800 not supported.

[root@localhost /]#
[root@localhost /]# lvre
lvreduce  lvremove  lvrename  lvresize 
[root@localhost /]# lvresize -L +2G /dev/mapper/VolGroup-test
  WARNING: Failed to connect to lvmetad: No such file or directory. Falling back to internal scanning.
  Extending logical volume test to 2.98 GiB
  Logical volume test successfully resized

[root@localhost /]#
[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   12G   36G  24% /
tmpfs                 926M  224K  926M   1% /dev/shm
/dev/sda1             477M   56M  393M  13% /boot
/dev/mapper/VolGroup-lv_home
                       99G   38G   56G  41% /home
/dev/mapper/VolGroup-test
                      767M  2.5M  725M   1% /test1
[root@localhost /]# resize2fs /dev/mapper/VolGroup-test
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-test is mounted on /test1; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 12
Performing an on-line resize of /dev/mapper/VolGroup-test to 3121152 (1k) blocks.
The filesystem on /dev/mapper/VolGroup-test is now 3121152 blocks long.

[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   12G   36G  24% /
tmpfs                 926M  224K  926M   1% /dev/shm
/dev/sda1             477M   56M  393M  13% /boot
/dev/mapper/VolGroup-lv_home
                       99G   38G   56G  41% /home
/dev/mapper/VolGroup-test
                      2.9G  3.2M  2.8G   1% /test1
[root@localhost /]# 
... lvresize command with resize2fs command increased the size similarly as lvextend and resize2fs command. So it showed both of these worked similarly. Now we can come to a conclusion below.


Command "fsadm" allows you to reduce the file system without manually un-mounting a file system and also running e2fsck or file system check and then resizing or lvreduce command and then mounting back, but within the file system size given at the creation time of Logical Volume. It skipped 
a. UMOUNT
b. FSCK
c. resize2fs {LV} SIZE
d. lvreduce
e. Mount the File system. 


Will be adding in other post about how we can use the space of the LV reduced using this method. 


 


Tuesday, April 15, 2014

Using while to run a command number of times + UNIX

Hi Friends,

We can use while to run a command multiple times with a time difference of n seconds.

[root@abc /]# while true
> do sleep 10
> df -h
> done
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   19G   28G  41% /
tmpfs                 935M  408K  935M   1% /dev/shm
/dev/sda1             485M   38M  422M   9% /boot
/dev/mapper/VolGroup-lv_home
                       50G  5.5G   42G  12% /home
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   19G   28G  41% /
tmpfs                 935M  408K  935M   1% /dev/shm
/dev/sda1             485M   38M  422M   9% /boot
/dev/mapper/VolGroup-lv_home
                       50G  5.5G   42G  12% /home
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   19G   28G  41% /
tmpfs                 935M  408K  935M   1% /dev/shm
/dev/sda1             485M   38M  422M   9% /boot
/dev/mapper/VolGroup-lv_home
                       50G  5.5G   42G  12% /home

===========


the output of df command is coming after every ten seconds. these can be used when monitoring the size of file system while reducing it using find or rm.

Love Sharing
Amit Chopra

Thursday, April 3, 2014

How to read wtmp, btmp and utmp files + Linux

Hi Friends,

Learning Linux is now more exciting to me, I stay very happy when i learn any new thing about UNIX systems.sharing the same with you my friends, please add more in this if find me correct or incorrect so that we all can share better with everyone and understand more about UNIX system and working on it.

Reading files with cat, vi and more depends only upon the type of file which we want to check or read or see. So it is best to check the type of file with "file --name of the file-- ".

#file /var/log/wtmp
wtmp: data
#

so to read it we can try with Command "STRINGS" i.e.

#strings wtmp

but this output doesn't show the output in human readable form. so we can use "last -f" command. like below :- last -f /var/log/wtmp

we can also redirect this output to /tmp or desired location. and can then read this file properly.
-----
-----

wtmp file carries login details, reboot or system boot details with timings, terminals detail, with format of Day, Date, Time, System Crash/ Went Down/Made reboot.

utmp , wtmp carries login records and it also depends on type of programs using utmp logging as not all programs uses utmp logging.

utmp can be found in

/var/log/utmp
/var/run/utmp

btmp file carries login details, attaching the output in text file so that it can be read.

again

last -f "/var/log/btmp" ---- will give output in detail and can be redirected to any desired path.

attaching the o/p below :-

[root@localhost log]# last -f btmp
(unknown tty1         :0               Fri Mar 28 13:29    gone - no logout
ROOTEST1 tty7         :0               Wed Mar 26 20:28    gone - no logout
ROOTTEST tty7         :0               Wed Mar 26 20:25 - 20:28  (00:03)   
test123  tty7         :0               Wed Mar 26 20:15 - 20:25  (00:10)   
harish   tty1         :0               Tue Mar 11 06:48 - 13:29 (17+06:41) 
root     ssh:notty    175.125.29.35    Sun Mar  2 05:29    gone - no logout
root     ssh:notty    175.125.29.35    Sun Mar  2 05:29 - 05:29  (00:00)   
root     ssh:notty    175.125.29.35    Sun Mar  2 05:29 - 05:29  (00:00)   
root     ssh:notty    175.125.29.35    Sun Mar  2 05:29 - 05:29  (00:00)   
root     ssh:notty    175.125.29.35    Sun Mar  2 05:29 - 05:29  (00:00)   
root     ssh:notty    175.125.29.35    Sun Mar  2 05:29 - 05:29  (00:00)   

-============================================

btmp begins Sun Mar  2 02:09:17 2014
[root@localhost log]# last -f wtmp
root     pts/1        :0.0             Tue Apr  1 07:42   still logged in  
root     pts/0        :0.0             Tue Apr  1 07:38   still logged in  
root     tty1         :0               Tue Apr  1 07:34   still logged in  
reboot   system boot  2.6.32-358.el6.x Tue Apr  1 07:33 - 07:43  (00:09)   
root     pts/0        :0.0             Mon Mar 31 23:49 - down   (00:30)   
root     tty1         :0               Mon Mar 31 23:48 - down   (00:30)   
reboot   system boot  2.6.32-358.el6.x Mon Mar 31 23:48 - 00:19  (00:31)   
root     pts/2        :0.0             Sun Mar 30 11:38 - 11:38  (00:00)   

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

[root@localhost Desktop]# last -f /var/log/wtmp > /tmp/wtmpMarch.txt
[root@localhost Desktop]# ls -ld /tmp/wtmpMarch.txt
-rw-r--r-- 1 root root 12435 Apr  3 08:36 /tmp/wtmpMarch.txt
[root@localhost Desktop]#
[root@localhost Desktop]# less /tmp/wtmpMarch.txt
[root@localhost Desktop]# tail -4 /tmp/wtmpMarch.txt
reboot   system boot  2.6.32-358.el6.x Sat Feb  8 23:42 - 23:49  (00:07)   
reboot   system boot  2.6.32-358.el6.x Sat Feb  8 23:40 - 23:41  (00:01)   

wtmp begins Sat Feb  8 23:40:05 2014
[root@localhost Desktop]#




Love Sharing
Amit Chopra