To start from a clean state I need to reset the hard disk to an empty state from command line.
It is not about running a wipe utility, the data don't have to be overwritten.
This question is quite similar to Deleting All Partitions From the Command Line
The solution there works quite well,
dd if=/dev/zero of=/dev/sda bs=512 count=1 conv=notrunc
but if I want to work with such an overwritten disk, I get the error that the device is still in use.
root@grml ~ # blockdev --rereadpt /dev/sda
BLKRRPART: Device or resource busy
or
root@grml ~ # partprobe
Error: Partition(s) 2, 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.
Error: Partition(s) 2, 3 on /dev/sdb have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.
So I have to manually disable everything which "sits" on the device
umount /mnt/debootstrap
umount /mnt/debootstrap/tmp
umount /mnt/debootstrap/var/log
umount /mnt/debootstrap/var
umount /mnt/debootstrap/home
service mdadm stop
service lvm2 stop
vgremove vg_main
pvremove /dev/md1
mdadm --stop /dev/md0
mdadm --stop /dev/md1
mdadm --remove /dev/md0
mdadm --remove /dev/md1
after that the partprobe
command works.
is there some command which works simpler? like
harddiskreset /dev/sda
so it can easily be used on systems with different partition/lvm/md layout?