Expanding root disk

1. increase vm disk from ESXi console from 20GB to 100GB

2. login as root
# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000462f5
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          499712    41943039    20721664   8e  Linux LVM
-We can see that current disk size is 107.4GB
Disk /dev/sda: 107.4 GB, 107374182400 bytes
But currently we use only
Disk /dev/mapper/rootvg-rootvol: 18.1 GB, 18144559104 bytes
+
Disk /dev/mapper/rootvg-swapvol: 1023 MB, 1023410176 bytes
# df -h
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol   17G  3.1G   13G  20% /
none                        4.0K     0  4.0K   0% /sys/fs/cgroup
udev                        3.9G  4.0K  3.9G   1% /dev
tmpfs                       798M  3.0M  795M   1% /run
none                        5.0M     0  5.0M   0% /run/lock
none                        3.9G     0  3.9G   0% /run/shm
none                        100M     0  100M   0% /run/user
/dev/sda1                   232M   42M  175M  20% /boot
# fdisk /dev/sda
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
Partition type:
p   primary (2 primary, 0 extended, 2 free)
e   extended
Select (default p): p
Partition number (1-4, default 3):
Using default value 3
First sector (41943040-209715199, default 41943040):
Using default value 41943040
Last sector, +sectors or +size{K,M,G} (41943040-209715199, default 209715199):
Using default value 209715199

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)

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

# reboot
# pvcreate /dev/sda3
Physical volume “/dev/sda3” successfully created

# vgdisplay
— Volume group —
VG Name               rootvg
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  5
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                1
Act PV                1
VG Size               19.76 GiB
PE Size               4.00 MiB
Total PE              5058
Alloc PE / Size       4570 / 17.85 GiB
Free  PE / Size       488 / 1.91 GiB
VG UUID               rD0jFD-GNsT-3ikl-Zfpy-hqy4-cz7W-GF9PeU

# vgextend rootvg /dev/sda3
Volume group “rootvg” successfully extended

# pvscan
PV /dev/sda2   VG rootvg   lvm2 [19.76 GiB / 1.91 GiB free]
PV /dev/sda3   VG rootvg   lvm2 [80.00 GiB / 80.00 GiB free]
Total: 2 [99.75 GiB] / in use: 2 [99.75 GiB] / in no VG: 0 [0   ]

# lvdisplay
— Logical volume —
LV Path                /dev/rootvg/rootvol
LV Name                rootvol
VG Name                rootvg
LV UUID                VjDqgV-ZlwK-H9J7-4gJo-OJBR-cXNH-kK0F7D
LV Write Access        read/write
LV Creation host, time unl01, 2014-10-03 06:34:04 +0000
LV Status              available
# open                 1
LV Size                16.90 GiB
Current LE             4326
Segments               2
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           252:0

— Logical volume —
LV Path                /dev/rootvg/swapvol
LV Name                swapvol
VG Name                rootvg
LV UUID                U6SI57-45kI-wM4c-E0eq-yu3y-8eLI-dzJMjb
LV Write Access        read/write
LV Creation host, time unl01, 2014-10-03 06:34:22 +0000
LV Status              available
# open                 2
LV Size                976.00 MiB
Current LE             244
Segments               1
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           252:1

# lvextend /dev/rootvg/rootvol /dev/sda3
Extending logical volume rootvol to 96.89 GiB
Logical volume rootvol successfully resized

# resize2fs /dev/rootvg/rootvol
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/rootvg/rootvol is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 7
The filesystem on /dev/rootvg/rootvol is now 25400320 blocks long.

# df -h
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol   96G  3.1G   89G   4% /
none                        4.0K     0  4.0K   0% /sys/fs/cgroup
udev                        3.9G  4.0K  3.9G   1% /dev
tmpfs                       798M  3.0M  795M   1% /run
none                        5.0M     0  5.0M   0% /run/lock
none                        3.9G     0  3.9G   0% /run/shm
none                        100M     0  100M   0% /run/user
/dev/sda1                   232M   42M  175M  20% /boot
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