printf("Setting up swapspace version 1, size = %"OFF_FMT"u bytes\n", len);
mkswap_selinux_setcontext(fd, argv[0]);
- /* Make a header. hdr is zero-filled so far... */
+ /* hdr is zero-filled so far. Clear the first kbyte, or else
+ * mkswap-ing former FAT partition does NOT erase its signature.
+ *
+ * util-linux-ng 2.17.2 claims to erase it only if it does not see
+ * a partition table and is not run on whole disk. -f forces it.
+ */
+ xwrite(fd, hdr, 1024);
+
+ /* Fill the header. */
hdr->version = 1;
hdr->last_page = (uoff_t)len / pagesize;
/* Write the header. Sync to disk because some kernel versions check
* signature on disk (not in cache) during swapon. */
- xlseek(fd, 1024, SEEK_SET);
xwrite(fd, hdr, NWORDS * 4);
xlseek(fd, pagesize - 10, SEEK_SET);
xwrite(fd, SWAPSPACE2, 10);