Re: zpool labelclear destroys GPT data

2013-06-15 Thread Daniel Kalchev

On 14.06.2013, at 19:16, Tom Evans tevans...@googlemail.com wrote:

 
 I suppose if labelclear was made to check for the existence of a
 pre-existing ZFS label, the force flag could be used to force the
 change… I still don't like it, the command is not called
 labelclear-only-if-the-label-area-already-has-sane-data.

It apparently does, because zpool labelclear would refuse to wipe a label that 
it believes belongs to an active zpool. So it apparently does check data. Just 
applies some weird logic.

The logic is also flawed and annoyed me few times. For example, you want to 
remove a drive from an raidz. You do this by marking the drive offline and 
wiping it's ZFS labels, so that you can repurpose it. However, as long as the 
zpool is not exported, zpool labelclear  refuses to wipe labels and you re 
forced to resort to dd.
Why would it refuse to clear labels on an offlined drive? Is there better 
method?

Daniel
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org

Re: zpool labelclear destroys GPT data

2013-06-15 Thread Steven Hartland


- Original Message - 
From: Daniel Kalchev dan...@digsys.bg

To: freebsd-stable@freebsd.org
Sent: Saturday, June 15, 2013 12:39 PM
Subject: Re: zpool labelclear destroys GPT data




On 14.06.2013, at 19:16, Tom Evans tevans...@googlemail.com wrote:



I suppose if labelclear was made to check for the existence of a
pre-existing ZFS label, the force flag could be used to force the
change… I still don't like it, the command is not called
labelclear-only-if-the-label-area-already-has-sane-data.


It apparently does, because zpool labelclear would refuse to wipe a label that it believes belongs to an active zpool. So it 
apparently does check data. Just applies some weird logic.


The logic is also flawed and annoyed me few times. For example, you want to remove a drive from an raidz. You do this by marking 
the drive offline and wiping it's ZFS labels, so that you can repurpose it. However, as long as the zpool is not exported, 
zpool labelclear  refuses to wipe labels and you re forced to resort to dd.

Why would it refuse to clear labels on an offlined drive? Is there better 
method?


I'd recommend raising a bug report and posting on the on illumos zfs list
for this so its specific behavour can be discussed there, as it does
sound odd to me and should in theory be quite an easy fix.

   Regards
   Steve 




This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. 


In the event of misdirection, illegible or incomplete transmission please 
telephone +44 845 868 1337
or return the E.mail to postmas...@multiplay.co.uk.

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-14 Thread Johan Hendriks

Kimmo Paasiala schreef:

On Fri, Jun 14, 2013 at 12:22 AM, Johan Hendriks joh.hendr...@gmail.com wrote:

Op 13-6-2013 14:40, Kimmo Paasiala schreef:


The 'device' can be a partition as well as the whole disk, use 'zpool
labelclear' on the freebsd-zfs partition instead of the whole disk.

-Kimmo

On Thu, Jun 13, 2013 at 3:29 PM, Johan Hendriks joh.hendr...@gmail.com
wrote:

When i use zpool labelclear, it wipes the whole disk including gpt data.
So the whole disk is empty and i need to create the gpt partitions again.

Is this supposed to work like this?
The man page suggests that it only wipes the ZFS metadata.

zpool labelclear [-f] device

   Removes ZFS label information from the specified device. The
device
   must not be part of an active pool configuration.

   -v  Treat exported or foreign devices as inactive.

This is on FreeBSD 9.1 stable r251213 memstick install.

regards

Johan Hendriks
Neuteboom Automatisering
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org

Thanks for your reply.
I will try it on the actual zfs partition.

But imho it is a bad thing that it destroys the whole disk layout.
It does not remove ZFS label information, it removes ALL label information
on the disk or device you give it


regards
Johan Hendriks
Neuteboom Automatisering


Of course, zpool(8) will do exactly what you tell it to do. It does
not know about any partitioning schemes and assumes that the user
knows that using labelclear on a the whole disk will potentially
destroy all data on it including any partitioning information.

-Kimmo

Well as i found out, zpool(8) does not know what it clears. ! :D

I think an adjustment to the man page is in order here.
The man page clearly state it removes ZFS labels, not GPT, gmirror and 
glabel labels.
It should mention it will remove labels from the disk/device, and that 
it clears ALL labels.


If a user reads the man page it now looks save to use labelclear.
I thougt that zpool would know if there was zpool label information on 
the disk, and if i a case there is no ZFS label information it will tell 
me that!
In my case i did not loose anything, so no big deal but there will 
proberbly be someone who gets bitten by this.


A plus is that  i found a new way to clear my disks fast ! ;)

regards
Johan Hendriks
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-14 Thread Florent Peterschmitt
Le 14/06/2013 09:35, Johan Hendriks a écrit :
 Kimmo Paasiala schreef:
 On Fri, Jun 14, 2013 at 12:22 AM, Johan Hendriks
 joh.hendr...@gmail.com wrote:
 Op 13-6-2013 14:40, Kimmo Paasiala schreef:

 The 'device' can be a partition as well as the whole disk, use 'zpool
 labelclear' on the freebsd-zfs partition instead of the whole disk.

 -Kimmo

 On Thu, Jun 13, 2013 at 3:29 PM, Johan Hendriks
 joh.hendr...@gmail.com
 wrote:
 When i use zpool labelclear, it wipes the whole disk including gpt
 data.
 So the whole disk is empty and i need to create the gpt partitions
 again.

 Is this supposed to work like this?
 The man page suggests that it only wipes the ZFS metadata.

 zpool labelclear [-f] device

Removes ZFS label information from the specified device.
 The
 device
must not be part of an active pool configuration.

-v  Treat exported or foreign devices as inactive.

 This is on FreeBSD 9.1 stable r251213 memstick install.

 regards

 Johan Hendriks
 Neuteboom Automatisering
 ___
 freebsd-stable@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-stable
 To unsubscribe, send any mail to
 freebsd-stable-unsubscr...@freebsd.org
 Thanks for your reply.
 I will try it on the actual zfs partition.

 But imho it is a bad thing that it destroys the whole disk layout.
 It does not remove ZFS label information, it removes ALL label
 information
 on the disk or device you give it


 regards
 Johan Hendriks
 Neuteboom Automatisering

 Of course, zpool(8) will do exactly what you tell it to do. It does
 not know about any partitioning schemes and assumes that the user
 knows that using labelclear on a the whole disk will potentially
 destroy all data on it including any partitioning information.

 -Kimmo
 Well as i found out, zpool(8) does not know what it clears. ! :D
 
 I think an adjustment to the man page is in order here.
 The man page clearly state it removes ZFS labels, not GPT, gmirror and
 glabel labels.
 It should mention it will remove labels from the disk/device, and that
 it clears ALL labels.

I agree with that, I thought too that zpool cleared only ZFS related
labels. Thankfully no damage for me because it was in a script that wipe
out the entire disk.

 regards
 Johan Hendriks

-- 
Florent Peterschmitt   | Please:
flor...@peterschmitt.fr|  * Avoid HTML/RTF in E-mail.
+33 (0)6 64 33 97 92   |  * Send PDF for documents.
http://florent.peterschmitt.fr | Thank you :)



signature.asc
Description: OpenPGP digital signature


Re: zpool labelclear destroys GPT data

2013-06-14 Thread Daniel O'Connor

On 14/06/2013, at 17:05, Johan Hendriks joh.hendr...@gmail.com wrote:
 Of course, zpool(8) will do exactly what you tell it to do. It does
 not know about any partitioning schemes and assumes that the user
 knows that using labelclear on a the whole disk will potentially
 destroy all data on it including any partitioning information.
 
 Well as i found out, zpool(8) does not know what it clears. ! :D
 
 I think an adjustment to the man page is in order here.
 The man page clearly state it removes ZFS labels, not GPT, gmirror and glabel 
 labels.
 It should mention it will remove labels from the disk/device, and that it 
 clears ALL labels.
 
 If a user reads the man page it now looks save to use labelclear.
 I thougt that zpool would know if there was zpool label information on the 
 disk, and if i a case there is no ZFS label information it will tell me that!
 In my case i did not loose anything, so no big deal but there will proberbly 
 be someone who gets bitten by this.
 
 A plus is that  i found a new way to clear my disks fast ! ;)


It only clears ZFS labels, just because GPT  gmirror information sits in a 
similar place doesn't make that incorrect.

You are saying the equivalent of..
Why does dd if=/dev/zero of=/dev/da0 erase my whole disk, not just the first 
partition?

ie you are giving the tool bad options and then complaining when it doesn't do 
what you meant :)

Perhaps it should be modified to check if there is valid ZFS data there before 
proceeding (although that could be annoying unless there is a way to force it), 
and/or the man page could be amended to say it doesn't do any checks before 
erasing things.

--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
The nice thing about standards is that there
are so many of them to choose from.
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C






___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-14 Thread Alban Hertroys
On 14 June 2013 10:02, Daniel O'Connor docon...@gsoft.com.au wrote:


 On 14/06/2013, at 17:05, Johan Hendriks joh.hendr...@gmail.com wrote:
  Of course, zpool(8) will do exactly what you tell it to do. It does
  not know about any partitioning schemes and assumes that the user
  knows that using labelclear on a the whole disk will potentially
  destroy all data on it including any partitioning information.
 
  Well as i found out, zpool(8) does not know what it clears. ! :D
 
  I think an adjustment to the man page is in order here.
  The man page clearly state it removes ZFS labels, not GPT, gmirror and
 glabel labels.
  It should mention it will remove labels from the disk/device, and that
 it clears ALL labels.
 
  If a user reads the man page it now looks save to use labelclear.
  I thougt that zpool would know if there was zpool label information on
 the disk, and if i a case there is no ZFS label information it will tell me
 that!
  In my case i did not loose anything, so no big deal but there will
 proberbly be someone who gets bitten by this.
 
  A plus is that  i found a new way to clear my disks fast ! ;)


 It only clears ZFS labels, just because GPT  gmirror information sits in
 a similar place doesn't make that incorrect.

 You are saying the equivalent of..
 Why does dd if=/dev/zero of=/dev/da0 erase my whole disk, not just the
 first partition?

 ie you are giving the tool bad options and then complaining when it
 doesn't do what you meant :)

 Perhaps it should be modified to check if there is valid ZFS data there
 before proceeding (although that could be annoying unless there is a way to
 force it), and/or the man page could be amended to say it doesn't do any
 checks before erasing things.


The same goes for several geom labels. For example, if you write a
geom_mirror label to a GPT-partitioned disk (as opposed to writing it to a
partition within that disk), you overwrite the backup GPT table. I got
recently warned not to do that (it didn't apply in my case, but still).

IMHO it would be helpful to verify what's there first and warn the user
about it if such an operation will overwrite a different type of label than
what is about to get written there.
Perhaps it should even refuse to write (by issuing an error stating that
there is already a label there - and preferably also what type) until the
label that's already there gets explicitly cleared by the user or until the
command gets forced.
Does that make sense?

If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-14 Thread Daniel O'Connor

On 14/06/2013, at 17:48, Alban Hertroys haram...@gmail.com wrote:
 IMHO it would be helpful to verify what's there first and warn the user about 
 it if such an operation will overwrite a different type of label than what is 
 about to get written there.
 Perhaps it should even refuse to write (by issuing an error stating that 
 there is already a label there - and preferably also what type) until the 
 label that's already there gets explicitly cleared by the user or until the 
 command gets forced.
 Does that make sense?

The problem with this is that then each label tool needs to know about every 
other label format you want to detect for..

If a label format has a checksum then you could ignore a request to nuke the 
label if there is no valid checksum (with a flag to force). No idea how many 
have checksums though..

--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
The nice thing about standards is that there
are so many of them to choose from.
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C






___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-14 Thread Alban Hertroys
On 14 June 2013 10:21, Daniel O'Connor docon...@gsoft.com.au wrote:


 On 14/06/2013, at 17:48, Alban Hertroys haram...@gmail.com wrote:
  IMHO it would be helpful to verify what's there first and warn the user
 about it if such an operation will overwrite a different type of label than
 what is about to get written there.
  Perhaps it should even refuse to write (by issuing an error stating that
 there is already a label there - and preferably also what type) until the
 label that's already there gets explicitly cleared by the user or until the
 command gets forced.
  Does that make sense?

 The problem with this is that then each label tool needs to know about
 every other label format you want to detect for..


Isn't it possible to add such information to labels, so that the tools at
least know who to ask what they're dealing with?


 If a label format has a checksum then you could ignore a request to nuke
 the label if there is no valid checksum (with a flag to force). No idea how
 many have checksums though..


If there is no guaranteed method of identifying data on the disk as a
label, then you can't warn the user in all cases. That's not particularly
helpful for those cases where you can't warn the user. That's possibly a
worse situation than what started this thread.

-- 
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-14 Thread Daniel O'Connor

On 14/06/2013, at 18:16, Alban Hertroys haram...@gmail.com wrote:
 The problem with this is that then each label tool needs to know about every 
 other label format you want to detect for..
 
 Isn't it possible to add such information to labels, so that the tools at 
 least know who to ask what they're dealing with?
 
Not really, the format of the labels is fixed, and there is no standard way 
they are arranged.

 If there is no guaranteed method of identifying data on the disk as a 
 label, then you can't warn the user in all cases. That's not particularly 
 helpful for those cases where you can't warn the user. That's possibly a 
 worse situation than what started this thread.

Being warned some of the time seems better than none of the time.

--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
The nice thing about standards is that there
are so many of them to choose from.
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C






___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-14 Thread John Baldwin
On Friday, June 14, 2013 4:21:08 am Daniel O'Connor wrote:
 
 On 14/06/2013, at 17:48, Alban Hertroys haram...@gmail.com wrote:
  IMHO it would be helpful to verify what's there first and warn the user 
about it if such an operation will overwrite a different type of label than 
what is about to get written there.
  Perhaps it should even refuse to write (by issuing an error stating that 
there is already a label there - and preferably also what type) until the 
label that's already there gets explicitly cleared by the user or until the 
command gets forced.
  Does that make sense?
 
 The problem with this is that then each label tool needs to know about every 
other label format you want to detect for..
 
 If a label format has a checksum then you could ignore a request to nuke the 
label if there is no valid checksum (with a flag to force). No idea how many 
have checksums though..

Well, you could have zpool check if there is a valid ZFS label and prompt/warn 
if it doesn't find one on whatever device it's about to wipe.  That doesn't 
fix the gmirror/gpt case, but it might make zpool more intuitive to use.

-- 
John Baldwin
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-14 Thread Tom Evans
On Fri, Jun 14, 2013 at 4:49 PM, John Baldwin j...@freebsd.org wrote:
 Well, you could have zpool check if there is a valid ZFS label and prompt/warn
 if it doesn't find one on whatever device it's about to wipe.  That doesn't
 fix the gmirror/gpt case, but it might make zpool more intuitive to use.

One of the uses of zpool labelclear is to completely wipe the portions
of the disk that ZFS will look at for label information. There is no
pre-condition, the post-condition is that the label areas of the
supplied device will be cleared.

The aim of the command is that the relevant parts of the device are
cleared, regardless of its content, such that they are ready to use as
pristine disks in a vdev.

I suppose if labelclear was made to check for the existence of a
pre-existing ZFS label, the force flag could be used to force the
change… I still don't like it, the command is not called
labelclear-only-if-the-label-area-already-has-sane-data.

Cheers

Tom
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org

zpool labelclear destroys GPT data

2013-06-13 Thread Johan Hendriks

When i use zpool labelclear, it wipes the whole disk including gpt data.
So the whole disk is empty and i need to create the gpt partitions again.

Is this supposed to work like this?
The man page suggests that it only wipes the ZFS metadata.

zpool labelclear [-f] device

 Removes ZFS label information from the specified device. The 
device

 must not be part of an active pool configuration.

 -v  Treat exported or foreign devices as inactive.

This is on FreeBSD 9.1 stable r251213 memstick install.

regards

Johan Hendriks
Neuteboom Automatisering
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-13 Thread Kimmo Paasiala
The 'device' can be a partition as well as the whole disk, use 'zpool
labelclear' on the freebsd-zfs partition instead of the whole disk.

-Kimmo

On Thu, Jun 13, 2013 at 3:29 PM, Johan Hendriks joh.hendr...@gmail.com wrote:
 When i use zpool labelclear, it wipes the whole disk including gpt data.
 So the whole disk is empty and i need to create the gpt partitions again.

 Is this supposed to work like this?
 The man page suggests that it only wipes the ZFS metadata.

 zpool labelclear [-f] device

  Removes ZFS label information from the specified device. The device
  must not be part of an active pool configuration.

  -v  Treat exported or foreign devices as inactive.

 This is on FreeBSD 9.1 stable r251213 memstick install.

 regards

 Johan Hendriks
 Neuteboom Automatisering
 ___
 freebsd-stable@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-stable
 To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-13 Thread Johan Hendriks

Op 13-6-2013 14:40, Kimmo Paasiala schreef:

The 'device' can be a partition as well as the whole disk, use 'zpool
labelclear' on the freebsd-zfs partition instead of the whole disk.

-Kimmo

On Thu, Jun 13, 2013 at 3:29 PM, Johan Hendriks joh.hendr...@gmail.com wrote:

When i use zpool labelclear, it wipes the whole disk including gpt data.
So the whole disk is empty and i need to create the gpt partitions again.

Is this supposed to work like this?
The man page suggests that it only wipes the ZFS metadata.

zpool labelclear [-f] device

  Removes ZFS label information from the specified device. The device
  must not be part of an active pool configuration.

  -v  Treat exported or foreign devices as inactive.

This is on FreeBSD 9.1 stable r251213 memstick install.

regards

Johan Hendriks
Neuteboom Automatisering
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org

Thanks for your reply.
I will try it on the actual zfs partition.

But imho it is a bad thing that it destroys the whole disk layout.
It does not remove ZFS label information, it removes ALL label 
information on the disk or device you give it


regards
Johan Hendriks
Neuteboom Automatisering

___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org


Re: zpool labelclear destroys GPT data

2013-06-13 Thread Kimmo Paasiala
On Fri, Jun 14, 2013 at 12:22 AM, Johan Hendriks joh.hendr...@gmail.com wrote:
 Op 13-6-2013 14:40, Kimmo Paasiala schreef:

 The 'device' can be a partition as well as the whole disk, use 'zpool
 labelclear' on the freebsd-zfs partition instead of the whole disk.

 -Kimmo

 On Thu, Jun 13, 2013 at 3:29 PM, Johan Hendriks joh.hendr...@gmail.com
 wrote:

 When i use zpool labelclear, it wipes the whole disk including gpt data.
 So the whole disk is empty and i need to create the gpt partitions again.

 Is this supposed to work like this?
 The man page suggests that it only wipes the ZFS metadata.

 zpool labelclear [-f] device

   Removes ZFS label information from the specified device. The
 device
   must not be part of an active pool configuration.

   -v  Treat exported or foreign devices as inactive.

 This is on FreeBSD 9.1 stable r251213 memstick install.

 regards

 Johan Hendriks
 Neuteboom Automatisering
 ___
 freebsd-stable@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-stable
 To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org

 Thanks for your reply.
 I will try it on the actual zfs partition.

 But imho it is a bad thing that it destroys the whole disk layout.
 It does not remove ZFS label information, it removes ALL label information
 on the disk or device you give it


 regards
 Johan Hendriks
 Neuteboom Automatisering


Of course, zpool(8) will do exactly what you tell it to do. It does
not know about any partitioning schemes and assumes that the user
knows that using labelclear on a the whole disk will potentially
destroy all data on it including any partitioning information.

-Kimmo
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to freebsd-stable-unsubscr...@freebsd.org