Increase the filesystem size

Hi
I am using oracle linux 6.4. My hard drive capacity is 500 GB. my filesystem size onbly 50GB. I would like to extend my filesystem size to around 100GB. I tried many codes but still I am not able.
this is the output of df -h :

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G  3.6G   44G   8% /
tmpfs                 1.9G  260K  1.9G   1% /dev/shm
/dev/sda2             485M   55M  405M  12% /boot
/dev/sda1             200M  260K  200M   1% /boot/efi
/dev/sdb1              16G  9.5G  5.7G  63% /media/BE3E-B000

and df -k :

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      51606140   3744716  45239984   8% /
tmpfs                  1968532       260   1968272   1% /dev/shm
/dev/sda2               495844     55756    414488  12% /boot
/dev/sda1               204580       260    204320   1% /boot/efi
/dev/sdb1             15858688   9941184   5917504  63% /media/BE3E-B000

Check the output of pvs, just to make sure there is room to extend the LV. If there's enough space:

# lvextend -L+50G /dev/mapper/VolGroup-lv_root
# resize2fs /dev/mapper/VolGroup-lv_root

Otherwise the free space may be unpartitioned and we need to take different steps.

1 Like

Hi
Thanks for your reply. this is the output of the pvs. I don't have free spaces. I have tried your code before, but because of the freespace I won't be able to extend the filesystem size.
I appreciate if you help me.
Output of pvs :

 
Code:
[root@localhost ~]# pvs
  PV         VG       Fmt  Attr PSize   PFree
  /dev/sda3  VolGroup lvm2 a--  465.07g    0

Hi.

Is Linux running in a virtual machine, or on the physical hardware?

Assuming the latter, it's likely that the remaining ~450 GB is unpartitioned, depending on what options you selected during the installation.

You can check in fdisk, or the graphical palimpsest partitioning tool, if you prefer. You can create a new partition of the required size.

For example, here's an example where I've created a new partition of 5GB from unpartitioned space on /dev/sda, using fdisk:

[root@admin ~]# fdisk -uc /dev/sda

Command (m for help): p

Disk /dev/sda: 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
Disk identifier: 0x0003bc8c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    13314047     6144000   8e  Linux LVM

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First sector (13314048-41943039, default 13314048): (pressed Enter to accept default)
Using default value 13314048
Last sector, +sectors or +size{K,M,G} (13314048-41943039, default 41943039): +5G

Command (m for help): p

Disk /dev/sda: 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
Disk identifier: 0x0003bc8c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    13314047     6144000   8e  Linux LVM
/dev/sda3        13314048    23799807     5242880   83  Linux

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): p

Disk /dev/sda: 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
Disk identifier: 0x0003bc8c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    13314047     6144000   8e  Linux LVM
/dev/sda3        13314048    23799807     5242880   8e  Linux LVM

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

Calling ioctl() to re-read partition table.

Everything I typed is in red. You'll need to reboot to update the partition table.

Now run these commands, substituting volume, volume group, logical volume names and sizes for your own:

[root@admin ~]# pvcreate /dev/sda3 # <-- for me this is what is new, in blue, above
  Physical volume "/dev/sda3" successfully created
[root@admin ~]# vgextend rootvg /dev/sda3
  Volume group "rootvg" successfully extended
[root@admin ~]# pvs
  PV         VG       Fmt  Attr PSize  PFree  
  /dev/sda2  rootvg   lvm2 a--   5.84g 320.00m
  /dev/sda3  rootvg   lvm2 a--   4.97g   4.97g
  /dev/sdb   dist01vg lvm2 a--  20.00g      0 
[root@admin ~]# vgdisplay -s
  "dist01vg" 20.00 GiB [20.00 GiB used / 0    free]
  "rootvg" 10.81 GiB [5.53 GiB  used / 5.28 GiB free]
[root@admin ~]# 
[root@admin ~]# lvextend -L+5G /dev/mapper/rootvg-rootlv # <-- You can substitute -l+100%FREE for -L+5G if there isn't quite 5GB of free space
  Extending logical volume rootlv to 9.03 GiB
  Logical volume rootlv successfully resized
[root@admin ~]# resize2fs /dev/mapper/rootvg-rootlv 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/rootvg-rootlv is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/mapper/rootvg-rootlv to 2367488 (4k) blocks.
The filesystem on /dev/mapper/rootvg-rootlv is now 2367488 blocks long.

If Linux is running in a virtual machine, you should add a new hard disk, then run the same commands for (probably) /dev/sdb.

Dear Scott
Thanks alot for your reply. I have followed your code for creating a new partition and I assigned +100G to this. everything was successfull and as you were requested to do a reboot to update the partition, I made a reboot. But I am not able to to access to my GUI. and I'm having an error that is :

****An error ocurred during the file system check.
**** Dropping you to a shell; the system will reboot
****when you leave the shell.
****Warning -- SELinux is active
****Disabling security enforment for system recovery.
**** Run 'setenforce 1' to reenable.

, I run the fsck but it is just hanging, showing pages like matrix and just passing numbers fast. I don't whats happened to my OS.
anyway, maybe I format my pc. But as you mention is it possible to just partition the freespace during OS installation. I want to install Oracle Linux 6.4
I haven't seen any pages during installation regarding to the partitions .

I really appreciate your help and support

Can you show the output of:

# fdisk -ucl /dev/sda

(assuming you created the new partition on /dev/sda)

Assuming you have made no other changes, you can delete the partition you just created, being careful not to delete the wrong one, then reboot again.

hi.
this is the out put of Fdisk -ucl /dev/sda

WARNING : GPT(GUID partition table) detected on '/dev/sda'!the util doesn't support GPT, Use GNU Parted.

Disk /dev/sda : 500.1 GB. 500107862016 bytes
255 heads, 63 sectors,/track , 60801 cylinders, total 976773168 sectors
units = sectors of 1*512 = 512 bytes
sector size ( logical/phisycal): 512 bytes / 512 bytes
I/O size (minimum/optimal:512 bytes/512 bytes
Disk identifier 0*000000000

Device Boot       Start           End            Blocks              ID              SYSTEM
/dev/sda1          1                976773167  488386583+       ee          GPT