Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nraynaud
Copy link
Member

@nraynaud nraynaud commented Jan 3, 2019

Ought to be a solution to xcp-ng/xcp#107

Still need testing.

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'])
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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...

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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)

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants