You are not logged in.

#1 2008-01-31 09:36:04

B-Con
Member
From: USA
Registered: 2007-12-17
Posts: 554
Website

Ensuring my partitions are the *exact* same size

I want to partition my primary hard disk such that it has numerous partitions that are the *exact* same size. I want to be able to copy them around and onto each other (via dd) so it is imperative that every partition equal the others in size.

I've determined that I want my partition size to be 17211 MB. So I'm using fdisk to create partitions of that exact size. Namely, I wiped the partition table, then started creating partitions using the first available cylinder and using +17211M for the size. Then using the 'p' option I listed the new altered partition table and now under "blocks" the number of blocks for the new partitions is identical (16812022+, to be specific). So far so good.

However, I've run out of primary partitions and would like to jump to using an extended partition. So I created an extended partition using the rest of the disk, then used the first cylinder that the extended partition started on as the first cylinder of my next partition  used +17211M for the partition size. However, this time using 'p' showed that my new partition didn't have the same number of blocks as the previous (primary) ones. This problem was solved, though, by deleting the partition and recreating it starting with the first cylinder *after* the first cylinder of the extended partition.

But, I had a problem with the next partion on the extended region. If I start it on the first available unused cylinder and make it +17211M in size, it doesn't show as having the same number of blocks as the other partitions.

I've included a terminal dump of what fdisk is showing me thus far, to help make it clear:

Command (m for help): p

Disk /dev/sda: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          13      104391   83  Linux
/dev/sda2              14        2106    16812022+  83  Linux
/dev/sda3            2107        4199    16812022+   7  HPFS/NTFS
/dev/sda4            4200        9671    43953840    5  Extended
/dev/sda5            4201        6293    16812022+  83  Linux
/dev/sda6            6294        8386    16811991   83  Linux

It's the second partition under "Extended" that I can't get to be the right number of "blocks".

I guess I should ask, to be sure, if "blocks" even has anything to do with size. It seems like partitions with different numbers of blocks should be different in size, but is that really so? Or am I getting worked up over nothing?

Also, on the topic of blocks, what's the + after the block count from some of the partitions imply?

Last edited by B-Con (2008-01-31 09:37:51)

Offline

#2 2008-02-01 07:09:29

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: Ensuring my partitions are the *exact* same size

Use sfdisk for that.

Points of interest:
- man sfdisk ("List Partitions")
- sfdisk -V -l -uS /dev/sda


1000

Offline

#3 2008-02-01 07:11:01

gradgrind
Member
From: Germany
Registered: 2005-10-06
Posts: 921

Re: Ensuring my partitions are the *exact* same size

It looks like there's not quite enough space to make the last partition as big as the others.

I think the blocks are kB (2 sectors) and that the '+' means 'a bit more than' (I suppose here an extra sector). I won't, however pretend to know how the shown numbers arise from the given 17211MB.

My suggestion would be to use 'parted' to do the partitioning - it is easy to use different units and get clear listings of the partition sizes. On the other hand, fdisk and cfdisk can also show sectors. See the man pages.

Offline

#4 2008-02-02 01:38:02

B-Con
Member
From: USA
Registered: 2007-12-17
Posts: 554
Website

Re: Ensuring my partitions are the *exact* same size

gradgrind wrote:

It looks like there's not quite enough space to make the last partition as big as the others.

I think the blocks are kB (2 sectors) and that the '+' means 'a bit more than' (I suppose here an extra sector). I won't, however pretend to know how the shown numbers arise from the given 17211MB.

My suggestion would be to use 'parted' to do the partitioning - it is easy to use different units and get clear listings of the partition sizes. On the other hand, fdisk and cfdisk can also show sectors. See the man pages.

I've used GParted before and what it did didn't even come close to being exact. It was off by up to 8 megabytes, and I need them identical down to the sector.

I have enough space, I have an extra 10GB beyond what the last (truncated) partition is using.

[edit]
Ah, and the above sfdisk command does indeed confirm that my "rogue" truncated partition does NOT have the same number of sectors, it's off by 63 to be precise. Weirdness...?

Last edited by B-Con (2008-02-02 03:32:25)

Offline

#5 2008-02-02 06:02:35

B-Con
Member
From: USA
Registered: 2007-12-17
Posts: 554
Website

Re: Ensuring my partitions are the *exact* same size

Mm, interesting. After a couple hours of tinkering around with fdisk and sfdisk I've made some progress. Here it is, in case it helps anyone else.

First, I was not aware that partitions are "supposed" to start on even cylinder breaks. Which, for the record, are about 8MB in size. Which explains why a long time ago when I was installing Windows I'd always see 8MB of space up front on a drive and why GParted was rounding by 8MB on my partitions (a problem I eluded to above), it was rounding to match a cylinder break.

And it turns out that one has to *skip* a full cylinder between the end of first logical partition on the extended partition and the start of the second logical partition within it, otherwise said second logical partition winds up too small. This makes no sense to me, but at this point I'll just accept it.

So my problem's all sorted now. Partition 6 doesn't start on an even cylinder, even though I'm using fdisk to make it, but I don't really care anymore. tongue

Offline

#6 2008-02-02 08:10:41

gradgrind
Member
From: Germany
Registered: 2005-10-06
Posts: 921

Re: Ensuring my partitions are the *exact* same size

B-Con wrote:

I've used GParted before and what it did didn't even come close to being exact. It was off by up to 8 megabytes, and I need them identical down to the sector.

I didn't write gparted, I suggested parted, the command line tool.

Anyway, glad you managed to sort it out.

Concerning the cylinder boundaries, it would be interesting to know if there are any significant rules, or whether this is one of those things that depends on the operating system(s) involved. Out of interest I just checked my partition boundaries (created by cfdisk, I think) - they are all on even cylinders.

Offline

#7 2008-02-02 08:39:22

B-Con
Member
From: USA
Registered: 2007-12-17
Posts: 554
Website

Re: Ensuring my partitions are the *exact* same size

gradgrind wrote:

I didn't write gparted, I suggested parted, the command line tool.

My bad, I misread it.

Concerning the cylinder boundaries, it would be interesting to know if there are any significant rules, or whether this is one of those things that depends on the operating system(s) involved. Out of interest I just checked my partition boundaries (created by cfdisk, I think) - they are all on even cylinders.

sfdisk just issues a warning, so it might not be an enforced rule, just a (optimization) recommendation or a past technical limitation.

Offline

#8 2008-02-02 08:54:14

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Ensuring my partitions are the *exact* same size

Maybe there's a better way.

You want to do this to dd some partitions to each other -- why do you want to do that in the first place? could there be a better solution to the _actual_ problem?

Offline

#9 2008-02-02 19:25:00

B-Con
Member
From: USA
Registered: 2007-12-17
Posts: 554
Website

Re: Ensuring my partitions are the *exact* same size

Nothing in specific, just general convenience. My reasons have varied over time. Back in the days of Ubuntu, upgrading from one version to another instead of performing a clean install was a game of roulette, so I'd always dd my Ubuntu partition to another drive right before I went to school for the day (even though the dd would only take about 20 minutes), then come back and upgrade. If the upgrade didn't go as smoothly as I wanted and I didn't deem it worth my time to sit and manually fix everything I'd just restore the old copy via dd (or even just use that one as my primary OS) and wait for a time I wanted to do a clean install.

A while ago I also used to backup Windows to another partition, just in case the current version became infected with something. Never happened (that I knew about, at least) so I stopped bothering.

More recently I've used it for when I'm lazy and don't want to bother undoing my steps. If I install something, configure it, do some stuff and break it, it may be faster to restore with a 20 minute dd than 30 minutes of hacking.

And I can be a bit compulsive in the organization compartment. Ever seen the TV show Monk? I'm nowhere near that bad ( wink ) but everytime I fdisk -l and I see unevenly-sized partitions all for the same job, I become less than pleased. I've been looking at it for a long time now, and figured I'd take some free time to fix it.

In short, nothing terribly practical, it's just somewhat convenient/organized.

Offline

#10 2008-02-02 21:01:13

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Ensuring my partitions are the *exact* same size

What's wrong with tar or just copying stuff from one partition to another? Works just as well smile

Offline

#11 2008-02-02 21:15:07

vogt
Member
From: Toronto, Canada
Registered: 2006-11-25
Posts: 389

Re: Ensuring my partitions are the *exact* same size

lvm snapshots achieve the same thing using the same thing more efficiently: no untarring to get your old stuff back.

Last edited by vogt (2008-02-02 21:15:47)

Offline

#12 2008-02-02 21:24:59

B-Con
Member
From: USA
Registered: 2007-12-17
Posts: 554
Website

Re: Ensuring my partitions are the *exact* same size

iphitus wrote:

What's wrong with tar or just copying stuff from one partition to another? Works just as well smile

Windows won't let you do that (IIRC) and going to Ubuntu from Windows it never occurred to me that Linux would suffice to just let you copy files around. :-)

vogt wrote:

lvm snapshots achieve the same thing using the same thing more efficiently: no untarring to get your old stuff back.

I'll look into that, thanks.

Offline

Board footer

Powered by FluxBB