LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-23-2009, 01:02 PM   #1
maxvonseibold
Member
 
Registered: Mar 2006
Location: Oxford, UK.
Distribution: Debian, Ubuntu, RHEL5, OSX
Posts: 41

Rep: Reputation: 15
parted, fdisk, gparted, sfdisk ... Cannot resize, tools inaccurate.


Hello,

I have a spare hard disk of 500 gigs. I am trying to creating one very large primary partition for storage and another smaller one for swap.


Using parted, I am able to create the big one and format it to ext3 with no bother. However whenever I try to add the swap it will not work.

Running parted and printing the table gives:-

Code:
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size    Type     File system  Flags
 1      0.51kB  465GB  465GB   primary  ext2              
 2      465GB   465GB  8225kB  primary  linux-swap
Clearly the swap is to small.

So, I thought I would use the GUI Gparted to have a look. I want to understand how to do this without graphical tools.

Basically Gparted showed me that the sizes being reported by parted where different. However parted will only report in Gigs and not anything.


Can anyone advise me how I can resize or more partitions using command lind tools and how I can get accurate information on things like start and end points?

I am using Ubuntu 8 (Hardy).


Many Thanks.
 
Old 02-23-2009, 01:47 PM   #2
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,675

Rep: Reputation: 239Reputation: 239Reputation: 239
This is an old problem relating to the way hard drive manufacturers label the capacity of their hard drives as opposed to the way every one else in IT determines capacity. To make a long story short, your 500GB hard drive is really only 465GB as stated in the usual definition of gigabyte.

Hard drive manufacturers use a decimal definition of 1 KB = 1000 bytes. Everyone else uses the binary definition of 1 KB = 2exp10 = 1024 bytes. The net result is that as far as your OS is concerned, your hard drive is about 7% less than the size stated by the hard drive manufacturer(.93 x 500 = 465). It gets more confusing because you can never be really sure whether a given tool is using binary or decimal as many have been changed to deal with the hard drive manufacturer's labeling practices. Here's a more lengthy explanation:

http://forum.pcmech.com/showthread.php?t=118330
 
Old 02-24-2009, 05:09 AM   #3
maxvonseibold
Member
 
Registered: Mar 2006
Location: Oxford, UK.
Distribution: Debian, Ubuntu, RHEL5, OSX
Posts: 41

Original Poster
Rep: Reputation: 15
hmmmm, ok, well that's annoying but makes sense.

I managed to get a working setup using cfdisk which was very nice. However I would really like to be able to go more low level and do it myself for situations at work on cranky old servers which have been stripped down to the nuts and dont have these new fangled curses and gui based tools. GParted is very nice to use but frankly I need to be able to figure it out without a gui.

I guess, that if an accurate disk capacity can be gained from a tool then this would allow fdisk or parted to work correctly then as it all seems to stem from knowing the initial size.

Thanks for your help with this!


Max.
 
Old 02-24-2009, 05:28 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 17,249

Rep: Reputation: 2640Reputation: 2640Reputation: 2640Reputation: 2640Reputation: 2640Reputation: 2640Reputation: 2640Reputation: 2640Reputation: 2640Reputation: 2640Reputation: 2640
Quote:
Originally Posted by maxvonseibold View Post
I guess, that if an accurate disk capacity can be gained from a tool then this would allow fdisk or parted to work correctly then as it all seems to stem from knowing the initial size.
I would be *most* surprised if either fdisk or parted are getting the actual size of the device wrong.
The fact that you (still) don't understand the situation is (much) more likely the problem.
 
Old 02-24-2009, 07:38 AM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 5,052

Rep: Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773
Quote:
root@Magpie:/# fdisk -lu

Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders, total 488281250 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xe686f016

Device Boot Start End Blocks Id System
/dev/sda1 63 96389 48163+ de Dell Utility
/dev/sda2 * 96390 84003884 41953747+ 7 HPFS/NTFS
/dev/sda3 84003885 478528154 197262135 f W95 Ext'd (LBA)
/dev/sda4 478528155 488263544 4867695 db CP/M / CTOS / ...
/dev/sda5 84003948 167911379 41953716 7 HPFS/NTFS
/dev/sda6 167911443 251818874 41953716 6 FAT16
/dev/sda7 251818938 335726369 41953716 83 Linux
/dev/sda8 335726433 419633864 41953716 83 Linux
/dev/sda9 419633928 423826829 2096451 82 Linux swap
/dev/sda10 423826893 434317274 5245191 b W95 FAT32
/dev/sda11 434317338 478528154 22105408+ 83 Linux
The output of fdisk -lu gives all the information you need.
"Disk /dev/sda: 250.0 GB, 250000000000 bytes" is the disk size in gigabytes (250 x 10^9). Note that this is different to the size in Gibibyte 250000000000/1024/1024/1024 = 232.830643654 GiB
"255 heads, 63 sectors/track, 30394 cylinders, total 488281250 sectors
Units = sectors of 1 * 512 = 512 bytes
" gives the disk layout for addressing and the units for the Start and End columns in the table. The Blocks column shows standard Linux disk blocks of 1024bytes.
The layout of the disk is:
Sector 0 to 62 (Master Boot Record) which is not shown.
Sector 63 to 96389 First primary partition containing Dell Utility (plus after Blocks indicates that this partition does not finish on a cylinder boundary)
Sector 96390 to 84003884 Second primary partition containing Windows (asterisk denotes boot partition, plus after Blocks indicates that this partition does not start on a cylinder boundary)
Sector 84003885 to 478528154 Extended partition containing logical volumes.
Sector 478528155 to 488263544 Third primary partition that I believe contains the disk image for restore of Windows partition from restore CD provided at purchase.

Note the gap between the start of the Extended partition and the start of the first logical volume from Sector 84003885 to 84003947. This is the location of the extended partition table.
 
  


Reply

Tags
fdisk, gparted, parted, sfdisk


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sfdisk advantages over fdisk? m4rtin Linux - Software 2 02-10-2009 05:39 AM
fdisk, parted, and gparted lawrence_lee_lee Linux - Software 3 06-15-2008 09:26 AM
Which Disk tool to USE? FDISK;CFDISK;SFDISK montyw47 Linux - Newbie 1 07-17-2004 04:21 AM
fdisk and sfdisk devinWhalen Linux - Distributions 5 04-08-2003 12:20 PM
fdisk,cfdisk,sfdisk not in my distro of RH 8.0 personal thehamguy1 Linux - Newbie 5 02-28-2003 01:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:44 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration