I'm using a swap file instead of a partition?

Hello,
I noticed in the boot process report that a swap file is used instead of the swap partition despite I created the swap partition when I installed Ubuntu MATE.

I have the following swap file:

$ ls -l /swapfile
-rw------- 1 root root 2147483648 Jan 31 15:34 /swapfile

And this is the output of swapon:

$ swapon --show
NAME      TYPE SIZE USED PRIO
/swapfile file   2G   0B   -2

This is how I have partitioned my hard drives:

$ sudo fdisk -l
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x9f639bb5

Device     Boot  Start        End    Sectors   Size Id Type
/dev/sda1  *      2048     206847     204800   100M  7 HPFS/NTFS/exFAT
/dev/sda2       206848 1953521663 1953314816 931.4G  7 HPFS/NTFS/exFAT




Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x2bb55f09

Device     Boot   Start        End    Sectors   Size Id Type
/dev/sdb1          2048    7929855    7927808   3.8G 82 Linux swap / Solaris
/dev/sdb2       7931902 1953523711 1945591810 927.7G  5 Extended
/dev/sdb5       7931904 1953523711 1945591808 927.7G 83 Linux

Partition 2 does not start on physical sector boundary.

As you can see, I have a swap partition. I created it in Ubiquity when I installed Ubuntu MATE. Why is it using a swap file and how can I use the partition instead?

Thanks in advance.

Not the answer, but a followup question:

When upgrading from 16.04 to 18.04 I noticed a file vice a partition was used for swap. But I don't understand the advantages and disadvantages of either method.

can you post your /etc/fstab ?

To switch to partition, take a look at:

Yes, here it is:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sdb5 during installation
UUID=6a6a0d47-4825-4715-8d14-01b16351c855 /               ext4    errors=remount-ro 0       1
/swapfile                               none            swap    sw                0       0

I knew swap files were the default in Ubuntu 17.04. That's why I created the swap partition, I wanted Ubuntu to use it.

So in order to use the swap partition, the UUID of which is 9b3d4180-b524-4558-8fca-a11a0834dd11, I have to add the following to /etc/fstab:

UUID=9b3d4180-b524-4558-8fca-a11a0834dd11 none            swap    sw              0       0

Right?

that looks right (you can find the UUID of each drive with blkid)

Just curious why you would choose a partition over file? Is there any performance difference or just old habit?