WARNING: performing these operations can be dangerous to desired data. Be careful against which drives you apply these commands.
Acquire current geometry:
$ sudo sfdisk -d /dev/sda label: dos label-id: 0x1bc93b71 device: /dev/sda unit: sectors sector-size: 512 /dev/sda1 : start= 2048, size= 524288, type=b $ sudo sfdisk -d /dev/sda > sda.txt
Kill the partition table (dangerous!):
$ sudo dd if=/dev/zero of=/dev/sda count=1 bs=512 1+0 records in 1+0 records out 512 bytes copied, 0.00642451 s, 79.7 kB/s $ sudo fdisk -l /dev/sda Disk /dev/sda: 57.73 GiB, 61984505856 bytes, 121063488 sectors Disk model: DataTraveler 2.0 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
Rebuild the drive, equally dangerous, but with some backup with the -O:
$ sudo sfdisk -O sfdisk.save /dev/sda < sda.txt Checking that no-one is using this disk right now ... OK Disk /dev/sda: 57.73 GiB, 61984505856 bytes, 121063488 sectors Disk model: DataTraveler 2.0 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes >>> Script header accepted. >>> Script header accepted. >>> Script header accepted. >>> Script header accepted. >>> Script header accepted. >>> Created a new DOS disklabel with disk identifier 0x1bc93b71. /dev/sda1: Created a new partition 1 of type 'W95 FAT32' and of size 256 MiB. Partition #1 contains a vfat signature. /dev/sda2: Done. New situation: Disklabel type: dos Disk identifier: 0x1bc93b71 Device Boot Start End Sectors Size Id Type /dev/sda1 2048 526335 524288 256M b W95 FAT32 The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Check the partition tables;
$ sudo fdisk -l /dev/sda Disk /dev/sda: 57.73 GiB, 61984505856 bytes, 121063488 sectors Disk model: DataTraveler 2.0 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x1bc93b71 Device Boot Start End Sectors Size Id Type /dev/sda1 2048 526335 524288 256M b W95 FAT32
Format the filesystem:
$ sudo mkfs -t vfat /dev/sda1 mkfs.fat 4.1 (2017-01-24)
user manual for sfdisk, which learned about at How to run fdisk in non-interactive batch mode.
I used fdisk /dev/sda to create the initial flavour of the vfat 256MB drive. Not much space is required to build a disk for ipxe boot operations (using a Dell Wyse 3040 ThinClient which does not seem to know how to PXE boot natively).