zoukankan      html  css  js  c++  java
  • How to clear/delete all the partition table from a disk or partition in Linux

    https://www.golinuxhub.com/2018/05/how-to-cleardelete-partition-table-disk-linux/

    Below article is a must read to understand all about partition, partition scheme and partition table

    Everything you need to know about a partition, types of partition, partition scheme

    To clear a partition table, wipefs command can be used

     

    Here I have a disk /dev/sdb which I have added to my Linux box for this article.
    In this disk I have created two primary partitions

    # fdisk -l /dev/sdb

    Disk /dev/sdb: 17.2 GB, 17179869184 bytes, 33554432 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x1410600c

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048     4196351     2097152   83  Linux
    /dev/sdb2         4196352    10487807     3145728   83  Linux

    Now I would like to clear the partition table from this disk
    To do so below commands can be used

    Check the partition table

    # wipefs /dev/sdb
    offset               type
    —————————————————————-
    0x1fe                dos   [partition table]

    Here I have a dos partition table

    Clear the partition table

    Using the below command you can wipe “dos” partition table

    # wipefs -a -t dos -f /dev/sdb
    /dev/sdb: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
    /dev/sdb: calling ioclt to re-read partition table: Success

    If I had a GPT partition table then to clear the same

    # wipefs -a -t gpt -f /dev/sdb

    To clear all the partition tables

    # wipefs -a -f /dev/sdb

    You can also delete a partition table using the offset value as shown above

    # wipefs -o 0x1fe /dev/sdb

    Once the above command returns success, check the partition table using fdisk

    # fdisk -l /dev/sdb

    Disk /dev/sdb: 17.2 GB, 17179869184 bytes, 33554432 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes

    As you both my partitions are cleared/deleted.

    Also read:
     

    I hope the article was useful.

  • 相关阅读:
    typescript提示implicitly has an 'any' type 问题
    element-ui中的table可分页多选功能-记住上一页勾选数据
    CSS加载会阻塞页面显示?
    网络流(EK算法)
    网络流(dinic算法)
    洛谷p1120小木棍(剪枝优化)
    三种背包模板
    HDU2089-不要62(数位dp)
    windy数(数位dp)
    素数判定(待填坑)
  • 原文地址:https://www.cnblogs.com/dhcn/p/14280969.html
Copyright © 2011-2022 走看看