17 October 2014

Rename Linux Volume Groups and Logical Volumes

If you are decided to rename your Linux LVM Volume Groups or Logical Volumes then here is how:

Rename a volume group:

# vgrename /dev/vg_old /dev/vgnewname 

Rename a logical volume:

# lvrename /dev/vg_name/lv_old /dev/vg_name/lv_newname 

Make sure to modify the respective entries in fstab as well:

# vi /etc/fstab

/dev/mapper/vg_old-lv_old       /var         ext4    defaults        1 1

to

/dev/mapper/vgnewname-lv_newname       /var         ext4    defaults        1 1

And if you are renaming your root partition VG or LV, then grub menu file also needs to be modified in order for server to find your vmlinuz kernel image under root directory during boot process:

# vi /boot/grub/menu.lst

kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vg_old-lv_root rd_NO_LUKS rd_LVM_LV=vg_old/lv_root LANG=en_US.UTF-8 rd_LVM_LV=vg_old/lv_swap

to 

kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vgnewname-lv_root rd_NO_LUKS rd_LVM_LV=vg_old/lv_root LANG=en_US.UTF-8 rd_LVM_LV=vgnewname/lv_swap


Note: If you forgot to modify these 2 mentioned files menu.list and fstab like me for the first time, you probably receive following kernel panic after reboot your system:

Kernel panic - not syncing: Attempted to kill init!
Pid: 1, comm: init tainted 2.6.32-431.el6.x86_64
Call Trace

After amended those files, you should be able to get rid of that kernel panic error and your system will be booted with new VG or LV names mounted. 







8 October 2014

Set static IP to Linux VM

If you are decided to not use DHCP to obtain IP dynamically for your linux box, you can set the IP manually as below.

Edit respecting ifcfg-eth* file of your network card and insert following entries in the file:

for network card eth0:

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
NETWORK=10.8.227.0
NETMASK=255.255.255.192
IPADDR=10.8.227.50
DNS1=10.8.224.13
GATEWAY=10.8.227.62
IPV6INIT=no
USERCTL=no

And replace you IP, netmask, gateway and dns(if any) with your addresses. 

Reactive your network card or restart you network service:

# ifdown eth0
# ifup eth0

or 

/etc/init.d/network restart

There you can see your new network settings and try t ping your gateway to make sure of connection:

# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:50:56:B7:3B:F7
          inet addr:10.8.227.50  Bcast:10.8.227.63  Mask:255.255.255.192
          inet6 addr: fe80::250:56ff:feb7:3bf7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9621 errors:0 dropped:0 overruns:0 frame:0
          TX packets:268 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:659779 (644.3 KiB)  TX bytes:45866 (44.7 KiB)