2
sfdisk --delete $disk

From Ubuntu 18.04 or later works. What is the equivalent command in Ubuntu 16.04 LTS?

Ubuntu 16.04 LTS (--delete missing),

Ubuntu 18.04 LTS (--delete present)

intika
  • 13,920
  • 7
  • 41
  • 79

2 Answers2

3

Solution 1: build and install sfdisk from sources (to be able to use a more recent version)

wget https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.35/util-linux-2.35.tar.gz
tar -xvf util-linux-2.35.tar.gz
cd cd util-linux-2.35
./configure 
make
make install
/usr/local/bin/sfdisk --delete $disk

Solution 2: use fdisk

# list disk and partitions
fdisk -l
# open the target disk with fdisk
fdisk /dev/target-disk
# then use the d command option to delete the partition you want to remove
# then use the w command option to save the changes 
intika
  • 13,920
  • 7
  • 41
  • 79
0

wipefs -a -f $disk

will do the trick

user4089
  • 878
  • 6
  • 14