Debian/Ubuntu: Expand disk clearing steps

This covers more scenarios, including the need to stop md arrays and
wipe MD partitions.

Signed-off-by: Richard Laager <rlaager@wiktel.com>
Requested-by: Larry Wagner <larrywagner0@gmail.com>
This commit is contained in:
Richard Laager
2020-05-30 13:26:53 -05:00
parent 4d3d0bdf55
commit c9e868af21
2 changed files with 27 additions and 2 deletions

View File

@@ -167,15 +167,28 @@ Step 2: Disk Formatting
#. If you are re-using a disk, clear it as necessary: #. If you are re-using a disk, clear it as necessary:
If the disk was previously used in an MD array, zero the superblock:: If the disk was previously used in an MD array::
apt install --yes mdadm apt install --yes mdadm
# See if one or more MD arrays are active:
cat /proc/mdstat
# If so, stop them (replace ``md0`` as required):
mdadm --stop /dev/md0
# For an array using the whole disk:
mdadm --zero-superblock --force $DISK mdadm --zero-superblock --force $DISK
# For an array using a partition:
mdadm --zero-superblock --force ${DISK}-part2
Clear the partition table:: Clear the partition table::
sgdisk --zap-all $DISK sgdisk --zap-all $DISK
If you get a message about the kernel still using the old partition table,
reboot and start over (except that you can skip this step).
#. Partition your disk(s): #. Partition your disk(s):
Run this if you need legacy (BIOS) booting:: Run this if you need legacy (BIOS) booting::

View File

@@ -197,15 +197,27 @@ Step 2: Disk Formatting
#. If you are re-using a disk, clear it as necessary: #. If you are re-using a disk, clear it as necessary:
If the disk was previously used in an MD array, zero the superblock:: If the disk was previously used in an MD array::
apt install --yes mdadm apt install --yes mdadm
# See if one or more MD arrays are active:
cat /proc/mdstat
# If so, stop them (replace ``md0`` as required):
mdadm --stop /dev/md0
# For an array using the whole disk:
mdadm --zero-superblock --force $DISK mdadm --zero-superblock --force $DISK
# For an array using a partition (e.g. a swap partition per this HOWTO):
mdadm --zero-superblock --force ${DISK}-part2
Clear the partition table:: Clear the partition table::
sgdisk --zap-all $DISK sgdisk --zap-all $DISK
If you get a message about the kernel still using the old partition table,
reboot and start over (except that you can skip this step).
#. Create bootloader partition(s):: #. Create bootloader partition(s)::
sgdisk -n1:1M:+512M -t1:EF00 $DISK sgdisk -n1:1M:+512M -t1:EF00 $DISK