LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 07-29-2006, 02:03 PM   #16
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,768

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477

A question. When you overwrite the partition table while running, do the changes show up in /proc/partitions ?

Note that logical cylinder boundary is not the same as logical partition.
If you are using an extended partition then you need to take into account that the partition table in the MBR will only hold the address of the sector where the extended partition info is kept. This extra sector must be counted in the total.
The cylinder boundaries affect the final sector even if the disk is not full. They come from the mismatch between the byte capacity of one or more full cylinders. If you choose a partiton 1MB smaller, say, the last two sectors would be 'skipped' as partition capacity but counted in the total number of sectors. The new partition begins on a cylinder boundary not on the next unclaimed sector.
 
Old 07-29-2006, 02:32 PM   #17
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 54
Quote:
Originally Posted by gnashley
Several things I see:

You have a null number of sectors for the first partition.
The partitions are mixed physically and logically -as if some had been created, then some removed or resized or recreated.

Logical cylinder boundaries. One of the things that sucks about DOS fdisk is that you can't be very specicfic about partition sizes -some sizes are uncreatable. Linux tools are better of course, they'll warn you sometimes like this:
'number of heads/tracks/sectors doesn't match logical cylinder boundaries'

If the point is to 'occupy' all the available space on the disk, then you need to get down to block-size also so you can ask for the proper number of K's for the partition. Most of choose a 'rounded' size like 100MB or 128MB. The logical cylinder boundaries may not match these fiures. When they don't, the last unused sectors are skipped. The next partition starts at a new logical cylinder boundary.

If you want to see how sfdisk or whatever does it you could try reading the sources.
I would add to this that you should make a point of defining new partitions on integral cylinder boundaries and avoid using every last bit of space.
 
Old 07-29-2006, 03:19 PM   #18
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Thanks, cwwilson721!

I added your warning to the top post.

Also, I made a pretty large mistake in my proof by evaluating when I shouldn't have. The resulting equation was one that only worked for my specific disk. I have fixed both the equation and the proof.

Also, thanks gnashley and Randux!

I will head this advice. Although this is probably more math then I feel like doing at the moment. Maybe in a few days I will give it a shot.

...drkstr

regards,
...drkstr

Last edited by drkstr; 07-29-2006 at 03:22 PM.
 
Old 07-29-2006, 03:23 PM   #19
cwwilson721
Senior Member
 
Registered: Dec 2004
Location: In my house.
Distribution: Ubuntu 10.10 64bit, Slackware 13.1 64-bit
Posts: 2,649
Blog Entries: 1

Rep: Reputation: 66
Thanks. I just thought that needed to be said for such low-level hdd mucking about.

But was serious about the pizza....lol
 
Old 07-29-2006, 03:32 PM   #20
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Quote:
A question. When you overwrite the partition table while running, do the changes show up in /proc/partitions ?
No, the host system cache's the partition table as you said, which is fine. I don't need the host system to see the new table, as long as I can access it. All I need to do is force the change (while live), do a few things, restore the original, then reboot (hopefully back to the original working system). I'm not sure if the reboot is necessary, but couldn't hurt.

regards,
...drkstr
 
Old 07-30-2006, 10:29 AM   #21
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 54
Did somebody say something about pizza? I'll bring the brewskies.
 
Old 07-31-2006, 09:04 AM   #22
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,768

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
here's some output from a couple of disks. If you are writing code that is gonna process output from sfdisk. You need to understand that all these programs write the info in hexcode and that linux uses a DOS-type partition table. So, the tools have to follow some rules that are governed by that and write info which is useful to other programs which may not do the same thing. I mean, you can write a DOS table with partition info that can be read and used by a linux program, but not by DOS or Windows or MacOS.
Finding out which sector is the last used is easy enough. But knowing why that is, or should or must be is fifferent. Some tools only create partitions the way they 'should' be. Others create them the they 'must' -letting you specify. Others do the 'best thing' for you if you leave them alone -this means that for creating partitions there is no better tool than linux fdisk. But that doesn't help if you are working with already created partitions.

bash-3.00# sfdisk -l /dev/hdc
Disk /dev/hdc: 9733 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/hdc1 * 0+ 126 127- 1020096 b W95 FAT32
/dev/hdc2 127 9732 9606 77160195 f W95 Ext'd (LBA)
/dev/hdc3 0 - 0 0 0 Empty
/dev/hdc4 0 - 0 0 0 Empty
/dev/hdc5 127+ 381 255- 2048256 b W95 FAT32
/dev/hdc6 382+ 1034 653- 5245191 b W95 FAT32
/dev/hdc7 1035+ 3358 2324- 18667498+ 83 Linux
start: (c,h,s) expected (1023,254,63) found (1023,1,1)
/dev/hdc8 3359+ 9732 6374- 51199123+ 83 Linux
start: (c,h,s) expected (1023,254,63) found (1023,1,1)
bash-3.00# sfdisk -d /dev/hdc
# partition table of /dev/hdc
unit: sectors

/dev/hdc1 : start= 63, size= 2040192, Id= b, bootable
/dev/hdc2 : start= 2040255, size=154320390, Id= f
/dev/hdc3 : start= 0, size= 0, Id= 0
/dev/hdc4 : start= 0, size= 0, Id= 0
/dev/hdc5 : start= 2040318, size= 4096512, Id= b
/dev/hdc6 : start= 6136893, size= 10490382, Id= b
/dev/hdc7 : start= 16627338, size= 37334997, Id=83
/dev/hdc8 : start= 53962398, size=102398247, Id=83
bash-3.00# fdisk -l /dev/hdc

Disk /dev/hdc: 80.0 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 * 1 127 1020096 b W95 FAT32
/dev/hdc2 128 9733 77160195 f W95 Ext'd (LBA)
/dev/hdc5 128 382 2048256 b W95 FAT32
/dev/hdc6 383 1035 5245191 b W95 FAT32
/dev/hdc7 1036 3359 18667498+ 83 Linux
/dev/hdc8 3360 9733 51199123+ 83 Linux


bash-3.00# sfdisk -d /dev/hda
# partition table of /dev/hda
unit: sectors

/dev/hda1 : start= 63, size= 2000817, Id= c, bootable
/dev/hda2 : start= 2000880, size= 4305168, Id=83
/dev/hda3 : start= 0, size= 0, Id= 0
/dev/hda4 : start= 0, size= 0, Id= 0
bash-3.00# sfdisk -l /dev/hda |grep Disk
Warning: The partition table looks like it was made
for C/H/S=*/16/63 (instead of 782/128/63).
For this listing I'll assume that geometry.
Disk /dev/hda: 782 cylinders, 128 heads, 63 sectors/track
bash-3.00# fdisk -l /dev/hda

Disk /dev/hda: 3228 MB, 3228696576 bytes
16 heads, 63 sectors/track, 6256 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1985 1000408+ c W95 FAT32 (LBA)
/dev/hda2 1986 6256 2152584 83 Linux
 
Old 08-01-2006, 01:01 AM   #23
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
Thanks a bunch gnashley!

I have a lack of disks to test this on so your output is very usefull. This got me thinking, it would probably be pretty usefull to start a thread asking for as many people who are willing to just post their output. I would like to be able to look at as many different partition tables that I can.

I'm going to go pop one in the software forum, it will be interesting to see how many people respond.

thanks!
...drkstr
 
  


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
Reverse engineer classes to diagrams in php ??? ALInux Programming 1 12-28-2005 05:19 AM
Calculation of number of bytes submitted with form blampain Linux - Networking 6 03-30-2004 05:54 AM
Trying to reverse engineer our network :) 8webguy8 Linux - Networking 12 03-17-2004 08:46 AM
How can you reverse engineer a small C program OrganicX Programming 1 01-30-2004 08:30 PM


All times are GMT -5. The time now is 07:13 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