ntfs-3g
ntfs-3g copied to clipboard
add wipefs to 'mkfs.ntfs --fast'
Hi,
'mkfs.ntfs --fast' failed to overwrite the existing filesystem. so, we need add wipefs to 'mkfs.ntfs --fast'
version: v2022.5.17
# mkfs.btrfs -f /dev/vdb1
# wipefs /dev/vdb1
DEVICE OFFSET TYPE UUID LABEL
vdb1 0x10040 btrfs 8bcc3d4f-a878-4caa-a992-5bebd8cfea55
# mkfs.ntfs --fast /dev/vdb1
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
# mount /dev/vdb1 /mnt/test/
mount: /dev/vdb1: more filesystems detected. This should not happen,
use -t <type> to explicitly specify the filesystem type or
use wipefs(8) to clean up the device.
# wipefs /dev/vdb1
DEVICE OFFSET TYPE UUID LABEL
vdb1 0x3 ntfs 6DEE42C2228DCC8C
vdb1 0x10040 btrfs 8bcc3d4f-a878-4caa-a992-5bebd8cfea55
vdb1 0x1fe dos
#
we need to detect the exist filesystem and ' -F, --force' to overwrite it?
a dirty fix to wipefs when 'mkfs.ntfs --fast'
@@ -3539,6 +3539,12 @@ static BOOL mkntfs_open_partition(ntfs_volume *vol)
}
ntfs_log_warning("mkntfs forced anyway. Hope /etc/mtab is incorrect.\n");
}
+ {
+ static u8 zero_to_wipefs[256*1024];
+ vol->dev->d_ops->seek(vol->dev, 0, SEEK_SET);
+ mkntfs_write(vol->dev, &zero_to_wipefs, sizeof(zero_to_wipefs));
+ vol->dev->d_ops->seek(vol->dev, 0, SEEK_SET);
+ }
result = TRUE;
done:
return result;