LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   DF reports wrong disk size (https://www.linuxquestions.org/questions/linux-newbie-8/df-reports-wrong-disk-size-681952/)

pobman 11-08-2008 05:54 AM

DF reports wrong disk size
 
Hello,

I needed to move my ubuntu install from /dev/sda6 (5GB) partition to /dev/sda3 (30GB) partition. I never thought I'd use ubuntu that much so put it on a small test partition.

I have used partimage to create an image of sda6 then restored it to sda3.

When I do a df -h I get the wrong output.
I did investigate using tune2fs -m -0 /dev/sda3 regarding reserved space for /root but this did not help.

I have also tried the resize command.

Please can someone tell me how to correct this.

Code:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3            5.1G  4.2G  672M  87% /
varrun                633M  164K  633M  1% /var/run
varlock              633M    0  633M  0% /var/lock
udev                  633M  72K  633M  1% /dev
devshm                633M  12K  633M  1% /dev/shm
lrm                  633M  39M  594M  7% /lib/modules/2.6.24-19-generic/volatile
/dev/sda3              30G  4.2G  26G  15% /sda3
gvfs-fuse-daemon      5.1G  4.2G  672M  87% /root/.gvfs

Code:

fdisk -l
/dev/sda3            4605        8453    30917092+  83  Linux

Also my grub partition is not correct, I tried to reinstall grub using.

>grub
>setup (hd0,2)

but something is still not right as it is using the /sda6 menu.lst options.

pixellany 11-08-2008 07:16 AM

When you copy a partition at the byte level (with dd or similar tools), you are copying the entire filesystem---which will be the same size even in a newer, larger, space. I'm not sure what partition resizing tools do in such a situation. (What "resize command" did you use?)

As for installing GRUB, the shell method you show requires 3 commands:
grub
root
setup

Example, to point GRUB to drive 1, partition 3 for its files, and then install the the MBR of drive 1:
grub
root (hd0,2)
setup (hd0)

(remember that GRUB counts from zero)

VinayatLQ 11-12-2008 09:33 AM

I have the same problem. In my case I am trying to use partimage from a 40GB HDD to a 80GB HDD.
When I do a df -h I get the following on 80GB
Code:

Filesystem                Size      Used Available Use% Mounted on
/dev/sda3                35.9G    22.5G    11.6G  66% /

where as the sfdisk -s /dev/sda3 I get the following on 80GB
Code:

#sfdisk -s /dev/sda3
77352975

Any way out of this?

Quote:

Originally Posted by pobman (Post 3335238)
Hello,

I needed to move my ubuntu install from /dev/sda6 (5GB) partition to /dev/sda3 (30GB) partition. I never thought I'd use ubuntu that much so put it on a small test partition.

I have used partimage to create an image of sda6 then restored it to sda3.

When I do a df -h I get the wrong output.
I did investigate using tune2fs -m -0 /dev/sda3 regarding reserved space for /root but this did not help.

I have also tried the resize command.

Please can someone tell me how to correct this.

Code:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3            5.1G  4.2G  672M  87% /
varrun                633M  164K  633M  1% /var/run
varlock              633M    0  633M  0% /var/lock
udev                  633M  72K  633M  1% /dev
devshm                633M  12K  633M  1% /dev/shm
lrm                  633M  39M  594M  7% /lib/modules/2.6.24-19-generic/volatile
/dev/sda3              30G  4.2G  26G  15% /sda3
gvfs-fuse-daemon      5.1G  4.2G  672M  87% /root/.gvfs

Code:

fdisk -l
/dev/sda3            4605        8453    30917092+  83  Linux

Also my grub partition is not correct, I tried to reinstall grub using.

>grub
>setup (hd0,2)

but something is still not right as it is using the /sda6 menu.lst options.


VinayatLQ 11-12-2008 10:57 AM

Solved the wrong disk size issue
 
Finally I got it working using the resize command. Hope this works for you pobman. Mind you that my filesystem on sda3 is ext3

Here is what I did,

1. Boot you system with a CDROM/USB using any of the rescue linux or knoppix etc. I used sysresccd.
2. After boot up
Code:

umount /dev/sda3 (just in case if it is mounted)
3. do a file system check
Code:

fsck -n /dev/sda3
Output shuld be
Code:

/dev/sda3: clean, <SOMESIZE>>
4.Removed the journal from /dev/sda3, this will make it an ext2 partition
Code:

tune2fs -O ^has_journal /dev/sda3
5. run
Code:

e2fsck -f /dev/sda3
6. resize the partition (with resize2fs without options takes your max size of the disk)
Code:

resize2fs /dev/sda3
7. Next run
Code:

fsck -n /dev/sda3
8. Create journal on /dev/sda3, this will turn sda3 to ext3 partition again
Code:

tune2fs -j /dev/sda3
9. Reboot the system using your original OS (ubuntu in your case?)

Let me know if it works for you

pobman 11-12-2008 09:26 PM

Thanks a lot VinayatLQ,

In the end I decided to blow away my install and start a fresh, but I will store as I am sure it will happen again, now to try a similar thing on my ntfs partition with that bloat ware.

Thanks :)

davehill 12-03-2008 12:48 AM

Hey - thanks!
 
Thanks, VinayatLQ - I had the same problem and followed your 8 steps - they worked great. df now reports the same size as gparted.

I'm planning to use the partition as a raid1 mirror with a similar HD so it was important to get it right (I'd resized it to match it to the other HD).

There was only one minor difference in what I did - the partition is new and separate from the ones in use (/, /home, etc), so I could unmount it and work on it without using a rescue CD like Knoppix.

I don't think of myself as a newbie, or of this as a newbie-type question, but I appreciate getting help from people that are more expert than me, and I'll try to do the same.

schworak 08-29-2012 09:58 AM

I know it has been a while since this thread has seen any action. I am only posting because this keeps coming up high in my Google searches and I found a simple solution.

I resized my RAID6 array by adding three new drives but DF kept showing the old size.

After some research I found that I simply needed to tell the OS to resize the partition to its maximum size. It took a while but it did it LIVE without unmounting the array and no data loss. As a matter of fact I was even able to write to the disk while it was being resized. I wouldn't try rebooting because that sounds down right dangerous.

It took about 3 hours (+/-) to expand my array from 3T to 6T using this command:

Code:

sudo resize2fs /dev/md9
By not specifying the size you are resizing to, the entire available space is used which is exactly what I wanted.



All times are GMT -5. The time now is 09:21 AM.