Linux: How to gather RAID hardware info from running system


In these days I’m planning a lot of Redhat systems patching.
It’s important to see when i have a system with RAID hardware or not , it’s critical for planning a best rollback strategy.
But how can i get info about raid hardware without using the BIOS?

Looking on the web i found this awesome link. It’s helping me A LOT!!
I suggest to save it or print 🙂

http://khmel.org/?p=174

RHCSA practice lab


Today i finished to work on a RHCSA practice test. It covers just some topic of the whole course!

Follow the details:

Q: What is this lab for?
A: This is useful for who thinks is ready to get the RHCSA exam

Q: What is the goal?
A: The goals are:

1) configure web server with any index ( it’s your choice )
2) configure ftp server WITHOUT anonymous login
3) configure luks encrypted fs on ‘secret’ volumegroup and /secret mount point.
4) configure additional swap ( even 50 mb is enough )
5) server must have network services available through the network ( ssh , ftp , http , etc.etc. )

Every goal must be PERSISTENT AT REBOOT

Q: Where i can get the software packages?
A: Configure a local repository with the cd/dvd image of centos.

Q: Where i can get help for this lab?
A: For the best exam simulation , DON’T LOOK ON INTERNET. I also add this: DON’T READ THE KICKSTART COMMANDS!!!! Otherwise you are not able to troubleshooting issues. I tought about it for a realistic simulation so if you read the commands u are not helping yourself.

Q: What I need for this lab?
A: I used a vmware workstation guest , CentOS 6 x86_64, with 20gb disk and 1540 memory

This is the kickstart file, have fun!!!

Got RHCSA certified!!!


Today i did and passed RHCSA exam with score of 300!!!
I’m very very happy and finally i can come back to write on my blog 😀

I’m working about prepare a kickstart profile where people can test their knowledge before take RHCSA exam

Redhat course taken !!!


This week i was in Milan for a Redhat course.
I took the RH-436 ( cluster and storage management ) course and i learned A LOT OF NEW THINGS ! Finally I got some reply about my olders questions about redhat 6 cluster.

The most interesting thing was gluster , i hope to work on it soon .
Now i have to make a gluster presentation on my company because it’s very useful .

I’m not RHCE and i was not able to do the exam but i’m working on it ( RHCSA exam FIRST ).

Redhat Enterprise Linux patching: Rollback strategies


Soon i will patch a lot of systems ( RHEL 5 – RHEL 6 ) and i’m planning every rollback strategy.
Studying and looking for the web I found that people usually use RPM rollback but this is NOT RECOMMENDED!!

People on RHEL 5 add RPM macro , on RHEL 6 use yum history but both struments can be used for small rollbacks, not for minor release rollbacks!

I read this from Redhat:

Note: Downgrading a system to minor version (ex: RHEL-6.1 to RHEL-6.0) is not recommended as this might leave the system in broken state where libgcc and other libraries won’t rollback as expected. Use the history option for small update rollbacks.

Same is for RHEL 5.

So what can I think about rollback?

1) LVM snapshot ( usually estimated as ~ 20% lvol source space, only on RHEL 6 )
2) Files copy from / and /boot partitions with dd. This is useful with soft/hard links and it’s bit a bit copy. I just need a filesystem from SAN or NFS. If snapshot will not work I just need to boot the system in rescue mode , configure the network , mount the filesystems and use dd for rollback!
3) Disk from RAID HARDWARE
4) Dedicated software backup ( Networker Legato for example )

SLES 11 SP2: Ext4 readonly mount


Yesterday i was doing some test on my SLES 11 for SAP.
I was trying to mount an ext4 filesystem on /mnt.

During the mount i saw the message:

mount: warning: /mnt seems to be mounted read-only

I was surprised to see that message , so i tought about some problem with lvm or iSCSi ( i maked a volume group on a disk via iSCSi ).

Looking the system messages i saw this:

Mar 19 15:59:19 suse1 kernel: [ 1147.951164] EXT4-fs (dm-2): ext4 is supported in read-only mode only

Now it was clear! I understand too why SLESS 11 had the root filesystem on ext3 🙂

Linux grub Error 1: Cannot mount selected partition


In these days i’m playing a lot with mdadm and grub on Linux. I need to learn how make a root disks mirror starting from /dev/sd* booting devices.

During the tasks i did, I encoutered a problem with grub. I had:

– hd0 (sda)
– hd1 (sdb)

/dev/md1 -> /dev/sdb1 ( /boot )
/dev/md3 -> /dev/sdb3 ( / )
/dev/md2 -> /dev/sdb2 ( swap )

I edited /boot/grub/grub.conf as follow:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda3
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
fallback=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS MD (2.6.32-279.el6.x86_64)
root (hd1,0)
kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=/dev/md3 rd_NO_LUKS LANG=en_US.UTF-8 KEYBOARDTYPE=pc KEYTABLE=it rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-279.el6.x86_64.img
title CentOS (2.6.32-279.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=UUID=7c1ba3b1-756c-4124-9079-d11a32ceea78 rd_NO_LUKS LANG=en_US.UTF-8 KEYBOARDTYPE=pc KEYTABLE=it rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-279.el6.x86_64.img

After i tried to run:
[root@localhost grub]# grub
Probing devices to guess BIOS drives. This may take a long time.

GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]
grub> root (hd0,0)
root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
setup (hd0)
Checking if “/boot/grub/stage1” exists… no
Checking if “/grub/stage1” exists… yes
Checking if “/grub/stage2” exists… yes
Checking if “/grub/e2fs_stage1_5” exists… yes
Running “embed /grub/e2fs_stage1_5 (hd0)”… 27 sectors are embedded.
succeeded
Running “install /grub/stage1 (hd0) (hd0)1+27 p (hd0,0)/grub/stage2 /grub/grub.conf”… succeeded
Done.
grub> root (hd1,0)
root (hd1,0)
Filesystem type unknown, partition type 0xfd
grub> setup (hd1)
setup (hd1)

Error 1: Cannot mount selected partition
grub>

Looking on the web i found that the problem is with md devices metadata.
I maked them with:
mdadm –create /dev/md1 –level=1 –raid-disks=2 –metadata=default missing /dev/sdb1

default metadata is 1.2 , and it’s incompatible with GRUB!
So for boot disks the solution is make them with:
mdadm –create /dev/md1 –level=1 –raid-disks=2 –metadata=0.90 missing /dev/sdb1

Linux CentOS 6 e Windows 7 dual boot – BOOTMGR is missing


Today I installed CentOS6 on my notebook for KVM purposes.
After the installation I tried to test Windows boot and i got this error:

BOOTMGR is missing
Press CTRL + ALT + DEL to restart

I immediately tought “damn i’m using my work-notebook this is bad”.
From Linux I saw /etc/grub entries and for Windows I saw:

root (hd0,7)

Watching fdisk -l output i saw the first partition with little size and I tried to map it as follow:

root (hd0,1)

After this I was able to boot Windows 🙂

Linux CentOS 6: strange behaviour with multiple devices on single mount point !!!


I’m doing a lot of tests , experiments on my CentOS.

Yesterday i was experimenti a LVM mirror recovery and i found two devices mounted on same mount point: /mnt

I tought “damn due to my experiments i erased the system again…”

Later i was curious about to try it again. IT WORKED , how is that possible?

I can do this even now:

[root@centos6 ~]# cat /etc/issue
CentOS release 6.3 (Final)
Kernel \r on an \m

[root@centos6 ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
ale rootvg -wi-a— 1.00g
ale2 rootvg -wi-a— 104.00m
mau rootvg -wi-a— 1.00g
rootvol rootvg -wi-ao– 13.46g
swap2vol rootvg -wi-a— 2.00g
swapvol rootvg -wi-ao– 2.05g
test rootvg -wi-ao– 200.00m
mirrvol testvg mwi-a-m- 2.00g mirrvol_mlog 100.00

[root@centos6 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rootvg 1 7 0 wz–n- 24.51g 4.70g
testvg 2 1 0 wz–n- 9.98g 5.98g

[root@centos6 ~]# mount /dev/mapper/rootvg-test /mnt
[root@centos6 ~]# mount /dev/mapper/testvg-mirrvol /mnt

[root@centos6 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol
14G 4.4G 8.2G 35% /
tmpfs 498M 188K 498M 1% /dev/shm
/dev/sda1 485M 33M 427M 8% /boot
/dev/mapper/rootvg-test
2.0G 67M 1.9G 4% /mnt

/dev/mapper/testvg-mirrvol
2.0G 67M 1.9G 4% /mnt

I need to understand. NOW !!

Redhat 6: how to make a snapshot of root logical volume and rollback it


RHEL6 introduces new features about LVM. One of these is the snapshots.

I wanted to test it for rollback purpose. I will think about it for a patching task 😉

For this test I maked a screenshot of root logical volume , I deleted /etc directory and restored it from the sreenshot. All worked !

[root@localhost ~]# df -h
 Filesystem Size Used Avail Use% Mounted on
 /dev/mapper/rootvg-rootvol
 23G 3.1G 18G 15% /
 tmpfs 498M 0 498M 0% /dev/shm
 /dev/sda1 485M 33M 427M 8% /boot

[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rootvg 1 2 0 wz–n- 24.51g 0

I saw no free space on rootvg so i added a new disk

[root@localhost ~]# sfdisk -l /dev/sdb

Disk /dev/sdb: 652 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdb1          0+    651     652-   5237158+  8e  Linux LVM
/dev/sdb2          0       –       0          0    0  Empty
/dev/sdb3          0       –       0          0    0  Empty
/dev/sdb4          0       –       0          0    0  Empty

[root@localhost ~]# pvcreate /dev/sdb1
Writing physical volume data to disk “/dev/sdb1”
Physical volume “/dev/sdb1” successfully created

[root@localhost ~]# vgextend rootvg /dev/sdb1
Volume group “rootvg” successfully extended

[root@localhost ~]# vgs
VG     #PV #LV #SN Attr   VSize  VFree
rootvg   2   2   0 wz–n- 29.50g 4.99g

Nice. After i maked a screenshot with all free space on the vg.

[root@localhost ~]# lvcreate -l 100%FREE –snapshot –name rootsnap /dev/rootvg/rootvol
Logical volume “rootsnap” created
[root@localhost ~]# lvs
LV       VG     Attr     LSize  Pool Origin  Data%  Move Log Copy%  Convert
rootsnap rootvg swi-a-s-  4.99g      rootvol   0.00
rootvol  rootvg owi-aos- 22.46g
swapvol  rootvg -wi-ao–  2.05g

s attribute said to me that rootsnap is a snapshot !

[root@localhost ~]# lvdisplay /dev/rootvg/rootvol
— Logical volume —
LV Path                /dev/rootvg/rootvol
LV Name                rootvol
VG Name                rootvg
LV UUID                MgWa8V-yUnK-hqC0-Kv6X-strT-eccc-Kiwt8S
LV Write Access        read/write
LV Creation host, time localhost.localdomain, 2013-01-29 19:04:19 +0100
LV snapshot status     source of
rootsnap [active]

LV Status              available
# open                 1
LV Size                22.46 GiB
Current LE             5750
Segments               1
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:1

First test I did:

[root@localhost ~]# dd if=/dev/zero of=test.img bs=1024k count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 80.6583 s, 13.0 MB/s

THE SPACE ON THE SNAPSHOT MUST BE CHECKED !!!

[root@localhost ~]# lvs
LV       VG     Attr     LSize  Pool Origin  Data%  Move Log Copy%  Convert
rootsnap rootvg swi-a-s-  4.99g      rootvol  18.21
rootvol  rootvg owi-aos- 22.46g
swapvol  rootvg -wi-ao–  2.05g

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol
23G  4.2G   17G  20% /
tmpfs                 498M     0  498M   0% /dev/shm
/dev/sda1             485M   33M  427M   8% /boot

After i erased /etc directory!

[root@localhost ~]# rm -rf /etc
[root@localhost ~]# cd /etc
-bash: cd: /etc: No such file or directory
[root@localhost ~]# df -h
df: cannot read table of mounted file systems: No such file or directory

I did a reboot and as expected the system was not able to boot up.
So , I used rescue mode from CD and I ran on the shell:

lvconvert –merge rootvg/rootsnap

At next boot the system came up without any problem/warning!

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol
23G  3.1G   18G  15% /
tmpfs                 498M     0  498M   0% /dev/shm
/dev/sda1             485M   33M  427M   8% /boot

[root@localhost ~]# cd /root
[root@localhost ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog

( The 1 gb file does not exist anymore )

[root@localhost ~]# lvs
LV      VG     Attr     LSize  Pool Origin Data%  Move Log Copy%  Convert
rootvol rootvg -wi-ao– 22.46g
swapvol rootvg -wi-ao–  2.05g

( the snapshot is not present )
With this i saw that the system was rollbacked with success.
So i will use this method on RHEL6 for rollingback after a patching!