October 2025
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

October 2025
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Veritas Volume Manager

vxdisk: 

krishbe$ vxdisk list                 ==> List all disks under volume manager control and give there status
krishbe$ vxdisk -oalldgs list
krishbe$ vxdisk rm <c?t?d?>    ==> Remove a disk so that it is no longer under volume manager control
krishbe$ vxdisk list <disk>      ==> Display detailed disk information

vxdg:
krishbe$ vxdg list  ==> Display groups
krishbe$ vxdg list <group> ==> Display detailed group information
krishbe$ vxdg free  ==> display free space on the disks
krishbe$ vxdg destroy <group> ==> Remove a group
krishbe$ vxdg import <group> ==> Import a group
krishbe$ vxdg deport <group> ==> Deport a group
krishbe$ vxdg -g <group> free ==> Display free space on diskgroup
krishbe$ vxdg -g homedg rmdisk disk99  ==> from the disk group homedg remove the disk disk99
krishbe$ vxdg -g homedg adddisk disk99=c0t0d0  ==> in the disk group homedg add the physical disk c0t0d0 calling it disk99

vxprint:
vxprint -l <volumename>  ==> Display information about volumes
vxprint -vl
vxprint -vt
vxprint -l <plex-name>  ==> Display information about plex(es)
vxprint -lp
vxprint -l <diskname>  ==> Display information about subdisks
vxprint -st
vxprint -ht  ==> Display the volume,plex & subdisk information for all volumes

vxvol:
vxvol stop <volumename>  ==> To stop a volume
vxvol start <volumename>  ==> To start a volume

Extended File System by adding a New Disk.

[root@myhost01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       17G   13G  3.4G  79% /
/dev/sda1              99M   43M   52M  45% /boot
tmpfs                 943M     0  943M   0% /dev/shm
 
[root@myhost01 ~]#
[root@myhost01 ~]#
[root@myhost01 ~]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.
The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdd: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1

First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):
Using default value 1305

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@myhost01 ~]# pvscan
  PV /dev/sda2   VG VolGroup00   lvm2 [19.88 GB / 0    free]
  Total: 1 [19.88 GB] / in use: 1 [19.88 GB] / in no VG: 0 [0   ]

[root@myhost01 ~]# pvcreate /dev/sdd1
  Physical volume “/dev/sdd1” successfully created

[root@myhost01 ~]# pvscan
  PV /dev/sda2   VG VolGroup00      lvm2 [19.88 GB / 0    free]
  PV /dev/sdd1                      lvm2 [10.00 GB]
  Total: 2 [29.87 GB] / in use: 1 [19.88 GB] / in no VG: 1 [10.00 GB]

[root@myhost01 ~]# vgextend VolGroup00 /dev/sdd1
  Volume group “VolGroup00” successfully extended

[root@myhost01 ~]# lvresize -L 25G /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 25.00 GB
  Logical volume LogVol00 successfully resized

[root@myhost01 ~]# pvscan
  PV /dev/sda2   VG VolGroup00   lvm2 [19.88 GB / 0    free]
  PV /dev/sdd1   VG VolGroup00   lvm2 [9.97 GB / 1.94 GB free]
  Total: 2 [29.84 GB] / in use: 2 [29.84 GB] / in no VG: 0 [0   ]

 
[root@myhost01 ~]# resize2fs -p  /dev/VolGroup00/LogVol00 25G
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 6553600 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 6553600 blocks long.
 
[root@myhost01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       25G   13G   11G  54% /
/dev/sda1              99M   43M   52M  45% /boot
tmpfs                 943M     0  943M   0% /dev/shm
 

Converting a non-root filesystem to ext4

Before the Addition of new disk to the Linux Server :
=============================================================================
======>> The total number of disks on the system can be seen through fdisk -l

[root@servername ~]# fdisk -l | more

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          29      232911   83  Linux
/dev/sda2              30        2610    20731882+  8e  Linux LVM

Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       65270   524281243+  8e  Linux LVM

Disk /dev/sdc: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       65270   524281243+  8e  Linux LVM

Disk /dev/sdd: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1       65270   524281243+  8e  Linux LVM

Disk /dev/sde: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1       13054   104856223+  8e  Linux LVM

Disk /dev/sdf: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1       65270   524281243+  8e  Linux LVM

Disk /dev/sdg: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1               1       65270   524281243+  83  Linux

Disk /dev/sdh: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdh1               1        3916    31455238+  8e  Linux LVM

Disk /dev/sdi: 644.2 GB, 644245094400 bytes
255 heads, 63 sectors/track, 78325 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdi1               1       78325   629145562   8e  Linux LVM

Filesystem sizes on the server before the addition :
=====================================================

[root@servername ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg0-root  992M  483M  458M  52% /
/dev/mapper/vg0-var   2.0G  744M  1.2G  40% /var
/dev/mapper/vg0-tmp   992M  130M  812M  14% /tmp
/dev/mapper/vg0-usr   7.8G  1.3G  6.2G  17% /usr
/dev/mapper/vg0-opt   2.3G  982M  1.2G  46% /opt
/dev/mapper/vg0-home  992M   88M  853M  10% /home
/dev/sda1             221M   26M  183M  13% /boot
tmpfs                1006M     0 1006M   0% /dev/shm
/dev/mapper/vg1-lv0   2.0T  1.7T  277G  86% /data
/dev/mapper/vg3-media1
                      589G  553G  6.5G  99% /media

We are going to increase the size of the /media FS by adding disk to the vg3 volume group.

After adding the disk from the storage , you can check the new disk availability through the fdisk -l :
========================================================================================================
=====>> New disk added will be shown as /dev/sdj in the below output

[root@servername ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          29      232911   83  Linux
/dev/sda2              30        2610    20731882+  8e  Linux LVM

Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       65270   524281243+  8e  Linux LVM

Disk /dev/sdc: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       65270   524281243+  8e  Linux LVM

Disk /dev/sdd: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1       65270   524281243+  8e  Linux LVM

Disk /dev/sde: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1       13054   104856223+  8e  Linux LVM

Disk /dev/sdf: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1       65270   524281243+  8e  Linux LVM

Disk /dev/sdg: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1               1       65270   524281243+  83  Linux

Disk /dev/sdh: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdh1               1        3916    31455238+  8e  Linux LVM

Disk /dev/sdi: 644.2 GB, 644245094400 bytes
255 heads, 63 sectors/track, 78325 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdi1               1       78325   629145562   8e  Linux LVM

Disk /dev/sdj: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdj doesn’t contain a valid partition table

Now You are going to create a new partition to the allocated disk /dev/sdj as shown below with the commands :
=============================================================================================================

[root@servername ~]# fdisk /dev/sdj
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklab
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.

The number of cylinders for this disk is set to 13054.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdj: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-13054, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-13054, default 13054):
Using default value 13054

Command (m for help): p

Disk /dev/sdj: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdj1               1       13054   104856223+  83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L

 0  Empty           1e  Hidden W95 FAT1 80  Old Minix       bf  Solaris
 1  FAT12           24  NEC DOS         81  Minix / old Lin c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          82  Linux swap / So c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  83  Linux           c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     84  OS/2 hidden C:  c7  Syrinx
 5  Extended        41  PPC PReP Boot   85  Linux extended  da  Non-FS data
 6  FAT16           42  SFS             86  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS       4d  QNX4.x          87  NTFS volume set de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 88  Linux plaintext df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 8e  Linux LVM       e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      93  Amoeba          e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 94  Amoeba BBT      e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            9f  BSD/OS          eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi ee  EFI GPT
 f  W95 Ext’d (LBA) 54  OnTrackDM6      a5  FreeBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a6  OpenBSD         f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a7  NeXTSTEP        f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a8  Darwin UFS      f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       a9  NetBSD          f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys ab  Darwin boot     fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

=======>> Change the partition type from linux state to the linux LVM state by the command code 8e as shown above.

After the Patition done by the above process now you can able to see the partition as shown below with the Output :

Disk /dev/sdj: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdj1               1       13054   104856223+  8e  Linux LVM

=======>> Now create the pv on the server by the above partition.

[root@servername ~]# pvcreate /dev/sdj1
 Physical volume “/dev/sdj1” successfully created

=======>> vg free space before the addition of pv to the volumegroup.

[root@servername ~]# vgdisplay vg3
  /dev/vg2/media: read failed after 0 of 4096 at 0: Input/output error
  — Volume group —
  VG Name               vg3
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               600.00 GB
  PE Size               4.00 MB
  Total PE              153599
  Alloc PE / Size       153088 / 598.00 GB
  Free  PE / Size       511 / 2.00 GB
  VG UUID               aVQV67-68Ge-b6EK-FnbI-81S2-9wsr-EobIkt

=======>> Now extend the volume group by adding the pv as shown below

[root@servername ~]# vgextend vg3 /dev/sdj1
  Volume group “vg3” successfully extended

=======>> Now check the volume group free space on the server as shown below

[root@servername ~]# vgdisplay vg3
  /dev/vg2/media: read failed after 0 of 4096 at 0: Input/output error
  — Volume group —
  VG Name               vg3
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               699.99 GB
  PE Size               4.00 MB
  Total PE              179198
  Alloc PE / Size       153088 / 598.00 GB
  Free  PE / Size       26110 / 101.99 GB
  VG UUID               aVQV67-68Ge-b6EK-FnbI-81S2-9wsr-EobIkt

=======>> Now increase ( 100GB )  the LV size as you needed the free space on the FS as shown below

[root@servername ~]# lvextend -L +100G /dev/vg3/media1
  Extending logical volume media1 to 698.00 GB
  Logical volume media1 successfully resized

=======>> Now resize the FS as shown below

[root@servername ~]# resize2fs -p /dev/vg3/media1

resize2fs 1.39 (29-May-2006)

Filesystem at /dev/vg3/media1 is mounted on /media; on-line resizing required

Performing an on-line resize of /dev/vg3/media1 to 182976512 (4k) blocks.

The filesystem on /dev/vg3/media1 is now 182976512 blocks long.

=======>> Now check the FS size with the below output.

[root@servername ~]# df -h /media
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg3-media1
                      688G  553G  100G  85% /media

Converting a root filesystem to ext4

Converting a root filesystem is a bit more tricky because you cannot unmount it, as your system is running on it. Nevertheless it is still possible to do it without using an external bootable media. You should do this in a single-user mode.

First step is to modify your /etc/fstab file to say “ext4” instead of “ext3” for root partition. This is important because you will be operating on a read-only filesystem later, and will not be able to make the change, and this would result in your system unable to mount a root filesystem on next boot.

Let us assume that root partition is /dev/sda1, so your /etc/fstab should look something like this.

=====>> #/dev/sda1 / ext4 defaults 0 1
Now remount the root filesystem read-only.

=====>> #mount -o remount,ro /
Then run a filesystem check on the root filesystem.

=====>> #fsck.ext3 -pf /dev/sda1
It will tell you to reboot the system. That may be a good idea, so simply boot into single-user mode and remount it read-only again. It is fine even though we have already modified /etc/fstab, because ext3 can be mounted as ext4 without conversion.

Next, enable all the ext4 features on the root filesystem.

=====>> #tune2fs -O extents,uninit_bg,dir_index /dev/sda1
And run run a filesystem check on the root filesystem again. It will find and fix errors. This is normal.

=====>> #fsck.ext4 -yfD /dev/sda1
You can now reboot to your new ext4 system, and enjoy faster filesystem check times, better performance, and all the improvements of ext4. Well, almost; read the next section.

Linux File Systems: Ext2 vs Ext3 vs Ext4

EXT2, EXT3 and EXT4 are all filesystems created for Linux. This article explains the following:

High level difference between these filesystems.
How to create these filesystems.
How to convert from one filesystem type to another.

===>> Ext2

Ext2 stands for second extended file system.
It was introduced in 1993. Developed by Rémy Card.
This was developed to overcome the limitation of the original ext file system.
Ext2 does not have journaling feature.
On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do the over head of journaling.
Maximum individual file size can be from 16 GB to 2 TB
Overall ext2 file system size can be from 2 TB to 32 TB

===>> Ext3

Ext3 stands for third extended file system.
It was introduced in 2001. Developed by Stephen Tweedie.
Starting from Linux Kernel 2.4.15 ext3 was available.
The main benefit of ext3 is that it allows journaling.
Journaling has a dedicated area in the file system, where all the changes are tracked. When the system crashes, the possibility of file system corruption is less because of journaling.
Maximum individual file size can be from 16 GB to 2 TB
Overall ext3 file system size can be from 2 TB to 32 TB
There are three types of journaling available in ext3 file system.
Journal – Metadata and content are saved in the journal.
Ordered – Only metadata is saved in the journal. Metadata are journaled only after writing the content to disk. This is the default.
Writeback – Only metadata is saved in the journal. Metadata might be journaled either before or after the content is written to the disk.
You can convert a ext2 file system to ext3 file system directly (without backup/restore).
===>> Ext4

Ext4 stands for fourth extended file system.
It was introduced in 2008.
Starting from Linux Kernel 2.6.19 ext4 was available.
Supports huge individual file size and overall file system size.
Maximum individual file size can be from 16 GB to 16 TB
Overall maximum ext4 file system size is 1 EB (exabyte). 1 EB = 1024 PB (petabyte). 1 PB = 1024 TB (terabyte).
Directory can contain a maximum of 64,000 subdirectories (as opposed to 32,000 in ext3)
You can also mount an existing ext3 fs as ext4 fs (without having to upgrade it).
Several other new features are introduced in ext4: multiblock allocation, delayed allocation, journal checksum. fast fsck, etc. All you need to know is that these new features have improved the performance and reliability of the filesystem when compared to ext3.
In ext4, you also have the option of turning the journaling feature “off”.
Use the method we discussed earlier to identify whether you have ext2 or ext3 or ext4 file system.

Warning: Don’t execute any of the commands given below, if you don’t know what you are doing. You will lose your data!

Creating an ext2, or ext3, or ext4 file system

Once you’ve partitioned your hard disk using fdisk command, use mke2fs to create either ext2, ext3, or ext4 file system.

Create an ext2 file system:

=====>> #mke2fs /dev/sda1
Create an ext3 file system:

=====>> #mkfs.ext3 /dev/sda1

(or)

=====>> #mke2fs –j /dev/sda1
Create an ext4 file system:

=====>> #mkfs.ext4 /dev/sda1

(or)

=====>> #mke2fs -t ext4 /dev/sda1
Converting ext2 to ext3

For example, if you are upgrading /dev/sda2 that is mounted as /home, from ext2 to ext3, do the following.

=====>> #umount /dev/sda2

=====>> #tune2fs -j /dev/sda2

=====>> #mount /dev/sda2 /home
Note: You really don’t need to umount and mount it, as ext2 to ext3 conversion can happen on a live file system. But, I feel better doing the conversion offline.

Converting ext3 to ext4

If you are upgrading /dev/sda2 that is mounted as /home, from ext3 to ext4, do the following.

=====>> #umount /dev/sda2

=====>> #tune2fs -O extents,uninit_bg,dir_index /dev/sda2

=====>> #e2fsck -pf /dev/sda2

=====>> #mount /dev/sda2 /home
Again, try all of the above commands only on a test system, where you can afford to lose all your data.

Changing FS type from ext3 to ext4 in Linux

Now changing the ext3 FS to the ext4 FS type depends on the Requirement.
=========================================================================

=====>> check the fs type by the below information

[root@servername ~]# mount | grep -i media

/dev/mapper/vg3-media1 on /media type ext3 (rw)

=====>> also check in the fstab file

[root@servername ~]# cat /etc/fstab
/dev/vg0/root           /                       ext3    defaults        1 1
/dev/vg0/var            /var                    ext3    defaults        1 2
/dev/vg0/tmp            /tmp                    ext3    defaults        1 2
/dev/vg0/usr            /usr                    ext3    defaults        1 2
/dev/vg0/opt            /opt                    ext3    defaults        1 2
/dev/vg0/home           /home                   ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/vg0/swap           swap                    swap    defaults        0 0
/dev/mapper/vg1-lv0     /data                   ext3    defaults,user_xattr     1 2
#/dev/mapper/vg2-media  /media                  ext4    defaults        1 2
/dev/mapper/vg3-media1  /media                  ext3    defaults        1 2

======>> umount the FS and give the below 2 commands and mount it with ext4 type.

[root@servername ~]# tune4fs -O extents,uninit_bg,dir_index /dev/vg3/media1
tune4fs 1.41.9 (22-Aug-2009)

Please run e4fsck on the filesystem.

[root@servername ~]# fsck.ext4 -fDC0 /dev/vg3/media1
e4fsck 1.41.9 (22-Aug-2009)

Do you really want to continue (y/n)? yes

/dev/vg3/media1: recovering journal

/dev/vg3/media1: ***** FILE SYSTEM WAS MODIFIED *****

=======>> now check the FS type has been changed to the ext4 type from ext3 as shown below.

[root@servername ~]# mount | grep -i media

/dev/mapper/vg3-media1 on /media type ext4 (rw)

=======>> Now change the FS type in the /etc/fstab to ext4 type.

[root@servername ~]# cat /etc/fstab
/dev/vg0/root           /                       ext3    defaults        1 1
/dev/vg0/var            /var                    ext3    defaults        1 2
/dev/vg0/tmp            /tmp                    ext3    defaults        1 2
/dev/vg0/usr            /usr                    ext3    defaults        1 2
/dev/vg0/opt            /opt                    ext3    defaults        1 2
/dev/vg0/home           /home                   ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/vg0/swap           swap                    swap    defaults        0 0
/dev/mapper/vg1-lv0     /data                   ext3    defaults,user_xattr     1 2
#/dev/mapper/vg2-media  /media                  ext4    defaults        1 2
/dev/mapper/vg3-media1  /media                  ext4    defaults        1 2

CentOS 5: Converting Ext3 to Ext4

OS: CentOS 5.6 64bit
Kernel version: 2.6.18-238.19.1.el5
Backup partition: /backup (mount from /dev/sdb)

1. First of all, its recommended to backup everything first. We will us ‘dd‘ command to backup the whole partition to another hard disk. That hard disk is attached via SATA cable. We will format the backup hard disk with ext3 filesystem and and mount as /backup partition:

$ fdisk /dev/sdb
…..

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-3916, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-3916, default 3916):
Using default value 3916

Command (m for help): w
The partition table has been altered!

……

The sequence I press in the keyboard is: n > p > 1 > enter > enter > w

2. Then, format the partition table /dev/sdb1 with ext3 filesystem:

$ mkfs.ext3 /dev/sdb1
3. Mount the backup partition to  /backup:

$ mkdir /backup
$ mount /dev/sdb1 /backup
4. Lets check our partition summary:

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       47G  3.3G   41G   8% /
/dev/sda1              99M   20M   75M  21% /boot
tmpfs                 501M     0  501M   0% /dev/shm
/dev/sdb1              76G  173M   75G   1% /backup
5. Lets backup “/” partition and put the image into backup directory:

$ dd if=/dev/VolGroup00/LogVol00 of=/backup/VolGroup00-LogVol00.bak
100466688+0 records in
100466688+0 records out
51438944256 bytes (51 GB) copied, 807.368 seconds, 63.7 MB/s
6. Now we need to install one package called e4fsprogs. The e4fsprogs packages contain a number of utilities for creating, checking, modifying, and correcting inconsistencies in fourth extended (ext4 and ext4dev) file systems:

$ yum -y install e4fsprogs
7. We start to do the ext4 filesystem conversion:

$ tune4fs -O extents,uninit_bg,dir_index /dev/VolGroup00/LogVol00
tune4fs 1.41.12 (17-May-2010)

Please run e4fsck on the filesystem.
8. As what has been advised, we need to run filesystem check after tune. I rather do this in single-mode (init 1) to reduce risks. DON’T PROCEED TO REBOOT ONCE THIS STEP COMPLETE!

$ init 1
$ e4fsck -fDC0 /dev/VolGroup00/LogVol00
………
Group descriptor checksum is invalid. FIXED.
Adding dirhash hint to filesystem.

Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/VolGroup00/LogVol00: ***** FILE SYSTEM WAS MODIFIED *****
/dev/VolGroup00/LogVol00: ***** REBOOT LINUX *****
/dev/VolGroup00/LogVol00: 112086/12558336 files (0.7% non-contiguous), 1252590/12558336 blocks
9. Change the /etc/fstab to make sure the system will mount the new ext4 filesystem afterwards:

$ vi /etc/fstab

Change following line:

/dev/VolGroup00/LogVol00 /                       ext4    defaults        1 1
10. Rebuild the initrd to make sure our system will mount /sysroot as ext4 and reboot the server once complete:

$ mkinitrd -v -f initrd-2.6.18-238.19.1.el5.img 2.6.18-238.19.1.el5
$ init 6
11. If we directly reboot after fsck on step 8, then we will have kernel panic, unless the kernel is 2.6.28 and later. Once up, lets check whether is it run on ext4 or not:

$ mount | grep ext4
/dev/mapper/VolGroup00-LogVol00 on / type ext4 (rw)

Additional Swap File in Linux

What is swap?
Swap space is the area on a hard disk which is part of the Virtual Memory of your machine, which is a combination of accessible physical memory (RAM) and the swap space. Swap space temporarily holds memory pages that are inactive. Swap space is used when your system decides that it needs physical memory for active processes and there is insufficient unused physical memory available. If the system happens to need more memory resources or space, inactive pages in physical memory are then moved to the swap space therefore freeing up that physical memory for other uses. Note that the access time for swap is slower therefore do not consider it to be a complete replacement for the physical memory. Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.

swap file is a special file in the filesystem that resides amongst your system and data files.
To Add
Step1: Use dd command and create 4g swap file
krishbe$ dd if=/dev/zero of=/swapfile bs=1024 count=4194304
4194304+0 records in
4194304+0 records out
krishbe$
Step2: Use mkswap command and setup linux swap area
krishbe$ mkswap /swapfile
Setting up swapspace version 1, size = 4294963 kB
krishbe$
krishbe$ free -g
             total       used       free     shared    buffers     cached
Mem:            15          9          5          0          0          7
-/+ buffers/cache:          2         12
Swap:            1          1          0
krishbe$
Step3: Use swapon command and activate newly created swap area
krishbe$ swapon /swapfile
Step4: Use free command and make sure additional swap space activated
krishbe$ free -g
             total       used       free     shared    buffers     cached
Mem:            15          9          5          0          0          7
-/+ buffers/cache:          2         12
Swap:            5          1          4
krishbe$
Step5: To make it permanent append /etc/fstab with the below entry
/swapfile               swap                    swap    defaults        0 0

To Remove
use swapoff command and remove swap file entry from  /etc/fstab
#swapoff /swapfile

LINIX -Bonding

LINIX -Bonding

 
Bonding – Linux allows binding multiple network interfaces into a single channel/NIC using special kernel module called bonding.The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical “bonded” interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services. Additionally, link integrity monitoring may be performed.”

root#/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
root#/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
root#/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
>>Load bond driver/module
root#/etc/modprobe.conf
alias bond0 bonding
options bond0 mode=balance-alb miimon=100
>>Test configuration
root#modprobe bonding
root#service network restart
root#less /proc/net/bonding/bond0
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:59
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:63
root#ifconfig

LINUX LVM multipath

krishbe$ multipath -ll
mpath2 (360060480000190102091533030453034) dm-2 EMC,SYMMETRIX
[size=30G][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=2][active]
 \_ 0:0:0:112 sdd 8:48  [active][ready]
 \_ 3:0:0:112 sdg 8:96  [active][ready]
mpath1 (360060480000190102091533030453033) dm-1 EMC,SYMMETRIX
[size=30G][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=2][active]
 \_ 0:0:0:111 sdc 8:32  [active][ready]
 \_ 3:0:0:111 sdf 8:80  [active][ready]
mpath0 (360060480000190102091533030303830) dm-0 EMC,SYMMETRIX
[size=2.8M][features=0][hwhandler=0][ro]
\_ round-robin 0 [prio=2][active]
 \_ 0:0:0:0   sda 8:0   [active][ready]
 \_ 3:0:0:0   sdb 8:16  [active][ready]
mpath3 (360060480000190102091533030453035) dm-3 EMC,SYMMETRIX
[size=30G][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=2][active]
 \_ 0:0:0:113 sde 8:64  [active][ready]
 \_ 3:0:0:113 sdh 8:112 [active][ready]
krishbe$
krishbe$ inq
Inquiry utility, Version V7.3-891 (Rev 2.0)      (SIL Version V6.5.2.0 (Edit Level 891)
Copyright (C) by EMC Corporation, all rights reserved.
For help type inq -h.
…………
——————————————————————–
DEVICE    :VEND    :PROD            :REV   :SER NUM    :CAP(kb)
——————————————————————–
/dev/sda  :EMC     :SYMMETRIX       :5773  :9100080000 :        2880
/dev/sdb  :EMC     :SYMMETRIX       :5773  :9100080000 :        2880
/dev/sdc  :EMC     :SYMMETRIX       :5773  :9100e03000 :    31200000
/dev/sdd  :EMC     :SYMMETRIX       :5773  :9100e04000 :    31200000
/dev/sde  :EMC     :SYMMETRIX       :5773  :9100e05000 :    31200000
/dev/sdf  :EMC     :SYMMETRIX       :5773  :9100e03000 :    31200000
/dev/sdg  :EMC     :SYMMETRIX       :5773  :9100e04000 :    31200000
/dev/sdh  :EMC     :SYMMETRIX       :5773  :9100e05000 :    31200000
/dev/dm-0 :EMC     :SYMMETRIX       :5773  :9100080000 :        2880
/dev/dm-1 :EMC     :SYMMETRIX       :5773  :9100e03000 :    31200000
/dev/dm-2 :EMC     :SYMMETRIX       :5773  :9100e04000 :    31200000
/dev/dm-3 :EMC     :SYMMETRIX       :5773  :9100e05000 :    31200000
krishbe$
krishbe$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p1      94G  2.2G   87G   3% /
/dev/cciss/c0d0p3      19G  173M   18G   1% /var/crash
tmpfs                  32G     0   32G   0% /dev/shm
krishbe$
krishbe$ cat /proc/partitions
major minor  #blocks  name
 104     0  143338560 cciss/c0d0
 104     1  100759648 cciss/c0d0p1
 104     2   20161575 cciss/c0d0p2
 104     3   20161575 cciss/c0d0p3
   8     0       2880 sda
   8    16       2880 sdb
 253     0       2880 dm-0
   8    32   31200000 sdc
   8    48   31200000 sdd
   8    64   31200000 sde
 253     1   31200000 dm-1
 253     2   31200000 dm-2
 253     3   31200000 dm-3
   8    80   31200000 sdf
   8    96   31200000 sdg
   8   112   31200000 sdh
krishbe$

krishbe$ fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.

The number of cylinders for this disk is set to 30468.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partitionn
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition’s system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-30468, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-30468, default 30468):
Using default value 30468
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
krishbe$
krishbe$ fdisk -l /dev/sdc
Disk /dev/sdc: 31.9 GB, 31948800000 bytes
64 heads, 32 sectors/track, 30468 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       30468    31199216   8e  Linux LVM
krishbe$
krishbe$ pvcreate /dev/mapper/mpath1p1
  Physical volume “/dev/mapper/mpath1p1” successfully created
krishbe$
krishbe$ pvdisplay
  “/dev/dm-5” is a new physical volume of “29.75 GB”
  — NEW Physical volume —
  PV Name               /dev/dm-5
  VG Name
  PV Size               29.75 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               EQ0kuR-zH2V-zSMt-QAEQ-Egkc-GSMg-3nUEP1
krishbe$
krishbe$ vgcreate prdsnacdg /dev/mapper/mpath1p1
  /dev/sda: open failed: Read-only file system
  Attempt to close device ‘/dev/sda’ which is not open.
  /dev/sde: open failed: Read-only file system
  Attempt to close device ‘/dev/sde’ which is not open.
  Volume group “prdsnacdg” successfully created
krishbe$
krishbe$ vgdisplay
  — Volume group —
  VG Name               prdsnacdg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               29.75 GB
  PE Size               4.00 MB
  Total PE              7616
  Alloc PE / Size       0 / 0
  Free  PE / Size       7616 / 29.75 GB
  VG UUID               JRt2Gv-bx2q-Oo5A-BsET-ifmZ-vxOm-6MMZYc
krishbe$
krishbe$ lvcreate -L 20g -n localvol prdsnacdg
  Logical volume “localvol” created
krishbe$
krishbe$ lvcreate -L 9.5g -n appsvol prdsnacdg
  Logical volume “appsvol” created
krishbe$

krishbe$ lvdisplay
  — Logical volume —
  LV Name                /dev/prdsnacdg/localvol
  VG Name                prdsnacdg
  LV UUID                ilDOiV-RqKO-7k7g-uUOQ-CMxQ-scCE-QbtJm3
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                20.00 GB
  Current LE             5120
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  – currently set to     256
  Block device           253:7
  — Logical volume —
  LV Name                /dev/prdsnacdg/appsvol
  VG Name                prdsnacdg
  LV UUID                FC0KCA-SYgT-pRzE-TUU8-GUqm-zoQu-kd5QGL
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                9.50 GB
  Current LE             2432
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  – currently set to     256
  Block device           253:8
krishbe$

krishbe$ mkfs -t ext3 /dev/prdsnacdg/localvol
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
bash-3.2# mkfs -t ext3 /dev/prdsnacdg/appsvol
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1245184 inodes, 2490368 blocks
124518 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2550136832
76 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
krishbe$
krishbe$ mkdir /apps/oracle
krishbe$ mkdir /local/oracle

krishbe$ cat /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/var/crash        /var/crash              ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SW-cciss/c0d0p2   swap                    swap    defaults        0 0
/dev/prdsnacdg/localvol /local/oracle           ext3    defaults        1 2
/dev/prdsnacdg/appsvol  /apps/oracle            ext3    defaults        1 2
krishbe$
krishbe$ mount -a
krishbe$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p1      94G  2.2G   87G   3% /
/dev/cciss/c0d0p3      19G  173M   18G   1% /var/crash
tmpfs                  32G     0   32G   0% /dev/shm
/dev/mapper/prdsnacdg-localvol
                       20G  173M   19G   1% /local/oracle
/dev/mapper/prdsnacdg-appsvol
                      9.4G  150M  8.8G   2% /apps/oracle
krishbe$