• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • How to clear/delete all the partition table from a disk or partition in 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.

    I hope the article was useful.

    Deepak Prasad

    Deepak Prasad is a techie and an author who is still trying to survive in this IT generation with very little knowledge he has on Linux/Unix, VMware, SAN Storage, Automation, networking etc

    You can follow him on Facebook or Google+

    Do you also have something to share here?

    Become an author and be a part of our GoLinuxHub Team, Click here for more information
    How to clear/delete all the partition table from a disk or partition in Linux How to clear/delete all the partition table from a disk or partition in Linux Reviewed by Deepak Prasad on Sunday, May 06, 2018 Rating: 5

    No comments:

    Powered by Blogger.