Skip to content

Latest commit

 

History

History
91 lines (73 loc) · 7.42 KB

2022.11.clear.partition.md

File metadata and controls

91 lines (73 loc) · 7.42 KB

清空硬盘分区

项目里面经常遇到无法清空硬盘分区的清空,标准的过程是什么呢?我们借助openshift的脚本,看看openshift是怎么做的

wipefs --force --all /dev/vda

# 获得设备sector数量
blockdev --getsz /dev/vda
# 1048576000

# 设备头,写33个零
dd bs=512 if=/dev/zero of=/dev/vda count=33

# 设备尾,写33个零
dd bs=512 if=/dev/zero of=/dev/vda count=33 seek=1048575967

# 销毁分区
sgdisk -Z /dev/vda
# Creating new GPT entries.
# GPT data structures destroyed! You may now partition the disk using fdisk or
# other utilities.

# 查看设备还有谁在用
fuser /dev/vda

# 等待设备使用者退出
udevadm settle

# 写入镜像测试一下,
qemu-img convert -O host_device -t directsync -S 0 -W /tmp/compressed-rhel-8.6-x86_64-kvm-wzh.qcow2 /dev/vda


log


2022-11-09 15:52:57.005 1 INFO ironic_python_agent.extensions.standby [-] Attempting to download image from http://172.22.0.3:6190/images/rhel-8.6-x86_64-kvm-wzh.qcow2/compressed-rhel-8.6-x86_64-kvm-wzh.qcow2
2022-11-09 15:53:00.448 1 INFO ironic_python_agent.extensions.standby [-] Image downloaded from /tmp/compressed-rhel-8.6-x86_64-kvm-wzh.qcow2 in 3.4566824436187744 seconds
2022-11-09 15:53:00.449 1 DEBUG ironic_python_agent.extensions.standby [-] Verifying image at /tmp/compressed-rhel-8.6-x86_64-kvm-wzh.qcow2 against md5 checksum a078f30e1e2fbd6120f49b2d49d20ed9 verify_image /usr/lib/python3.6/site-packages/ironic_python_agent/extensions/standby.py:395
2022-11-09 15:53:00.451 1 DEBUG ironic_lib.disk_utils [-] Start destroy disk metadata for node . destroy_disk_metadata /usr/lib/python3.6/site-packages/ironic_lib/disk_utils.py:602
2022-11-09 15:53:00.452 1 DEBUG oslo_concurrency.processutils [-] Running cmd (subprocess): wipefs --force --all /dev/vda execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:384
2022-11-09 15:53:00.477 1 DEBUG oslo_concurrency.processutils [-] CMD "wipefs --force --all /dev/vda" returned: 0 in 0.025s execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:423
2022-11-09 15:53:00.479 1 DEBUG ironic_lib.utils [-] Command stdout is: "" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:99
2022-11-09 15:53:00.480 1 DEBUG ironic_lib.utils [-] Command stderr is: "" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:100
2022-11-09 15:53:00.481 1 DEBUG oslo_concurrency.processutils [-] Running cmd (subprocess): blockdev --getsz /dev/vda execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:384
2022-11-09 15:53:00.491 1 DEBUG oslo_concurrency.processutils [-] CMD "blockdev --getsz /dev/vda" returned: 0 in 0.010s execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:423
2022-11-09 15:53:00.492 1 DEBUG ironic_lib.utils [-] Command stdout is: "1048576000
" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:99
2022-11-09 15:53:00.493 1 DEBUG ironic_lib.utils [-] Command stderr is: "" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:100
2022-11-09 15:53:00.494 1 DEBUG oslo_concurrency.processutils [-] Running cmd (subprocess): dd bs=512 if=/dev/zero of=/dev/vda count=33 execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:384
2022-11-09 15:53:00.508 1 DEBUG oslo_concurrency.processutils [-] CMD "dd bs=512 if=/dev/zero of=/dev/vda count=33" returned: 0 in 0.015s execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:423
2022-11-09 15:53:00.510 1 DEBUG ironic_lib.utils [-] Command stdout is: "" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:99
2022-11-09 15:53:00.511 1 DEBUG ironic_lib.utils [-] Command stderr is: "33+0 records in
33+0 records out
16896 bytes (17 kB, 16 KiB) copied, 0.00224917 s, 7.5 MB/s
" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:100
2022-11-09 15:53:00.512 1 DEBUG oslo_concurrency.processutils [-] Running cmd (subprocess): dd bs=512 if=/dev/zero of=/dev/vda count=33 seek=1048575967 execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:384
2022-11-09 15:53:00.524 1 DEBUG oslo_concurrency.processutils [-] CMD "dd bs=512 if=/dev/zero of=/dev/vda count=33 seek=1048575967" returned: 0 in 0.012s execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:423
2022-11-09 15:53:00.525 1 DEBUG ironic_lib.utils [-] Command stdout is: "" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:99
2022-11-09 15:53:00.526 1 DEBUG ironic_lib.utils [-] Command stderr is: "33+0 records in
33+0 records out
16896 bytes (17 kB, 16 KiB) copied, 0.000925569 s, 18.3 MB/s
" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:100
2022-11-09 15:53:00.527 1 DEBUG oslo_concurrency.processutils [-] Running cmd (subprocess): sgdisk -Z /dev/vda execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:384
2022-11-09 15:53:03.558 1 DEBUG oslo_concurrency.processutils [-] CMD "sgdisk -Z /dev/vda" returned: 0 in 3.031s execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:423
2022-11-09 15:53:03.559 1 DEBUG ironic_lib.utils [-] Command stdout is: "Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:99
2022-11-09 15:53:03.560 1 DEBUG ironic_lib.utils [-] Command stderr is: "" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:100
2022-11-09 15:53:03.562 1 DEBUG oslo_concurrency.processutils [-] Running cmd (subprocess): fuser /dev/vda execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:384
2022-11-09 15:53:03.578 1 DEBUG oslo_concurrency.processutils [-] CMD "fuser /dev/vda" returned: 1 in 0.016s execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:423
2022-11-09 15:53:03.580 1 DEBUG ironic_lib.utils [-] Command stdout is: "" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:99
2022-11-09 15:53:03.581 1 DEBUG ironic_lib.utils [-] Command stderr is: "" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:100
2022-11-09 15:53:03.582 1 INFO ironic_lib.disk_utils [-] Disk metadata on /dev/vda successfully destroyed for node
2022-11-09 15:53:03.583 1 DEBUG ironic_lib.disk_utils [-] Waiting until udev event queue is empty udev_settle /usr/lib/python3.6/site-packages/ironic_lib/disk_utils.py:714
2022-11-09 15:53:03.584 1 DEBUG oslo_concurrency.processutils [-] Running cmd (subprocess): udevadm settle execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:384
2022-11-09 15:53:03.606 1 DEBUG oslo_concurrency.processutils [-] CMD "udevadm settle" returned: 0 in 0.022s execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:423
2022-11-09 15:53:03.608 1 DEBUG ironic_lib.utils [-] Command stdout is: "" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:99
2022-11-09 15:53:03.608 1 DEBUG ironic_lib.utils [-] Command stderr is: "" _log /usr/lib/python3.6/site-packages/ironic_lib/utils.py:100
2022-11-09 15:53:03.609 1 INFO ironic_python_agent.extensions.standby [-] Writing image with command: qemu-img convert -t directsync -S 0 -O host_device -W /tmp/compressed-rhel-8.6-x86_64-kvm-wzh.qcow2 /dev/vda
2022-11-09 15:53:03.611 1 DEBUG oslo_concurrency.processutils [-] Running cmd (subprocess): /usr/bin/python3 -m oslo_concurrency.prlimit --as=2147483648 -- qemu-img convert -O host_device -t directsync -S 0 -W /tmp/compressed-rhel-8.6-x86_64-kvm-wzh.qcow2 /dev/vda execute /usr/lib/python3.6/site-packages/oslo_concurrency/processutils.py:384


end