DEV="/dev/${TARGET_DISK}"
-erase_primary_partitions()
+remove_lvm_from_primary_partitions()
{
DISK_DEV="$1"
- mixedgauge "Removing previous disk partitions." 0
+ mixedgauge "Removing LVM state from primary disk partitions." 0
if ! do_cmd vgchange -a n >&2 ; then
echo "ERROR: Failure disabling the LVM contents of disk ${DISK_DEV}.">&2
exit ${Abort}
fi
- REMOVED_OK=0
for DISK_PTN_NODE in ${DISK_DEV}[1-4] ; do
- [ ! -b "${DISK_PTN_NODE}" ] || do_cmd pvremove -ff -y "${DISK_PTN_NODE}" >&2 || REMOVED_OK=1
+ # Ignore errors returned by pvremove here as there may not
+ # actually be any LVM state to remove.
+ # Any important failures here will also cause the later
+ # creation commands to fail, so handle errors there.
+ [ ! -b "${DISK_PTN_NODE}" ] || do_cmd pvremove -ff -y "${DISK_PTN_NODE}" >&2
done
- if [ "${REMOVED_OK}" -ne 0 ] ; then
- echo "ERROR: Failure erasing the contents of disk ${DEV}.">&2
- exit ${Abort}
- fi
}
mk_xc_partition_layout()
do_cmd sfdisk -D ${DISK_DEV} >&2 <<EOF
,,
EOF
- do_cmd dd if=/dev/zero of="${DISK_DEV}" bs=512 count=1
+ do_cmd dd if=/dev/zero of="${DISK_DEV}1" bs=512 count=1
do_cmd sync
mixedgauge "Activating first partition." 15
do_cmd sfdisk "${DISK_DEV}" -A1 >&2
return 0
}
-erase_primary_partitions "${DEV}"
+remove_lvm_from_primary_partitions "${DEV}"
mk_xc_partition_layout "${DEV}"
install_xc_packages "${DEV}"
write_disk_mbr "${DEV}"