2004-04-18 14:23:14

by Remi Colinet

[permalink] [raw]
Subject: Questions : disk partition re-reading

Hi,

I have 2 questions about disk partitioning under linux 2.6.x :

1/ Is it possible to alter a disk partition of a used disk and beeing
able to use the modified partition without having to reboot the box?

2/ Is it possible to delete a disk partition without having the
partition numbers changed?

My box is an AMD 2500+/Asus board with FC1 / 2.6.5.

Do I need to upgrade fdisk or use an other utility? Or do I need to
apply a kernel patch?

Regards,
Remi


2004-04-18 15:38:43

by Remi Colinet

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

Christian Kr?ner wrote:

>On Sunday 18 April 2004 15:24, you wrote:
>
>
>>Hi,
>>
>>I have 2 questions about disk partitioning under linux 2.6.x :
>>
>>1/ Is it possible to alter a disk partition of a used disk and beeing
>>able to use the modified partition without having to reboot the box?
>>
>>2/ Is it possible to delete a disk partition without having the
>>partition numbers changed?
>>
>>My box is an AMD 2500+/Asus board with FC1 / 2.6.5.
>>
>>Do I need to upgrade fdisk or use an other utility? Or do I need to
>>apply a kernel patch?
>>
>>Regards,
>>Remi
>>-
>>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>the body of a message to [email protected]
>>More majordomo info at http://vger.kernel.org/majordomo-info.html
>>Please read the FAQ at http://www.tux.org/lkml/
>>
>>
>
>All this is possible...
>Use fdisk or cfdisk for editing the partition table and, if youre root
>partition doesnt reside on the disk, simply use hdparm to let the kernel
>reread the partition table. You can start formatting the new partitions right
>after that...
>cheers, christian.
>
>
>
>
Christian,

I have modified a partition with fdisk.
Then, I have tried to update the in memory partitioning informations,
but I have the following error message :

# hdparm -z /dev/hdb

/dev/hdb:
BLKRRPART failed : Device or resource busy

An other partition is used on the same disk.

Regards,
Remi



2004-04-18 18:01:49

by DervishD

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

Hi Remi :)

* Remi Colinet <[email protected]> dixit:
> 1/ Is it possible to alter a disk partition of a used disk and beeing
> able to use the modified partition without having to reboot the box?

sfdisk -R <disk-you-want-to-get-its-partition-table-reread>

> 2/ Is it possible to delete a disk partition without having the
> partition numbers changed?

For primary partitions, it is possible. Don't know for extended
ones :??

> Do I need to upgrade fdisk or use an other utility?

AFAIK, fdisk will do, except for rereading. Well, 'fdisk'
actually *do* a rereading, but only after altering the partition
table of the disk. 'sfdisk' can do it on demand, but if the disk is
busy the BKLRRPART ioctl will fail.

Ra?l N??ez de Arenas Coronado

--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/

2004-04-19 03:49:32

by Jakob Oestergaard

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

On Sun, Apr 18, 2004 at 03:24:46PM +0200, Remi Colinet wrote:
> Hi,
>
> I have 2 questions about disk partitioning under linux 2.6.x :
>
> 1/ Is it possible to alter a disk partition of a used disk and beeing
> able to use the modified partition without having to reboot the box?

Not if you want to use DOS partition tables, no. But read on.

> 2/ Is it possible to delete a disk partition without having the
> partition numbers changed?

Yes. fdisk will do this. But read on :)


Look into LVM.

Really, it solves all the silly problems with partition tables like:
1) requiring reboot after changing table on root disk
2) partition fragmentation
3) partition number limiting
4) the inability to partition SW-RAID devices
5) etc...

And then it adds some real niceties; like being able to span a
"parition" (logical volume) over multiple physical disks, and very
easily adding extra storage (extra disks) into your "storage pool"
(volume group).

Currently, the various distro installers aren't particularly good at (or
even able to) install on LVM - this is changing (the next debian release
seems to be able to do this - dunno about others yet), but this is
currently the only problem that I've seen with LVM.

At home I have a small / on hda1, then I put hda2 (spanning the rest of
hda) into LVM. So, all other filesystems are created on LVM, and I never
need to mock around with the partition table. Works nicely. This setup
(LVM on top of partition tables) saved me the trouble of figuring out
how to create an initrd properly, but I know others who mount / from LVM
so it's indeed possible. But for an existing setup like yours, maybe
it's easier to keep / on the partition table and just put the "rest" in
LVM.

And it's not that hard to work with; there's an excellent HOWTO on the
topic. Once you figure out "physical volume", "volume group" and
"logical volume", you know enough to use it.


/ jakob

2004-04-19 11:39:21

by Erik Mouw

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

On Sun, Apr 18, 2004 at 03:24:46PM +0200, Remi Colinet wrote:
> I have 2 questions about disk partitioning under linux 2.6.x :
>
> 1/ Is it possible to alter a disk partition of a used disk and beeing
> able to use the modified partition without having to reboot the box?

"blockdev --rereadpt /dev/whatever" does the trick on 2.4.x. Didn't try
it on 2.6 yet, but I don't think it changed.

> 2/ Is it possible to delete a disk partition without having the
> partition numbers changed?

Yes (assuming MS-DOS style partition tables).


Erik

--
+-- Erik Mouw -- http://www.harddisk-recovery.com -- +31 70 370 12 90 --
| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands

2004-04-19 22:38:27

by Rob Couto

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

On Sunday 18 April 2004 09:24 am, you wrote:
> Hi,
>
> I have 2 questions about disk partitioning under linux 2.6.x :
>
> 1/ Is it possible to alter a disk partition of a used disk and beeing
> able to use the modified partition without having to reboot the box?
>

as already stated,it can be. fdisk tries to refresh the kernel's copy of the
table every time it writes, and hdparm -Z /dev/hdx does the same, but both
will fail if any partitions are mounted from that disk. unmounting, then
re-partitioning, then remounting lets it work... this is often useful to me
when working from rescue disks but never when booted from that drive, or
if /usr, /var, or /tmp are on it

--
Rob Couto [[email protected]]
computer safety tip: use only a non-conducting, static-free hammer.
--

2004-04-20 07:46:59

by Andries Brouwer

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

On Sun, Apr 18, 2004 at 03:24:46PM +0200, Remi Colinet wrote:

> I have 2 questions about disk partitioning under linux 2.6.x :
>
> 1/ Is it possible to alter a disk partition of a used disk and beeing
> able to use the modified partition without having to reboot the box?

Yes. Look at partx.

> 2/ Is it possible to delete a disk partition without having the
> partition numbers changed?

Yes. Look at partx.

> Do I need to upgrade fdisk or use an other utility? Or do I need to
> apply a kernel patch?

You must distinguish the on-disk partition table and the kernel
partition table. You can change the on-disk partition table just by
writing to it, but that does not change the kernel's ideas.
You can change the kernel partition table using the right ioctls
but that does not change the bits on disk.

Usually one does
blockdev --rereadpt /dev/something
after changing media, or after writing to the partition table,
but that will fail if the disk is busy.

2004-04-20 14:36:41

by Rogier Wolff

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

On Tue, Apr 20, 2004 at 09:46:50AM +0200, Andries Brouwer wrote:
> You must distinguish the on-disk partition table and the kernel
> partition table. You can change the on-disk partition table just by
> writing to it, but that does not change the kernel's ideas.
> You can change the kernel partition table using the right ioctls
> but that does not change the bits on disk.
>
> Usually one does
> blockdev --rereadpt /dev/something
> after changing media, or after writing to the partition table,
> but that will fail if the disk is busy.

Which reminds me: Too bad the kernel says "Busy" without really
thinking aboutit.

Assume that I have a
<hda1> swap 1G (*)
<hda2> root 19G (active)
<free space>

disk, and want to add an extra partition. Maybe I have a 20G image
which I want to copy onto 20, 40, 60, 80, 120 and 200Gb disks. I can
then add the third partition as a /data or a /tmp partition. However
as the active root is on that disk I have to reboot. But in fact I
don't intend to change the active partition.

So, there should be objections if I want the new partitioning scheme
to be:

<hda1> swap 1.5G
<hda2> root 19G (active)
<free space>

then there is a problem and I can understand "Busy". But if the new
scheme is:

<hda1> swap 1G
<hda2> root 19G (active)
<hda3> data 20G <unformatted>

then I don't understand the reason for refusing the rereadpt request.

Anybody want to code this up?


Roger.


(*) usually active as well, but easily deactivated. So lets pretend
it's inactive for this discussion.

--
** [email protected] ** http://www.BitWizard.nl/ ** +31-15-2600998 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
**** "Linux is like a wigwam - no windows, no gates, apache inside!" ****

2004-04-25 22:15:34

by Andries Brouwer

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

On Tue, Apr 20, 2004 at 04:36:35PM +0200, Rogier Wolff wrote:
...
> then there is a problem and I can understand "Busy". But if the new
> scheme is:
>
> <hda1> swap 1G
> <hda2> root 19G (active)
> <hda3> data 20G <unformatted>
>
> then I don't understand the reason for refusing the rereadpt request.
>
> Anybody want to code this up?

The answer is always the same: it exists and is called partx.

Maybe you want to move part of its functionality into the kernel,
but there is no good reason.

2004-04-26 08:31:44

by Wichert Akkerman

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

Previously Andries Brouwer wrote:
> The answer is always the same: it exists and is called partx.

Is partx ready for prime time yet? The util-linux sources do not compile
or install it by default and the only comment in the HISTORY file is
'code to play with, not to use'.

Wichert.

--
Wichert Akkerman <[email protected]> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.

2004-04-26 15:20:26

by Bill Davidsen

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

Wichert Akkerman wrote:
> Previously Andries Brouwer wrote:
>
>>The answer is always the same: it exists and is called partx.
>
>
> Is partx ready for prime time yet? The util-linux sources do not compile
> or install it by default and the only comment in the HISTORY file is
> 'code to play with, not to use'.

So partx is intended to provide a reason for not discussing putting the
functionality into the kernel, rather than actually being robust enough
to use? If the author doesn't think it's ready for production use, why
mention it?


--
-bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me

2004-04-29 00:16:03

by Andries Brouwer

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

On Mon, Apr 26, 2004 at 10:31:42AM +0200, Wichert Akkerman wrote:

> Previously Andries Brouwer wrote:
> > The answer is always the same: it exists and is called partx.
>
> Is partx ready for prime time yet? The util-linux sources do not
> compile or install it by default and the only comment in the
> HISTORY file is 'code to play with, not to use'.

It depends on what you want to do.
It really works, or at least really worked when I last tried it.
There are no problems that I know of.

2004-04-29 00:26:19

by Andries Brouwer

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

On Mon, Apr 26, 2004 at 11:21:25AM -0400, Bill Davidsen wrote,

> So partx is intended to provide a reason for not discussing putting the
> functionality into the kernel, rather than actually being robust enough
> to use?

Both parts of that sentence are false.

2004-04-29 08:04:51

by Wichert Akkerman

[permalink] [raw]
Subject: Re: Questions : disk partition re-reading

Previously Andries Brouwer wrote:
> It depends on what you want to do.
> It really works, or at least really worked when I last tried it.
> There are no problems that I know of.

If it works as advertised I'm happy with it. I'm just asking you to make
it a proper part of util-linux in its next release so it will actually be
installed for people without having to manually compile and install it
seperately from the other utilities in util-linux.

Wichert.

--
Wichert Akkerman <[email protected]> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.