Showing posts with label LVM. Show all posts
Showing posts with label LVM. Show all posts

Wednesday, May 10, 2017

How to add a disk on AIX Logical Volume Manager (LVM)

In the last post of AIX, I had explained that how we create a logical volume manager on AIX operating system. In this post, I will explain to you how to add a disk on AIX logical volume manager.

LVM (Logical Volume Manager) is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes.With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes.

LVM allows users to create partitions from more than one disk and allows them to extend the filesystem size online within few seconds.

Step by step method to add a disk on LVM.

1. In the first step we will add the physical or virtual disk to the logical partition. Once the new disk is added on the logical partition then we can able to go for next step.

2. Now, rescan your system hardware so that the Operating system can find which new hard disk is add on the server. For this please use the below command to scan the hardware on AIX operating system.

aix:/> cfgmgr

3. In this step, we will check the disk. For example, let’s assume that the new disk is hdisk1, so please run the below command to check the disk.

aix:/> lsdev -Cc disk
hdisk0  Available  Virtual SCSI Disk Drive
hdisk1  Available  Virtual SCSI Disk Drive

aix:/> lspv
hdisk0      00f68f03d1e42951       rootvg          active
hdisk1      00f68f03d20beafd       vstorage        active
hdisk2      00f68f03d20ceb37       vstorage        active

if you see the above both output, you can found that hdisk1 is available to add on Voulme group.

4. In this step, now you need to create a new group and move the new disk hdisk1 in there. Let's assume the new group named is "rootvg". So please find the below command to create a new group and add the disk in it.

aix:/> mkvg -y rootvg hdisk1

5. Now you can look at the size of hdisk1. Please run the below command , you can found the below output regarding the disk space of your disk and this command would not work if it is not associated with the volume group.

aix:/> lspv hdisk1
PHYSICAL VOLUME:    hdisk1                   VOLUME GROUP:     rootvg
PV IDENTIFIER:      00f68f03d1e42951 VG IDENTIFIER     00f68f0300004c0000000153d1e429c1
PV STATE:           active
STALE PARTITIONS:   0                        ALLOCATABLE:      yes
PP SIZE:            128 megabyte(s)          LOGICAL VOLUMES:  17
TOTAL PPs:          799 (102272 megabytes)   VG DESCRIPTORS:   2
FREE PPs:           118 (15104 megabytes)    HOT SPARE:        no
USED PPs:           681 (87168 megabytes)    MAX REQUEST:      256 kilobytes
FREE DISTRIBUTION:  11..00..00..00..107
USED DISTRIBUTION:  149..160..159..160..53
MIRROR POOL:        None

6. In this step , now we will create a log logical volume for jfs2 file system and this needs to be part of vloume group "rootvg".

aix:/> mklv -t jfs2log rootvg 1

As i can not paste the my machine output as I am already add it, You can add at your end , if any issue occur on this stage please comment on the post.

7. Now, we will check the new logical volume (lv) and you can used the below command to check the new logical volume present on the AIX server.Normally on AIX server we are used "loglv00" logical name, as on my machine I used the same name.

aix:/> lsvg
rootvg

aix:/> lsvg -l rootvg
rootvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
hd5                 boot       1       1       1    closed/syncd  N/A
hd6                 paging     404     404     1    open/syncd    N/A
loglv00             jfs2log    1       1       1    open/syncd    N/A
hd4                 jfs2       4       4       1    open/syncd    /

If you see the above both the output, you can find that "rootvg" is voulme group present and in rootvg, you can find the logical volume "loglv00".

8. In this, we will create a logical volume and fixed their size , lets assume we will used 30GB size and used the logical volume name lglv_test.

aix:/> lsvg rootvg
aix:/> mklv -t jfs2 -y lglv_test rootvg 30G
aix:/> mkfs -o log=/dev/loglv00 -V jfs2 /dev/lglv_test

9. In the seconf last step we will mount the newly created file system on the AIX operating system.

aix:/> mkdir /test
aix:/> mount -o log=/dev/loglv00 /dev/lglv_test /test

In this example , we will create a "/test" file system and mount the file system on this folder.

10. In the final step we will make a permament entry of this file system in "/etc/filesystems file so once you take a reboot of AIX server, file system will mount permamently, otherwise you need to mount again if you not made an entry in /etc/filesystems.

Hope this post is useful for you, as this step by step method you can not found in other sites, In case still you are facing any issue related to this topic, please comment on this post, I will revert to you with solution.

Monday, February 20, 2017

How to Increase or extend the size of a Linux LVM by adding a new hard disk

Hello Friends,

This post will cover how to increase the disk space for a VMware virtual machine running Linux that is using logical volume manager (LVM). Firstly we will add a new disk to the virtual machine and then extend the original LVM over this additional space.

As there are a number of different ways to increase disk space but I have also posted simple and step by step method. Using this method I am sure you will increase the space easily.

1. First of all before adding any hard disk please run the below command to check the how much space is currently left on the VG group.

#vgdisplay 









If you see above image you can found the volume group name, in my case it is "rootvg".

2. Now run the below command to see the existing LVM disk is currently used in LVM.

#fdisk -l














You can see the above output, the /dev/sda2 hard disk is in used for existing LVM. Now you can add new hard disk on the server.

3. Once you added the new hard disk on the server to increase the size on Linux LVM, lets assume the new hard disk labelled is /dev/sdb. In this step we will need to partition the new hard disk so we can use it.

#fdisk /dev/sdb

It should show us below message to us for next selection.

root@localhost:~# fdisk /dev/sdb
Command (m for help): n

Please select the "n" for adding a new partition. Once we will select the "n" for new partition it is show to us below screen.

Command action
   e   extended
   p   primary partition (1-4)p

We will select the "p" for primary partition so we will add new had disk /dev/sdb as a primary partition.
----------------------------------------------------------------------------------------
Partition number (1-4): 1

First cylinder (1-2610, default 1): "enter"
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): "enter"
Using default value 2610
----------------------------------------------------------------------------------------
In above screen, we will select 1 for primary partition and make a default settings.

‘t’ is selected to change to a partitions system ID, in this case we change to ’1′ automatically as this is currently our only partition.
----------------------------------------------------------------------------------------
Command (m for help): t
Selected partition 1
----------------------------------------------------------------------------------------
The hex code ’8e’ was entered as this is the code for a Linux LVM which is what we want this partition to be, as we will be joining it with the original Linux LVM which is currently using /dev/sda4.
----------------------------------------------------------------------------------------
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
----------------------------------------------------------------------------------------
‘w’ is used to write the table to disk and exit, all changes that have been done will be saved and then you will be exited from fdisk.
----------------------------------------------------------------------------------------
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
----------------------------------------------------------------------------------------

By using “fdisk -l” now you will be able to see that /dev/sdb1 is listed, this is the new partition created on our newly added /dev/sdb disk.

4. Now we will create a physical volume with this newly added hard disk /dev/sdb1. For physical volume creation we will use "pvcreate" command.

#pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.

In above command output, you can see the /dev/sdb1 physical volume group has been created.

5. Now the most important steps of this post is using physical volume you can extend or create a new volume group.

If you want to extend the logical volume size of existing Volume group then please use the below command and method. 

#vgextend test /dev/sdb1

In my case my VG name is "test" so I will extend the space in existing VG "test".

If you want to create the new logical voume and want to add physical volume in new VG, please use the below command and method.

#vgcreate rootvg /dev/sdb1

In this case my new VG name is "rootvg".

So, as per my this post, you can add new hard disk in to existing volume group or newly created volume group. Using this volume group you can create or extend the Linux LVM size.

Monday, February 6, 2017

LVM and file system basics in HP-UX

Hello Friends,

In my previous post, you can find the simple way to extend or increase the file system size in HP-UX operating system. So now we need to understand also how these file system is created with LVM. So in my new post, i would try to explain you how we will create LVM and file system in HP-UX operating system.

In this post, I will give you an example for HP-UX 11i v2/v3 version operating system. As my current machine keeping same version OS. You can find the LVM creation for Linux in my other post on my blog.

As you know LVM stands for logical volume management system which are used for file creation. Please find the step by step method to create the LVM in HP-UX operating system as describe below.

1. First we will create the physical volume using free disk space. After that we will create the volume group. to create the physical volume we will use "pvcreate" command.
-------------------------------------------------------------------------------------------------------------
hpx:/>pvcreate -f /dev/rdisk/disk1
Physical volume "/dev/rdisk/disk1" has been successfully created.
-------------------------------------------------------------------------------------------------------------
Using "pvcreate" command new physical volume group'/dev/rdisk/disk1 has been created.

2. In second step, we will create the new volume group with the help of physical volume. but before running the creation command we need to create a VG directory in /dev location.Once we will create the directory we will change the ownership and permission of the folder respectively.
-------------------------------------------------------------------------------------------------------------
hpx:/>mkdir -p /dev/vg00    Note: (you can replace volume group name accordingly) 
hpx:/>chown -R root:root /dev/vg00
hpx:/>chmod -R 755 /dev/vg00
-------------------------------------------------------------------------------------------------------------
3. Now we will create a special group device file.In HP-UX each volume group must have a group device special file under its sub directory in /dev. This group DSF is created with the "mknod " command, like any other DSFs the group file must have a major and a minor number.

One of the most important thing while creating the LVM on the HP-UX is major & minor number. For LVM 1.0 volume groups the major number must be 64 and for the LVM 2.0 one must be 128.

For minor number, the first two digits will uniquely identify the volume group and the remaining digits must be 0000.

In our case we’re creating a 1.0 volume group on HP-UX operating system.

hpx:/>cd /dev/vg00
hpx:/dev/vg00>mknod group c 64 0x010000

Now change the ownership to root:sys and the permissions to 640.

hpx:/>chown root:sys group
hpx:/>chmod 640 group

4. Now create the volume group using below command.

hpx:/>vgcreate -s 16 vg00 /dev/disk/disk1
Volume group "/dev/vg00" has been successfully created.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf

In above command , we will create new volume group "vg00" with 4 MB size.

5.  Now your new volume group in HP-UX operating system has been created successfully. You can check the volume group and physical group by using below command.
-------------------------------------------------------------------------------------------------------------
hpx:/> vgdisplay -v vg00
--- Volume groups ---
VG Name                     /dev/vg00
VG Write Access         read/write     
VG Status                    available                 
Max LV                       255    
Cur LV                        0      
Open LV                     0      
Max PV                      16     
Cur PV                        2      
Act PV                        2      
Max PE per PV           6000         
VGDA                        2   
PE Size (Mbytes)       16              
Total PE                     26    
Alloc PE                    0       
Free PE                      26    
Total PVG                  0        
Total Spare PVs         0              
Total Spare PVs in use      0 

 --- Physical volumes ---
 PV Name                   /dev/disk/disk1
 PV Status                   available                
 Total PE                    13       
 Free PE                     13       
 Autoswitch                On
-------------------------------------------------------------------------------------------------------------
In above output you can see the VG Name & PV Name which we created during LVM creation. Now using these Volume group "vg00" we can able to create file system on HP-UX file system.

6. Now in final step we will create the logical volume group in HP-UX using VG.

hpx:/> lvcreate -n vg00_test -L 256 vg00

Logical volume "/dev/vg00/vg00_test_S2" has been successfully created with
character device "/dev/vg00/rvg00_test_S2".
Logical volume "/dev/vg00/vg00_test_S2" has been successfully extended.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf

If our example the logical volume group name is "vg00_test". If you see the syntax of above command "-n" option is used for new logical volume name and "-L" option is used for specifying the file system size in MB.

hpx:/> lvdisplay  /dev/vg00/vg00_test

Using this command you can check newly created logical volume group on HP-UX operating system.

7. For file system creation in HP-UX, we will use below method step by step.

hpx:/>newfs -F vxfs -o largefiles /dev/vg00/vg00_test
version 7 layout 393216 sectors, 393216 blocks of size 1024, log size 1024 blocks large files supported

In above syntax, we will create a new file system, now we will create the mount point where we mount this file system
-------------------------------------------------------------------------------------------------------------
hpx:/>mkdir /test
hpx:/>mount /dev/vg00/vg00_test /test.
-------------------------------------------------------------------------------------------------------------
Using above method /test file system has been created successfully and if you want to check the current size of file system you can use "bdf  /dev/vg00/vg00_test" command.

Hope, this post is useful for you. If you have any questions related this post please comment on it. I will try to provide the simple and step by step solution to you.

Friday, February 3, 2017

How to Shrink or reduce size of LVM partitons in RHEL/CentOS

LVM (Logical Volume Manager) is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes.With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes.

LVM allows users to create partitions from more than one disk and allows them to extend the filesystem size online within few seconds.

In this post, we will see how we can shrink the size of an LVM partition without losing data.

On my linux virtual machine, the VG name is “rootvg” and LV name is “Vibhor” which has 60 GB size. I want to reduce the LV size to 4GB. Please note down the following points before proceeding with the shrinking of filesystem.

  • Make sure the current disk usage of the filesystem is less than the size to which you are going to reduce the logical volume.
  • Always take a backup of filesystem data before doing any size change in LVM as a simple mistake in command can cause filesystem corruption and hence loss of data.

Now, please find the below steps which we need to follow for reduce or shrink the partition size.

Umount the filesystem:

We will check the file system through fsck command but before running fsck on the filesystem, it should be unmounted.You can unmount the filesystem “/vibhor” as follows.

#umount /Vibhor

Performing filesystem check:
Before proceeding with reducing filesystem, “fsck” should be done in order to avoid inconsistency of filesystem data.
#e2fsck –f /dev/mapper/rootvg/rootvg_vibhor

Resizing filesystem:

Now, we will reducing the size of the Logical Volume, but before we need to reduce the filesystem in it. The command “resize2fs” can be used for this as follows.

#resize2fs –p /dev/mapper/rootvg/rootvg_vibhor 4G

This will decrease or shrink the filesystem size to 4GB.

Reducing the LV size:

After reduce or shrink the filesystem, we can reducing the LV as given below.

#lvreduce –L 4G /dev/mapper/rootvg/rootvg_vibhor

This will reduce the logical volume size to 4 GB. Now I will mount the filesystem again and check it using the command “df –h”. the file system has reduced to 4 GB without losing any data.

#mount /Vibhor
#df –h

This output will show you the reduce filesystem size.