Linux - How to add storage to an OEL 5 update 4 Linux VMWare Machine

About

When you increase the disk capacity of a VMWare virtual machine, you need to perform some operation to add this capacity to the file system.

The basic installation of Oracle Entreprise Linux use Linux Logical Volume Manager to configure the storage management.

Prerequisite

Basic knowledge of:

Steps

Type of storage

New Disk

[root@di-obia-01 ~]# fdisk /dev/sdb
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 65270.
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 partition
   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-65270, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-65270, default 65270):
Using default value 65270

Command (m for help): p

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+  83  Linux

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

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

Disk Storage Augmentation

Do not attempt to create a partition on a device that is in use.

Before creating a partition, boot into rescue mode (or you can also unmount any partitions on the device and turn off any swap space on the device).

Start parted, where /dev/sda is the disk on which to create the partition:

  • use the print command to get information on the file system
  • and create the partition with mkpart (or fdisk)
[root@ebs121 ~]# parted /dev/sda
GNU Parted 1.8.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print

Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 376GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  107MB   107MB   primary  ext3         boot
 2      107MB   21.5GB  21.4GB  primary               lvm

(parted) mkpart primary 21.5GB 376GB
(parted) print

Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 376GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  107MB   107MB   primary  ext3         boot
 2      107MB   21.5GB  21.4GB  primary               lvm
 3      21.5GB  376GB   354GB   primary

Add the partition to the current logical volume

Create the physical volume

[root@ebs121 ~]# fdisk -l

Disk /dev/sda: 375.8 GB, 375809638400 bytes
255 heads, 63 sectors/track, 45689 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM
/dev/sda3            2611       45689   346032067+  83  Linux
[root@ebs121 ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created

The partition must be a primary partition and not an extended

Extend the Volume Group

[root@ebs121 ~]# vgextend VolGroup00 /dev/sda3
  Volume group "VolGroup00" successfully extended
[root@ebs121 ~]# vgdisplay VolGroup00
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               349.88 GB
  PE Size               32.00 MB
  Total PE              11196
  Alloc PE / Size       636 / 19.88 GB
  Free  PE / Size       10560 / 330.00 GB
  VG UUID               ZWF1oZ-SxTf-08EL-KhYO-C7nf-L22q-ZgUuZO

Extend the logical volumne

[root@ebs121 ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                B0EwV0-5XTH-1GLF-LTW2-8q9q-3Ou0-rsggEM
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                17.94 GB
  Current LE             574
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                CL7Kz2-pyWf-9xtB-1VnG-JZ1n-m4u7-xHEmLA
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.94 GB
  Current LE             62
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
[root@ebs121 ~ ]# lvextend -L+330G /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 347.94 GB
  Logical volume LogVol00 successfully resized

Exploit the additional storage

Once a logical volume has been extended, the underlying file system can be expanded to exploit the additional storage now available on the LV.

[root@ebs121 ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      18219452  11465604   5813408  67% /
/dev/sda1               101086     11940     83927  13% /boot
tmpfs                  1521384         0   1521384   0% /dev/shm
[root@ebs121 ~]# resize2fs /dev/mapper/VolGroup00-LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol00 to 91209728 (4k) blocks.
[root@ebs121 ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                     353445220  11490496 323720280   4% /
/dev/sda1               101086     11940     83927  13% /boot
tmpfs                  1521384         0   1521384   0% /dev/shm





Discover More
Linux - Adding storage depends of LVM

When you need to add disk storage to a linux environement, the tasks depend of if you want to use or not the Linux Logical Volume Manager.. Without LVM, a filesystem is created inside a partition....
Linux - Adding storage without LVM

When you add a disk device to your system, you need to add this storage in your Linux environment When you improve the disk capacity of your Virtual Vmware Machine, you just need to configure the device...
Linux - Storage

Linux - Storage



Share this page:
Follow us:
Task Runner