[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: repartitioning: joining two partitions



* Joris Huizer <joris_huizer@yahoo.com> [20030325 13:59 PST]:
> Hello,
> 
> Derrick, you're reply is very helpfull - but I've got
> a new question based on the adjacency of partitions.
> 
> This is the partition table as it is:
> 
> hda: hda1
> hdb: hdb1 hdb2 hdb3 hdb4 < hdb5 hdb6 >
> 
> the hda disk is where windows lives (for my dad)
> the /tmp is on hdb3, /home is on /hdb5
> 
> the partition has an "extended" partition - or so was
> it called - because when I made the partitions I was
> using Redhat 8 - and their partition tool insisted on
> creating an extended partition in order to have more
> than 5 partitions - I still don't know why this should
> be necessary but... well this is the situation.
> 
> As far as I understand the extended partition, /hdb4,
> isn't a real partition so hdb3 would be next to hdb5 -
> which means lvm would work.

Well, actually, LVM will work for non-adjacent partitions as well.  I
think dman said that you'll only be able to create a new, large
partition out of two smaller partitions without anything fancy (e.g.
lvm) if they are adjacent.

Also, hdb3 and hdb5 are not strictly adjacent in that sense.  The
problem is that the partition table is only big enough to store 4
entries.  So if you want 4 partitions, they can all just be regular
partitions.  If you want 5 or more (usable partitions), you'll have to 
create at least one "extended" partition.  Each extended partition can
hold up to 4 more partitions.  It does this by creating that dummy
"extended" partition which has another partition table at its beginning.
So in your case, hdb4 occupies all of the space of hdb5 and hdb6, and
includes a partition table specifying where hdb5 and hdb6 start and end.
So you can't delete hdb4 without deleting hdb5 and hdb6 first.  So you
can't just join hdb3 and hdb5.

One thing that will *probably* work (i.e. it looks like it should, but I
haven't done it so BACK BACK BACK UP UP UP your data if you're thinking
about trying this.  No wait, back it up anyway. =) is to write down the
blocks on which the existing partitions start and end, then create the
new ones in exactly the same places.

For example, in your case, if you wanted to join partitions 3 and 5, you
would go like this:

(you'll have to store the data from 3 and 5 somewhere else and create
restore it after creating a new, larger filesystem on the new, joined
partition ... or do some yet fancier moves with growing the existing
hdb3 filesystem to fill the new available space)

write down where 6 starts and ends
delete 6
delete 5
delete 4
delete 3
create a new "Extended" partition #3, filling all of the space from
where the old 3 started through where the old 6 ended (which is probably
all of the available space on the drive, and the defaults in the prompts
for whatever fdisk program you're using).
create a new partition #4, starting where the old 3 started and ending
where the old 5 ended.
create a new partition #5, starting where the old 6 started and ending
where the old 6 ended.

Now your old partition 6 is partition 5, and should be ready to mount
and use, without re-creating a new filesystem (the old one is still
there, and the new partition is in exactly the same place).

Your new partition 4 is the combination of your old partitions 3 and 5.
Your new partition 3 is the same as your old dummy partition 4.

Create a new filesystem on hdb4 (or grow the old one, if you decided to
go that route, which I didn't go into here), restore your data, update
your fstab, and Bob's your uncle!


That may have gotten a little out-of-hand ... I hope at least my initial
explanation helps, and that you can use the example to reinforce the
ideas in the explanation, even if you decide to use a little less voodoo
for your particular situation =)

good times,
Vineet
-- 
http://www.doorstop.net/
-- 
"Extremism in the defense of liberty is no vice.
Moderation in the pursuit of justice is no virtue."  -- Barry Goldwater 

Attachment: pgp1d_Ovnlw7h.pgp
Description: PGP signature


Reply to: