-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WiP] wipe existing RAID and disks before creating a new one. #5
base: master
Are you sure you want to change the base?
Conversation
if os.path.exists(raid_device): | ||
util.runCmd2(['mdadm', '--stop', '--force', raid_device]) | ||
for dev in members: | ||
util.runCmd2(['dd', 'if=/dev/zero', 'of=%s' % dev, 'bs=512', 'count=1']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand, we zero out the 512 first bytes of each partition? What about mdadm superblocks that would be at the end of the partitions? Someone suggested to write zeroes there too, should we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the first 512 bits of each disk, that destroys their partition too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I thought we were going to iterate over the partitions in case they were part of a raid array (instead of the whole disk itself), to avoid having the mdadm superblock "resurrect" by chance if the new partition scheme is similar to the old one. But maybe destroying the partition table is enough...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, let me think.
basically, I was trying not to ever parse the existing RAID configuration, and only decide things based on new information. Maybe it's wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant is not to parse the existing RAID configuration but rather to read the partition table, and for each partition found, destroy the first and last bytes of the partition just in case there would be a superblock there.
Then maybe also destroy the partition table itself like you did and also probably the end of the disk in case there would be a superblock for a disk-wide RAID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thought (from the discussion in the issue), it is possible that mdadm would automatically detect a RAID array and start it, which means that we'd need to stop it before wiping things, to avoid errors, like they did in xcp-ng/xcp#107 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's the parsing issue, we have to look at all the RAID in the system, parse their configuration, and only stop those whose array include one of the disks we are about to destroy.
Ought to be a solution to xcp-ng/xcp#107
Still need testing.