如何使用 sgdisk 清除/擦除找到的分区的内容

如何使用 sgdisk 清除/擦除找到的分区的内容

我有一个要求,如果我使用 skids -p /dev/sdc 找到我的分区,那么我需要清除特定分区的内容。如何使用 sgdisk 命令执行此操作?

假设我找到了 Client_Image 分区,需要清除其中的内容

# sudo sgdisk -p /dev/sdc
Disk /dev/sdc: 15654912 sectors, 7.5 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 8C5B1844-CEAE-2370-00BD-D0E47E3C9900
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 15654878
Partitions will be aligned on 2-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34         2097151   1024.0 MiB  0700  Linux data
   2         2097152         8388607   3.0 GiB     0700  Shared FAT
   3         8388608        15654878   3.5 GiB     A503  Client_Image

答案1

sgdisk手册页

   -d, --delete=partnum
          Delete a partition. This action deletes the entry from the partition table but does
          not disturb the data within the sectors originally allocated to  the  partition  on
          the  disk.  If  a  corresponding  hybrid MBR partition exists, gdisk deletes it, as
          well, and expands any adjacent 0xEE (EFI GPT) MBR protective partition to fill  the
          new free space.

因此,删除分区Client_Image(编号3)

sudo sgdisk -d 3 -s /dev/sdc

将会删除分区 3,然后对修改后的分区表进行排序。

相关内容