Wednesday, 1 August 2012

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




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)




Tuesday, 31 July 2012

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

Addition of New disk to the LINUX Server



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

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.

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.

Converting a non-root filesystem to ext4


As long as you are converting a filesystem that can be unmounted, it is fairly simple procedure. In this example we will be converting a /dev/sdc1 partition mounted as /home directory.

First, unmount the partition.

=====>> umount /dev/sdc1
Next, run a filesystem check on it to make sure it is in sane condition. We are still on ext3.

=====>> fsck.ext3 -pf /dev/sdc1
Enable new features of ext4 on the filesystem.

=====>> tune2fs -O extents,uninit_bg,dir_index /dev/sdc1
Option "extents" enables the filesystem to use extents instead of bitmap mapping for files, "uninit_bg" reduces file system check times by only checking used portions of the disk, and "dir_index" allows storing the contents of large directories in a htree for faster access. Option "dir_index" is also supported by ext3, so you may already be using it, but it makes no harm to specify it here.

Run a filesystem check. It will find errors. It is normal. Let it fix them. You may want to run the check twice to make sure that the filesystem is now clean.

=====>> fsck.ext4 -yfD /dev/sdc1
The "-D" parameter will actually enable the "dir_index" option by rebuilding directory index. It can be rebuilt (optimized) at any later time by running the check with the parameter.

Now edit your /etc/fstab file to say "ext4" instead of "ext3" for /home. Other options may differ for your system.

/dev/sdc1 /home ext4 defaults 0 2
Try to mount your new ext4 filesystem.

=====>> mount /home
If it succeeds, congratulations. If not, do not panic. You have not lost your data. And you have a backup after all, right? Make sure you have all the latest tools listed in prerequisites. Get them form Debian unstable or experimental if needed. Upgrade and try again.

Wednesday, 4 January 2012

AIX LVM - Remove Logical Volume copy

Remove LV copy
Using rmlvcopy we can remove the lvcopy from the PV’s
If we want to remove testlv copy from hdisk0

#rmlvcopy testlv 3 hdisk0

After executing the above command third copy of the testlv removed from PV hdisk0, like this we can remove

Unmount FS

Using umount or unmount command we can umount the file system i.e. file system is moved to off line.
#umount /newfs


After this you run the lsfs –a command it wont display /newfs file system details.
#lsfs –a

AIX - User and Group Management


In user management, we can perform the below operations:


1. Create user
2. List user
3. Change user
4. Remove user
5. Set password for users

AIX -Extend Volume Group

Extend VG

We can increase VG size by adding Pv into existing VG, example: extendvg command

#lsvg –p datavg
Hdisk4
Hdisk5

datavg has 2 PV’s now we want to extend datavg, then your command will be

#extendvg datavg hdisk6
After executed command hdisk6 pv added with datavg


#lsvg –l datavg
Hdisk4
Hdisk5
Hdisk6

AIX - LVM - Extend Logical Volume

If we want to increase LV size using extendlv command
#lslv newlv

The above command shows LV size, no of LP’s and some other information about LV,
suppose LV has 10 LP’s and usage is up to 95% full,
that time we can increase the LV size online by adding no of LP’s in newlv i.e.

#extendlv newlv 5
After executing the above command 5 PP’s added with newlv,
then some additional space will available in newlv.
Suppose you want to see this changes again use the lslv command

#lslv newlv (it will show no of LV’s is 15 and some additional space)

AIX - Create LV copy

We can create LV content copy to another PV, after this same LV content is available in Lvcopy configured PV.

#lspv
Hdisk0
Hdisk1
Hdisk2


#lspv –l hdisk1
Assume testlv available in hdisk1, now we will make testlv copy to hdisk2, using
After this testlv data available in both PV, hdisk1 and hdisk2, If hdisk1 is fail, we can recover testlv data from hdisk2


#mklvcopy testlv 2 hdisk2
Testlv –lv name
2- No of copies, (we can make 3 copies also; this case you put 3 and mention hdisk0 then third copy will be available in hdisk0)


#mklvcopy testlv 3 hdisk0 ( It will make third lvcopy on hdisk0
After executing above command testlv is copied to hdisk2
If you want to confirm, execute the following command


#lslv –m testlv (it will show lvcopy details for testlv)
Hdiks1 hdisk2 hdisk0
Testlv (copy1) testlv (copy2) testlv (copy3)

AIX - LVM - VarryOn Volume Group

Varryon VG

This is just for VG activation; some times clients want to deactivate VG for project restriction. After that we want to activate the VG for further data access

Suppose we want to activate testvg, then your command will be

#lsvg
Rootvg
Datavg
Testvg

The above command shows what are VG’s available

#lsvg –o
Rootvg
Datavg

The above commands shows only online VG’s because testvg is offline so we have to activate testvg

#varryonvg testvg

#lsvg –o
Rootvg
Datavg
Testvg

Now above command is display the testvg.

AIX - Varryoff VG

This is just for VG deactivation; some clients want to deactivate VG for project Restriction.
Suppose customer want deactivate testvg then your command will be

#lsvg –o
Rootvg
Datavg
Testvg

#Varryoff testvg

#lsvg –o
Rootvg
Datavg

The above command display only two online VG’s and it will not show testvg because testvg is offline VG.

AIX LVM - Remove Logical Volume copy

Remove LV copy
Using rmlvcopy we can remove the lvcopy from the PV’s
If we want to remove testlv copy from hdisk0

#rmlvcopy testlv 3 hdisk0


After executing the above command third copy of the testlv removed from PV hdisk0, like this we can remove

AIX - LVM - Change Physical Volumes

If we have three PV’s, like hdisk0, hdisk1, hdisk2, now you want to deactivate the hdisk2,

#chpv -vr hdisk2  : To deactivate the hdisk2
#chpv –va hdisk2  : To activate the hdisk2
#chpv –an hdisk2  : hdisk2 is not allocatable
#chpv –ay hdisk2  : hdisk2 is allocatable
#chpv –hn hdisk2  : hotspare no
#chpv –hy hdisk2  : Hotspare yes
#chpv –c hdisk2   : To clear the boot image

AIX - Reduce VG

We can remove the VG using reducevg command, if we want remove testvg and testvg has one pv hdisk9
#lsvg –p testvg
Hdisk9


Now we will remove the pv from testvg
#reducevg –f testvg hdisk9

f- option is used to force reduce, you have data in pv hdisk9,
that time I will not any questions, directly it will remove the pv from testvg.
Suppose 2 PV’s available in testvg then one by one we can reduce the PV’s

AIX - Add, change, and delete:

Volume groups
Logical volumes
Physical volumes
Describe mirroring
Describe striping


Logical Volume Manager

# smit lvm

Logical Volume Manager
Move cursor to desired item and press Enter.

Volume Groups
Logical Volumes
Physical Volumes
Paging Space

F1=Help F2=Refresh F3=Cancel F8=Image
F9=Shell F10=Exit Enter=Do


Volume Groups

Physical Volume (PV)
-Hard disk

Volume Group (VG)
-Collection of related disks (PVs)

SMIT Volume Groups Menu


# smit vg

Volume Groups
Move cursor to desired item and press Enter.

-List All Volume Groups
-Add a Volume Group
-Set Characteristics of a Volume Group
-List Contents of a Volume Group
-Remove a Volume Group
-Activate a Volume Group
-Deactivate a Volume Group
-Import a Volume Group
-Export a Volume Group
-Mirror a Volume Group
-Unmirror a Volume Group
-Synchronize LVM Mirrors
-Back Up a Volume Group
-Remake a Volume Group
-Preview Information about a Backup
-Verify the Readability of a Backup (Tape only)
-View the Backup Log
-List Files in a Volume Group Backup
-Restore Files in a Volume Group Backup

F1=Help F2=Refresh F3=Cancel F8=Image
F9=Shell F10=Exit Enter=Do

List All Volume Groups
# lsvg
rootvg
payrollvg
# lsvg -o
rootvg

List Volume Group Contents

# lsvg rootvg

VOLUME GROUP: rootvg VG IDENTIFIER: 000bc6fd00004c00000000e10fdd7f52
VG STATE: active PP SIZE: 16 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 1084 (17344 megabytes)
MAX LVs: 256 FREE PPs: 1032 (16512 megabytes)
LVs: 11 USED PPs: 52 (832 megabytes)
OPEN LVs: 10 QUORUM: 2
TOTAL PVs: 2 VG DESCRIPTORS: 3
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 2 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 256 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable

List Volume Group Information (Physical Volumes)
# lsvg -p rootvg
rootvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk0 active 159 52 24..00..00..00..28
hdisk1 active 159 78 32..02..00..12..32

List Volume Group Information (Logical Volumes)
# lsvg -l rootvg
rootvg:
LVNAME TYPE LPs PPs PVs LV STATE MOUNT POINT
hd6 paging 8 8 1 open/syncd N/A
hd5 boot 1 1 1 closed/syncd N/A
hd8 jfslog 1 1 1 open/syncd N/A
hd9var jfs 1 1 1 open/syncd /var
hd4 jfs 1 1 1 open/syncd /
hd2 jfs 77 77 1 open/syncd /usr
hd3 jfs 3 3 1 open/syncd /tmp
hd1 jfs 11 11 1 open/syncd /home
hd10opt jfs 2 2 1 open/syncd /opt
lv00 jfs2 1 2 2 open/syncd /home/john
lv01 jfs2 4 4 2 open/syncd /home/fred

AIX - Reduce Volume Group

Reduce VG
We can remove the VG using reducevg command, if we want remove testvg and testvg has one pv hdisk9


#lsvg –p testvg
Hdisk9

Now we will remove the pv from testvg
#reducevg –f testvg hdisk9

f- option is used to force reduce, you have data in pv hdisk9,
that time I will not any questions, directly it will remove the pv from testvg.
Suppose 2 PV’s available in testvg then one by one we can reduce the PV’s

AIX - Quorum - LVCB (Logical Volume control block)

LVCB (Logical Volume control block)

Logical volume control block (LVCB) contains important information about the
Logical volume, such as the number of the logical partitions or disk allocation
Policy. Its architecture and location on the disk depends on the type of the
Volume group it belongs to. For standard volume groups, the LVCB resides on
The first block of user data within the LV. For big volume groups there is
Additional LVCB information in VGDA on the disk. For scalable volume groups
All relevant logical volume control information is kept in the VGDA as part of
The LVCB information area and the LV entry area.


***************************************************************************************************************************
***************************************************************************************************************************

-- AIX - Quorum - VGDA (Volume Group Descriptor Area)


Volume group descriptor area (VGDA) is an area on the disk that contains
Information pertinent to the volume group that physical volume belongs to. It
Also includes information about properties and status of all physical and
Logical volumes that are part of the volume group. The information from VGDA
is used and updated by LVM commands. There is at least one VGDA per
Physical volume. Information from VGDAs of all disks that are part of the
Same volume group must de identical. VGDA internal architecture and location on the disk depends on the type of the volume group (original, big, or
Scalable).


**************************************************************************************************************************
***************************************************************************************************************************

-- VGSA (Volume Group Status Area)


Volume group status area (VGSA) is used to describe the state of all physical
Partitions from all physical volumes within a volume group. The VGSA
indicates if a physical partition contains accurate or stale information. VGSA
Is used for monitoring and maintained data copies synchronization. The
VGSA is essentially a bitmap and its architecture and location on the disk
Depends on the type of the volume group.

AIX - Quorum

The following commands change the quorum for the volume group testvg. This
Attribute determines if the volume group will be varied off or not after losing the
Simple majority of its physical volumes.


To turn off the quorum use the command:
#chvg -Qn testvg


To turn on the quorum use the command:
# chvg -Qy testvg


Quorum is used for data integrity. When we activate quorum in VG it will recover 51% of data in VG
If we have DATAVG, This DATAVG has two PV’s hdisk1, hdisk2.
First PV hdisk1 has 2 * VGDA and 1 *VGSA
Second PV hdisk2 has 1* VGDA and 1*VGSA
Each VGDA has 33% of data, so hdisk1 has 2 VGDA, it will protect 66% of data and Second PV hdisk2 has 1 VGDA, it will protect only 33% data.

AIX - LVM - VarryOn Volume Group

Varryon VG
This is just for VG activation; some times clients want to deactivate VG for project restriction.
After that we want to activate the VG for further data access
Suppose we want to activate testvg, then your command will be

#lsvg
Rootvg
Datavg
Testvg

The above command shows what are VG’s available

#lsvg –o
Rootvg
Datavg

The above commands shows only online VG’s because testvg is offline so we have to activate testvg

#varryonvg testvg

#lsvg –o
Rootvg
Datavg
Testvg


Now above command is display the testvg.

AIX - Varryoff VG

This is just for VG deactivation; some clients want to deactivate VG for project Restriction.
Suppose customer want deactivate testvg then your command will be

#lsvg –o
Rootvg
Datavg
Testvg

#Varryoff testvg
#lsvg –o
Rootvg
Datavg


The above command display only two online VG’s and it will not show testvg because testvg is offline VG

AIX - LVM - Unmirror Volume Group

Using Unmirror command we can Unmirror the VG
#unmirrorvg rootvg hdisk1

PV hdisk1 is removed from rootvg mirror.

AIX - LVM - Synchronize Volume Group

Using Syncvg command we can sync the mirrored Vg and LV copy information’s
If we want to sync lvcopy
#syncvg –l lvname
#syncvg –l testlv


After executing the above command, testlv copy get sync with lv copied PV
If we want to sync mirrored PV’s
#syncvg –v rootvg


The above sync the mirrored PV’s in rootvg

AIX - LVM - Repair File System

Using fsck command we can repair the problematic FS or corrupted FS
If you want check /data FS
#fsck /data


Or directly we can repair the LV
#fsck –Y n /dev/datalv (To fsck the FS associated to /dev/datalv assuming response “Yes”
#fsck –p /dev/datalv (To restore superblock from backup superblock)

AIX - LVM - Remove Logical Volume

If we want to LV testlv from server
#rmlv testlv (If data is available in testlv It will ask confirmation)
#rmlv –f testlv (It won’t ask any confirmation, directly it will delete the data)


After executing the above command testlv removed from the server.

AIX - LVM - Remove File System

Remove FS
Using rmfs command we can remove the file systems
#lsfs –a
/testfs


Before removing the /testfs. That file system should be unmounted.
#umount /testfs
#rmfs /testfs (Deletes FS /newfs and associated LV)


After executing the above command /testfs is removed.
#rmfs –r /testfs (Deletes FS /newfs its mount point and associated LV)

AIX - LVM - Mount File System

After creating the file system, we should mount the file system, without file system mount
we cannot access the file system using mount command we can mount the file system.
Before mount lsfs command is wont display the /newfs file system
#lsfs –a


That /newfs file system detail is not available
#mount /newfs


Now you execute lsfs command, it will show the /newfs details
#lsfs –a

AIX - LVM - Mirror Volume Group

We can do mirroring in AIX, using mirrorvg command and we can create max of three copy of mirror.
If we have two PV’s in rootvg, now we want mirror, Data and OS installed in hdisk0 and now we want to mirror hdisk0 to hdisk1. Then your command will be

#mirrorvg –S –m rootvg hdisk1

S – Backgroup mirror
-m - exact (force) mirror

NOTE: in mirrored VG quorum should be off line because quorum is not recommended for mirror.

AIX - LVM - Migrate Logical Volume

Using migratepv command we can migrate lv from PV to PV
If we want to migrate single LV

#migratepv –l testlv hdisk1 hdisk2
After executing above command testlv LV is moved hdisk2.


Using migratepv command we can move full PV data or single LV from one PV to another PV. This is not copy just cut and past method
If we want to migrate data from PV to PV

#migratepv hdisk1 hdisk2
After executing above command hdisk1 data is moved to hdisk2.

AIX - List LV

Suppose we want see what are the Lv’s available in datavg, then your command will be
#lsvg –l datavg

It will login list LV details
newlv
Now we want see newlv properties, then your command will be
#lslv newlv


The above command is used to display the newlv properties, i.e. available pp’s mount pint, label name, stale partitions. Etc.
#lslv –m newlv – To display the lvcopy information’s

IBM - AIX - List File System

We can list file system details using lsfs command

#lsfs        :  List all filesystems in the /etc/filesystems entry
#lsfs –q     :  List all filesystems with detailed info
#lsfs –a     :  list all filesystems (default)
#lsfs –l     :  specify the output in the list format
#lsfs –c     :  specify the output in the column format
#lsfs –v jfs :  List all jfs filesystems

AIX - LVM - Import Volume Group

Using importvg command we can import the DATAVG to ServerB

First you should connect hdisk3, hdisk4, in ServerB then, run the
#cfgmgr (for hard disk detection)


Then check the PV’s installed or not using lspv command
#lspv (it will display the installed PV’s) if hdisk3, hdisk4 is available then PV’s are configured properly.


Then run the command importvg for import the DATAVG
#importvg –y DATAVG hdisk3 (VG information is added in ODM)
#importvg –y DATAVG hdisk4 (VG information is added in ODM)


NOTE:

If ServerB has VG with same name DATAVG, This case we can rename the importing VG DATAVG to other name,
#importvg –y NEWDATAVG hdisk3
#importvg –y NEWDATAVG hdisk4

Like this we can import.
After importing the DATAVG, we no need to Varryon DATAVG, automatically it will Varryon while importing.

AIX - LVM - Extend Logical Volume

If we want to increase LV size using extendlv command
#lslv newlv

The above command shows LV size, no of LP’s and some other information about LV,
suppose LV has 10 LP’s and usage is up to 95% full, that time we can increase the LV size online by adding no of LP’s in newlv i.e.
#extendlv newlv 5


After executing the above command 5 PP’s added with newlv, then some additional space will available in newlv.
Suppose you want to see this changes again use the lslv command
#lslv newlv (it will show no of LV’s is 15 and some additional space)

AIX - LVM - Export Volume Group

Using exportvg command we can export VG (including all the PV’s) from one server to another server.
If you have ServerA, in this server has DATAVG with two PV’s. Now we want export DATAVG to ServerB
Before exporting the DATAVG, we should Varryoff the DATAVG, i.e. DATAVG is moved to offline.

#varryoff DATAVG (Varryoff the DATAVG)
#exportvg DATAVG (VG information removed from ODM)


Now DATAVG is exported from the ServerA, after this run the following command to verify the export.
#lsvg


It won’t show DATAVG name. Because DATAVG is exported.
Then you should remove PV from the configuration

#rmdev –dl hdisk3
#rmdev –dl hdisk4


After that we can remove the PV’s from ServerA for import DATAVG to ServerB.

AIX - Create LV

All the File systems belongs to individual LV, after creating the VG’s we should create the LV using mklv command
Suppose you want to create LV name as newlv

#mklv –y newlv –t jfs2 datavg 5 hdisk4

-y for confirmation
-t type mentioning the filesystem type i.e. jfs or jfs2,
Datavg – lv created on datavg
5 – 5 PP’s allocated for newlv ( 1 pp size 32MB the newlv size is 32MB*5 = 160MB)
Hdisk4 – that newlv is belongs to PV hdisk4

AIX - Create LV copy

We can create LV content copy to another PV, after this same LV content is available in Lvcopy configured PV.

#lspv
Hdisk0
Hdisk1
Hdisk2

#lspv –l hdisk1

Assume testlv available in hdisk1, now we will make testlv copy to hdisk2, using
After this testlv data available in both PV, hdisk1 and hdisk2, If hdisk1 is fail, we can recover testlv data from hdisk2

#mklvcopy testlv 2 hdisk2

Testlv –lv name
2- No of copies, (we can make 3 copies also; this case you put 3 and mention hdisk0 then third copy will be available in hdisk0)

##mklvcopy testlv 3 hdisk0 ( It will make third lvcopy on hdisk0)

After executing above command testlv is copied to hdisk2
If you want to confirm, execute the following command

#lslv –m testlv (it will show lvcopy details for testlv)
Hdiks1 hdisk2 hdisk0
Testlv (copy1) testlv (copy2) testlv (copy3)

AIX - LVM - Create File System

Create FS
Using crfs command we can create a file system. File systems belongs to LV’s
Whenever we create the file system we should mention the LV name
#crfs –v jfs2 –d testlv –m /newfs (Normal creation)


The /newfs file system created on testlv.
#crfs –v jfs2 –g testvg –a size=64465 –m /newfs (Directly we can create /fs from VG

This case lv name will be lv00 or lv01 like this after that also we can rename the lv name)

AIX - LVM - Change Logical Volume

In this change LV option we can change LV name and permissions for the LV using chlv command.
#chlv –n newlvname oldlvname
#lslv testlv


Output is some details about testlv
#chlv –n newlv testlv

After executing the above command the testlv renamed to newlv
#lslv testlv
Some error message will come i.e. testlv is not found
#lslv newlv

It will show newlv details, because testlv is renamed as newlv.


Changing the LV permissions: If we want to change LV permissions to read only then the command will be
#chlv –p r testlv

After executing the above command testlv permissions changed as read only , so we can only read the LV, we can not copy new files into this LV.

AIX - LVM - Change File System

Using chfs command we can rename and increase the size of the file system online
We want to increase file system size
#chfs –a size=+block size /filesystem name
#chfs –a size=+32m /filesystem name
#chfs-a size=+4g /filesystem name


+block size – We can mention the size using blocks (2048 blocks = 1MB)
+32m – We can mention the size using MB
+4g – We can mention the size using GB


After increasing the file system size, we can verify using commands

#df –k
#ls –q /newfs


#lsfs /newfs
It will display /newfs details


Now we want to rename /newfs to /testfs then your command will be
#chfs –m /testfs /newfs


After executing the above command /newfs renamed as /testfs
We can auto mount the file system while booting using chfs command
#chfs –A /testfs

AIX - List Volume Group

We can list VG information using following commands

#lsvg                   :  It will display the available vg’s
#lsvg datavg        :  It will display full details about datavg only
#lsvg –o              :  It will display the online vg’s
#lsvg – l datavg   :  It will display the all logical volume details across the datavg
#lsvg –p datavg   :  It will display the information about all PV’s in datavg

AIX - Create Voulme Group

We can create VG by using mkvg commands
#mkvg –s 32 –y datavg hdisk4

The above command is creating datavg using pv hdisk4 and pp size is 32MB

#mkvg datavg hdisk4