How to select a partition for swap instead of entire hard drive?

I keep trying to add a swap partition. I have it set to 31.25GB but when I add a swap according to this wiki tutorial it adds the entire HDD which is a 500GB HDD. How do I select the specific partition?

Please, post your /etc/fstab and output of terminal commands sudo blkid and sudo parted -l.

/etc/fstab

# /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>
UUID=E832-7B45                            /boot/efi      vfat    umask=0077 0 2
UUID=40809886-d17c-433b-876f-89a03d053b64 /              ext4    defaults,noatime 0 1
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0

sudo blkid

/dev/sda1: LABEL_FATBOOT="NO_LABEL" LABEL="NO_LABEL" UUID="E832-7B45" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="62eacffc-cf21-1e47-adf8-75eeed0c029d"
/dev/sda2: UUID="40809886-d17c-433b-876f-89a03d053b64" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="2731d539-9738-b249-8dfc-dd421f2e9500"
/dev/sdb: UUID="925461ec-eacb-45a1-af4c-25dbc5d36137" TYPE="swap"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop0: TYPE="squashfs"

sudo parted -l

Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size   File system  Name  Flags
 1      2097kB  317MB  315MB  fat32              boot, esp
 2      317MB   250GB  250GB  ext4


Model: ATA ST3500312CS (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End    Size   File system     Flags
 1      0.00B  500GB  500GB  linux-swap(v1)

Here’s your problem.
/dev/sdb is a drive. You should have a number afterwards to note a partition (like /dev/sda1).

Did you actually create a partition beforehand in order to set it as swap?

A swap partition can be created in any disk management / partition management tool and should be set as type linuxswap.

1 Like

Okay it looks like I have no idea what I’m doing here. Thank you for your help I think I need to do some research. I made the entire HDD a linux swap and when I try to resize it it goes back to using the entire HDD instead of staying at 31.25GB.

Is it a brand new drive? You may need to create partition table first, so it records the position of your partitions.

No, it’s old. I’m not sure how to use GParted. I don’t see how to make multiple partitions.

Good reading.
https://gparted.org/display-doc.php?name=help-manual

I figured it out. I wasn’t applying operations in GParted. I formatted the drive then performed the proper procedure. Thank you for the help. I chose your second response as a solution because that’s what I was having trouble with.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.