Re-Partition and update of LVM

In one of my posts mentioned increasing the VM disk (VMDK) size and if you are using it under LVM then we need to partition and resize it.

pre ns1sriibrrs  /dev/mapper <8> # lsblk
NAME                              MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0                                11:0    1  1024M  0 rom 
sda                                 8:0    0   200G  0 disk
├─sda1                              8:1    0   500M  0 part /boot
└─sda2                              8:2    0 199.5G  0 part
  ├─VolGroup00-LogVol03 (dm-0)    253:0    0     1G  0 lvm  [SWAP]
  ├─VolGroup00-lvolroot (dm-1)    253:1    0   3.9G  0 lvm  /
  ├─VolGroup00-lvolhome (dm-2)    253:2    0   500M  0 lvm  /home
  ├─VolGroup00-lvolvar (dm-3)     253:3    0     4G  0 lvm  /var
  ├─VolGroup00-lvoldb2das (dm-4253:4    0   100M  0 lvm  /home/shared/db2das
  ├─VolGroup00-lvoldb2inst (dm-5) 253:5    0   185G  0 lvm  /home/shared/db2inst
  ├─VolGroup00-lvolopt (dm-6)     253:6    0     4G  0 lvm  /opt
  └─VolGroup00-lvoldb2fenc (dm-7) 253:7    0    60M  0 lvm  /home/shared/db2fenc
pre ns1sriibrrs  /dev/mapper #
Now we need to re-partition so that – Partition 2 where LVM configured can see the increased storage. This is done in two steps.
Step1: Delete the existing partition 2 and create new one
Step2: After creating new partition we also need to change the type from “Linux” to “Linux LVM”
pre ns1sriibrrs  /sys/class/scsi_device <1> # fdisk /dev/sda          
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switchoff the mode (command 'c') and change display units to
         sectors (command 'u').
Command (m forhelp): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print thismenu
   n   add a newpartition
   o   create a newempty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a newempty 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 forhelp): p
Disk /dev/sda: 322.1GB, 322122547200bytes
255heads, 63sectors/track, 39162cylinders
Units = cylinders of 16065* 512= 8225280bytes
Sector size (logical/physical): 512bytes / 512bytes
I/O size (minimum/optimal): 512bytes / 512bytes
Disk identifier: 0x00039662
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           16451200083Linux
Partition 1does not end on cylinder boundary.
/dev/sda2              64261092092021768e  Linux LVM
Partition 2does not end on cylinder boundary.
Command (m forhelp): d
Partition number (1-4): 2
Command (m forhelp): p
Disk /dev/sda: 322.1GB, 322122547200bytes
255heads, 63sectors/track, 39162cylinders
Units = cylinders of 16065* 512= 8225280bytes
Sector size (logical/physical): 512bytes / 512bytes
I/O size (minimum/optimal): 512bytes / 512bytes
Disk identifier: 0x00039662
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           16451200083Linux
Partition 1does not end on cylinder boundary.
Command (m forhelp): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (64-39162, default64):
Using defaultvalue 64
Last cylinder, +cylinders or +size{K,M,G} (64-39162, default39162):
Using defaultvalue 39162
Command (m forhelp): p
Disk /dev/sda: 322.1GB, 322122547200bytes
255heads, 63sectors/track, 39162cylinders
Units = cylinders of 16065* 512= 8225280bytes
Sector size (logical/physical): 512bytes / 512bytes
I/O size (minimum/optimal): 512bytes / 512bytes
Disk identifier: 0x00039662
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           16451200083Linux
Partition 1does not end on cylinder boundary.
/dev/sda2              643916231405574183Linux
Command (m forhelp): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2to 8e (Linux LVM)
Command (m forhelp): p
Disk /dev/sda: 322.1GB, 322122547200bytes
255heads, 63sectors/track, 39162cylinders
Units = cylinders of 16065* 512= 8225280bytes
Sector size (logical/physical): 512bytes / 512bytes
I/O size (minimum/optimal): 512bytes / 512bytes
Disk identifier: 0x00039662
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           16451200083Linux
Partition 1does not end on cylinder boundary.
/dev/sda2              64391623140557418e  Linux LVM
Command (m forhelp): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The newtable will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
pre ns1sriibrrs  /sys/class/scsi_device <1> #
 
pre ns1sriibrrs  ~ # fdisk -l /dev/sda
Disk /dev/sda: 322.1GB, 322122547200bytes
255heads, 63sectors/track, 39162cylinders
Units = cylinders of 16065* 512= 8225280bytes
Sector size (logical/physical): 512bytes / 512bytes
I/O size (minimum/optimal): 512bytes / 512bytes
Disk identifier: 0x00039662
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           16451200083Linux
Partition 1does not end on cylinder boundary.
/dev/sda2              64391623140557418e  Linux LVM
pre ns1sriibrrs  ~ #
Run “partprobe” to realize the new partition but most of the times I need to restart the VM to see it.
pre ns1sriibrrs  ~ # pvresize /dev/sda2
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
pre ns1sriibrrs  ~ #
 
pre ns1sriibrrs  ~ # lvresize -r -L +50G /dev/VolGroup00/lvoldb2inst
  Size of logical volume VolGroup00/lvoldb2inst changed from 185.00 GiB (47360 extents) to 235.00 GiB (60160 extents).
  Logical volume lvoldb2inst successfully resized.
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup00-lvoldb2inst is mounted on /home/shared/db2inst; on-line resizing required
old desc_blocks = 12, new_desc_blocks = 15
Performing an on-line resize of /dev/mapper/VolGroup00-lvoldb2inst to 61603840 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-lvoldb2inst is now 61603840 blocks long.
pre ns1sriibrrs  ~ #

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s