Grow file system on Fedora on VMWare

In this post I would like to show how to increase file system space on installed Fedora VMWare instance. You might need it if you use VMWare (and we know many people do) to spin VMs for Selenium testing.

In this particular case I use I installed Fedora and allocated 10GB but later I started using this VM for quite large databases and free space quickly disappeared.

# df -k
Filesystem                    1K-blocks    Used Available Use% Mounted on
devtmpfs                         498132       0    498132   0% /dev
tmpfs                            508060       0    508060   0% /dev/shm
tmpfs                            508060     772    507288   1% /run
/dev/mapper/vg_fedora-lv_root   7641992 6590912    656228  91% /
tmpfs                            508060       0    508060   0% /sys/fs/cgroup
tmpfs                            508060       0    508060   0% /media
/dev/sda1                        487652   84379    377673  19% /boot
# fdisk -l
 
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders, total 20971520 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: 0x000e3a8c
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    20971519     9972736   8e  Linux LVM
 
 
Disk /dev/mapper/vg_fedora-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders, total 4128768 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 /dev/mapper/vg_fedora-lv_root: 8086 MB, 8086618112 bytes
255 heads, 63 sectors/track, 983 cylinders, total 15794176 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

To grow disk space I went to VMWare console and added one more disk as shown below:
 
 
Adding a disk to existing VMWare VM
 
 
Now we can see a new disk in “fdisk -l” command output.

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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

Now we create partition sdb1 covering all new disk using “fdisk /dev/sdb”.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set
 
Command (m for help): v
Remaining 2047 unallocated 512-byte sectors
 
Command (m for help): w
The partition table has been altered!

Finally we just expand our volume group and file system:

pvcreate /dev/sdb1
vgextend vg_fedora /dev/sdb1
lvextend -l +100%FREE /dev/mapper/vg_fedora-lv_root
resize2fs /dev/mapper/vg_fedora-lv_root
Print this post | Home

Comments are closed.