LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-10-2012, 10:58 PM   #1
sysmicuser
Member
 
Registered: Mar 2010
Posts: 247

Rep: Reputation: 0
Unhappy fdisk and df giving different hard disk size


Hi Guys.

I am using host operating system as windows xp and guest as centos 6 with virtualization software as Virtual Box.

I had issue with hard disk size of guest so increased it successfully with VirtualBox command line argument.
VBoxmanage modifyhd "path\to\vdi image file\centos60-full.vdi" --resize 40960

all good but now, if we have look df -h still shows old size

fdsik does gives information about 40Gb hard disk size.


[user01@centos60-full ~]$ su -
Password:
[root@centos60-full ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_centos60full-lv_root
16G 12G 2.8G 82% /
tmpfs 1012M 112K 1012M 1% /dev/shm
/dev/sda1 485M 48M 412M 11% /boot
C_DRIVE 233G 137G 97G 59% /media/sf_C_DRIVE
/dev/sr0 44M 44M 0 100% /media/VBOXADDITIONS_4.1.8_75467
[root@centos60-full ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e134f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM

Disk /dev/mapper/vg_centos60full-lv_root: 16.7 GB, 16684941312 bytes
255 heads, 63 sectors/track, 2028 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_centos60full-lv_root doesn't contain a valid partition table

Disk /dev/mapper/vg_centos60full-lv_swap: 4261 MB, 4261412864 bytes
255 heads, 63 sectors/track, 518 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_centos60full-lv_swap doesn't contain a valid partition table
[root@centos60-full ~]#


Please assit.

Many thanks in advance.
 
Old 01-10-2012, 11:04 PM   #2
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,747

Rep: Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977
You increased the disk size (what fdisk measures), but not the partition or filesystem size (what df measures).

You'll need to expand the partition to fill the empty space that was created when you expanded the disk. Same thing that happens when you have two partitions on a disk and delete one of them, you end up with a bunch of free space on the disk. The second partition won't automatically expand to fill it, you have to do that by hand.

Last edited by suicidaleggroll; 01-10-2012 at 11:06 PM.
 
1 members found this post helpful.
Old 01-10-2012, 11:09 PM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
What suicidaleggroll said.

One utility to resize partitions (and the filesystems they contain): gparted

You will need to download an ISO of a Live CD that has gparted on it, boot your virtual machine off the Live CD image, run gparted to resize the partition and filesystem, and then reboot your virtual machine. You cannot run gparted on a mounted, active filesystem--which is why you need an ISO of a Live CD.
 
1 members found this post helpful.
Old 01-10-2012, 11:43 PM   #4
sysmicuser
Member
 
Registered: Mar 2010
Posts: 247

Original Poster
Rep: Reputation: 0
Thanks gys, is there not there any better way to do it online?

I really want that 40GB available ASAP.

Any magical command to do?
 
Old 01-10-2012, 11:52 PM   #5
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,747

Rep: Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977
Nope, you can't modify the root partition and filesystem while it's mounted and running. You have to jump through these same hoops with Windows or any other OS too.
Your only option if you want the space without shutting down and running parted on a live cd is to add a second partition to use up the free space, and mount it in a new directory. "/" won't be expanded to the new size, but the additional space will be available in your new filesystem mounted at say "/mnt/extra/".
 
1 members found this post helpful.
Old 01-11-2012, 11:15 AM   #6
wpeckham
Member
 
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix
Posts: 765

Rep: Reputation: 172Reputation: 172
Correction

You do not have to jump through that particular hoop with EVERY OS, you can expand (but not shrink) some filesystem while they are mounted when running some operating systems. I am familiar with AIX from IBM. Those capabilities are ON THE WAY for several file system under Linux, but I cannot tell you that they are production ready today.

BTW: If you want to research a few interesting things: AIX uses JFS or JFS2 as the native FS. Linux capability will likely be based upon EXT4 on LVM volumes: that was closest when last I checked.

Alas, none of that helps the OP RIGHT NOW, but may be something to keep in mind for that next system build.
 
1 members found this post helpful.
Old 01-11-2012, 06:48 PM   #7
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 286

Rep: Reputation: 70
Hi Sysmicuser.

Yes you can enlarge your mounted ext[234] filesystem while mounted. Checkout the tool resize2fs.

But remember as with all actions that make changes to your filesytem. Make sure you got a valid backup.
 
1 members found this post helpful.
Old 01-11-2012, 07:08 PM   #8
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by gdejonge
Yes you can enlarge your mounted ext[234] filesystem while mounted. Checkout the tool resize2fs.
That is not what the man page says.
Code:
RESIZE2FS(8)                                                                      RESIZE2FS(8)

NAME
       resize2fs - ext2/ext3/ext4 file system resizer

SYNOPSIS
       resize2fs [ -fFpPM ] [ -d debug-flags ] [ -S RAID-stride ] device [ size ]

DESCRIPTION
       The  resize2fs  program  will  resize ext2, ext3, or ext4 file systems.  It can be used to
       enlarge or shrink an unmounted file system located on device.  If the filesystem is mounted,
       it can be used to expand the size of the mounted filesystem, assuming the kernel supports
       on-line resizing.  (As of this writing, the Linux 2.6 kernel supports on-line resize for
       filesystems mounted using ext3 only.).
ext2 and ext4 cannot be expanded while mounted according to the man page. Only ext3 is supported and only with a 2.6 kernel.

While CentOS 6 most certainly uses a 2.6 kernel, we do not know what filesystem the OP is using.

Furthermore, the resize2fs man page goes on to state:
Code:
       The resize2fs program does not manipulate the size of partitions.  If you wish to
       enlarge a filesystem, you must make sure you can expand the size of the underlying
       partition first.  This can be done using fdisk(8) by deleting  the partition and
       recreating it with a larger size or using lvextend(8), if you're using the logical volume
       manager lvm(8).  When recreating the partition, make sure you create it with the same
       starting disk cylinder as before!  Otherwise, the resize operation will certainly not work,
       and you may lose your entire filesystem.  After running fdisk(8), run resize2fs to resize
       the ext2 filesystem to use all of the space in the  newly  enlarged partition.
The OP must still expand the partition to make use of the newly available space. And I don't know of any utility that allows for mounted partition resizing.

Last edited by Dark_Helmet; 01-11-2012 at 07:20 PM.
 
1 members found this post helpful.
Old 03-14-2012, 08:33 AM   #9
sysmicuser
Member
 
Registered: Mar 2010
Posts: 247

Original Poster
Rep: Reputation: 0
Thanks Guys for all your help.

I am closing this thread as SOLVED.

Cheers.
sysmicuser
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change disk size by editing disk information on the hard disk? xptchina Linux - Virtualization and Cloud 2 12-16-2010 08:12 AM
Display Free Hard Disk Space using Fdisk amirsd Linux - Newbie 5 01-27-2010 01:35 PM
cannot use 100% of hard disk, fdisk / parted / partition question lucastic Linux - Hardware 5 12-02-2005 08:58 PM
Hitachi scsi hard disk fdisk curiosity/conundrum rharvey@cox Linux - Hardware 4 11-07-2003 08:31 AM
Hitachi SCSI hard disk fdisk definition rharvey@cox *BSD 2 10-27-2003 04:28 AM


All times are GMT -5. The time now is 11:37 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration