Re: How to tear down a geom mirror?
On Thu, Mar 05, 2009 at 10:27:50PM -0800, Peter Steele wrote: I've created a USB boot disk that is used to clone itself onto the systems hard drives, setting up mirrored file systems in the process. The main difficulty I'm having is reimaging a system with an existing OS whose drives are already configured in a mirror. I want of course to destroy the mirror and create a complete new one, but I can't find the right process to accomplish this reliably. I don't want to make any assumptions about what mirrors might exist already and I definitely don't want to do gmirror load before I get a chance to destroy any existing mirrors. What I am doing is to clean the drive using dd. For example, assume my target system has two drives ad1 and ad2. I issue the following commands: dd if=/dev/zero of=/dev/ad1 bs=512 count=79 dd if=/dev/zero of=/dev/ad2 bs=512 count=79 gmirror and various other geom modules store their metadata on the last sector(s) of the drive, so you need to wipe that too. -- Jilles Tjoelker ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: How to tear down a geom mirror?
Jilles Tjoelker wrote: On Thu, Mar 05, 2009 at 10:27:50PM -0800, Peter Steele wrote: I've created a USB boot disk that is used to clone itself onto the systems hard drives, setting up mirrored file systems in the process. The main difficulty I'm having is reimaging a system with an existing OS whose drives are already configured in a mirror. I want of course to destroy the mirror and create a complete new one, but I can't find the right process to accomplish this reliably. I don't want to make any assumptions about what mirrors might exist already and I definitely don't want to do gmirror load before I get a chance to destroy any existing mirrors. What I am doing is to clean the drive using dd. For example, assume my target system has two drives ad1 and ad2. I issue the following commands: dd if=/dev/zero of=/dev/ad1 bs=512 count=79 dd if=/dev/zero of=/dev/ad2 bs=512 count=79 gmirror and various other geom modules store their metadata on the last sector(s) of the drive, so you need to wipe that too. Or simply use the clean command, for example gmirror clean (also supported in other GEOM classes). signature.asc Description: OpenPGP digital signature
Re: How to tear down a geom mirror?
Or simply use the clean command, for example gmirror clean (also supported in other GEOM classes). Can I do a gmirror clean without first doing a gmirror load? That's what I want to avoid since it can hang if the mirror is is a bad state. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: How to tear down a geom mirror?
gmirror and various other geom modules store their metadata on the last sector(s) of the drive, so you need to wipe that too. In our case the systems we are using aren't mirroring the whole drive, just certain slices. Some systems have a single slice mirrored (plus an unmirrored slice), and others have two slices mirrored (plus a third unmirrored slice). I need a way to destroy the existing mirrors, without doing a gmirror load, and ultimately without making any assumptions about the number or condition of mirrored slices on the drives I am about to install a new OS onto. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: How to tear down a geom mirror?
Peter Steele wrote: Or simply use the clean command, for example gmirror clean (also supported in other GEOM classes). Can I do a gmirror clean without first doing a gmirror load? That's what I want to avoid since it can hang if the mirror is is a bad state. Sorry, the actual command is clear, not clean. Yes. The clear commands usually just zero-out the last sector of the underlying provider (doesn't matter if it's a drive, slice or something altogether different) so you don't have to do it manually. signature.asc Description: OpenPGP digital signature
Re: How to tear down a geom mirror?
Yes. The clear commands usually just zero-out the last sector of the underlying provider (doesn't matter if it's a drive, slice or something altogether different) so you don't have to do it manually. So, as a generic solution then I could just iterate through all slices of all drives and run gmirror clear on each, and run dd to clear the first sectors. What btw is in these first sectors? I use this command because I saw it being done in one of the gmirror tutorials. I understand what the gmirror clear command does, but what is the dd command clearing? ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: How to tear down a geom mirror?
Peter Steele wrote: Yes. The clear commands usually just zero-out the last sector of the underlying provider (doesn't matter if it's a drive, slice or something altogether different) so you don't have to do it manually. So, as a generic solution then I could just iterate through all slices of all drives and run gmirror clear on each, and run dd to clear the first sectors. What btw is in these first sectors? I use this command because I saw it being done in one of the gmirror tutorials. I understand what the gmirror clear command does, but what is the dd command clearing? It clears the MBR (slice table) and GPT or disklabel (partition table), if any. Depending on how many sectors you clear, it will also destroy the beginning the file system, e.g. the first UFS superblock. By the way, if you cannot use gmirror clear for any reason, you can also easily clear the last sector on any devices using the information from diskinfo. For example: DEV=/dev/ad0s1a set -- $(diskinfo $DEV) BLOCKSIZE=$2 MEDIASIZE=$4 LASTSEC=$(( $MEDIASIZE - 1 )) dd if=/dev/zero of=$DEV bs=$BLOCKSIZE seek=$(( $MEDIASIZE - 1 )) count=1 That's pretty much what gmirror clear /dev/ad0s1a does. Best regards Oliver -- Oliver Fromme, secnetix GmbH Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs. -- Robert Firth ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: How to tear down a geom mirror?
Okay, thanks everyone for their feedback. I think I have a workable solution now. Peter - Original Message - From: Oliver Fromme o...@lurza.secnetix.de To: freebsd-hackers@FreeBSD.ORG, pste...@maxiscale.com Sent: Friday, March 6, 2009 11:15:11 AM GMT -08:00 US/Canada Pacific Subject: Re: How to tear down a geom mirror? Peter Steele wrote: Yes. The clear commands usually just zero-out the last sector of the underlying provider (doesn't matter if it's a drive, slice or something altogether different) so you don't have to do it manually. So, as a generic solution then I could just iterate through all slices of all drives and run gmirror clear on each, and run dd to clear the first sectors. What btw is in these first sectors? I use this command because I saw it being done in one of the gmirror tutorials. I understand what the gmirror clear command does, but what is the dd command clearing? It clears the MBR (slice table) and GPT or disklabel (partition table), if any. Depending on how many sectors you clear, it will also destroy the beginning the file system, e.g. the first UFS superblock. By the way, if you cannot use gmirror clear for any reason, you can also easily clear the last sector on any devices using the information from diskinfo. For example: DEV=/dev/ad0s1a set -- $(diskinfo $DEV) BLOCKSIZE=$2 MEDIASIZE=$4 LASTSEC=$(( $MEDIASIZE - 1 )) dd if=/dev/zero of=$DEV bs=$BLOCKSIZE seek=$(( $MEDIASIZE - 1 )) count=1 That's pretty much what gmirror clear /dev/ad0s1a does. Best regards Oliver -- Oliver Fromme, secnetix GmbH Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs. -- Robert Firth ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
How to tear down a geom mirror?
I posed this question in the questions list but didn't get any traction. Hopefully someone here will have an answer. I've created a USB boot disk that is used to clone itself onto the systems hard drives, setting up mirrored file systems in the process. The main difficulty I'm having is reimaging a system with an existing OS whose drives are already configured in a mirror. I want of course to destroy the mirror and create a complete new one, but I can't find the right process to accomplish this reliably. I don't want to make any assumptions about what mirrors might exist already and I definitely don't want to do gmirror load before I get a chance to destroy any existing mirrors. What I am doing is to clean the drive using dd. For example, assume my target system has two drives ad1 and ad2. I issue the following commands: dd if=/dev/zero of=/dev/ad1 bs=512 count=79 dd if=/dev/zero of=/dev/ad2 bs=512 count=79 I'm assuming this is enough to destroy any existing mirrors on the target drives, and I do this before the geom driver is loaded. After this, I partition the drives as I want them, and then create the mirrored pair: gmirror load gmirror label -v -n -b round-robin gm0 ad1s1 gmirror insert gm0 ad2s1 This process works exactly as I want it if the system that is being reimaged has existing mirrors. However, if the drives were previously participating in a mirror, the label command fails, reporting the following error: gmirror: Can't store metadata on ad1s1: Operation not permitted. If I make sure the existing mirrors are torn down first doing an remove operation instead of using the dd method, this can solve the problem, but in some cases the mirror on the target system is in a suspect state and I've seen the gmirror load command hang idefiinitely. So I don't want to do a load command before I destroy the old mirrors, but I can't seem to find a way to reliably destroy the old mirrors. Can anyone suggest a way to do this? ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org