I created a partition called /dev/sda3 as a swap partition, and changed the ID to 82 (Linux Swap) via fdisk. If this partition was recognized as a swap partition (seen in the output of fdisk -l and blkid), then why couldn't I proceed straight to swapon /dev/sda3? Why did I have to execute mkswap /dev/sda3?
Another question, is partition information exclusive from data? So if I changed a filesystem type via fdisk would data be affected?
fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008d6ed
Device Boot Start End Blocks Id System
/dev/sda1 * 1 32 256000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 32 1566 12317696 83 Linux
/dev/sda3 1566 2610 8390105 82 Linux swap / Solaris
blkid
/dev/sda3: LABEL="SWAP" UUID="63f1807e-7cc6-4339-92b2-b1958fcf285e" TYPE="swap"
Best Answer
fdisk creates a partition but doesn't format it. Before you can use your swap partition, you need to format it first. This is done with mkswap.
The same rules apply for any other file systems. You need to create the partition and format it before using it.