FSTAB File mounting Swap partition

How Do I edit the FSTAB file so my Swap Partition will automatically mount at boot up? I tried it and messed up and my system would not boot and I had to boot with a live USB and put the FSTAB back the way it was before I fudged it up.

Thanks

maybe this can help:
--------------references--------------
---------https://help.ubuntu.com/community/Fstab
----- http://ubuntuforums.org/showthread.php?t=1726157 Post #4

Essentially, mounting a drive through /etc/fstab involves:

  1. Creating a mount point, i.e., a directory where the file system of your partition will be “attached”
  2. Adding a line in your /etc/fstab that contains six entries (1) the UUID of the partition (2) the mount point (3) the file system (4) the options (5) a number 0 (a remainder from the old days) and (6) another number indicating priority for checking. Make this 2 for data partitions.

(1) and (3) can be seen from the output of “sudo blkid”. (2) is the directory (full path) you made yourself under 1) (4): If you do not have specific requirements, then put “defaults” there.


----- http://ubuntuforums.org/showthread.php?t=1666086 Post #4

Notes:

  1. fstab is found in /etc
  2. to edit: right click-open as administrator
    =======================================

First find out what your drive system is:

----------get a listing by running> sudo blkid -c /dev/null

/dev/ramzswap0: TYPE=“swap”
/dev/sda1: LABEL=“System.windows” UUID=“9EDC2123DC20F6E5” TYPE=“ntfs”
/dev/sda2: LABEL=“Windows” UUID=“6012230D1222E7AC” TYPE=“ntfs”
/dev/sda5: LABEL=“pinguy.root” UUID=“3f1b1ec5-08de-41db-b561-0a24f4a803d8” TYPE=“ext3”
/dev/sda6: LABEL=“pinguy.home” UUID=“4d18a993-06f3-4abf-bf50-5fe2c63f4536” TYPE=“ext3”
/dev/sda7: UUID=“36eb6399-f7f3-4be3-a2ea-3caf20131502” TYPE=“swap”
/dev/sda8: LABEL=“local-data.ext3” UUID=“e127fbfa-8631-4bda-a366-e4a60b749ad0” SEC_TYPE=“ext2” TYPE=“ext3”
/dev/sdb1: LABEL=“pin11.home” UUID=“a80830b0-2922-4477-a94a-43ab2a3acf15” TYPE=“ext4”
/dev/sdb2: LABEL=“dataBackup” UUID=“c290a199-c742-473c-8d7b-3981063f7e7d” TYPE=“ext4”
/dev/sdb3: LABEL=“pin11.root” UUID=“77a75fef-542d-4ca5-b912-7b894a6e208b” TYPE=“ext4”
/dev/sdb5: UUID=“e142ddea-a830-49d5-8c00-0e436c107d8b” TYPE=“swap”
/dev/sdb6: LABEL=“sdb6” UUID=“3376de83-2f8d-461f-8422-46b773c41cb1” TYPE=“ext4”

copy/paste output to a text file

-----my existing fstab-------->>>> Friday, 09 November 2012

/etc/fstab: static file system information.

Use ‘blkid -o value -s UUID’ 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).

proc /proc proc nodev,noexec,nosuid 0 0

/ was on /dev/sda5 during installation

UUID=3f1b1ec5-08de-41db-b561-0a24f4a803d8 / ext3 errors=remount-ro 0 1

/home was on /dev/sda6 during installation

UUID=4d18a993-06f3-4abf-bf50-5fe2c63f4536 /home ext3 defaults 0 2

swap was on /dev/sda7 during installation

UUID=36eb6399-f7f3-4be3-a2ea-3caf20131502 none swap sw 0 0

-----my new fstab-------->>>> (add the following to the end of /etc/fstab)

user input Friday, 09 November 2012

“local-data.ext3” on primary drive

#/dev/sda8: LABEL=“local-data.ext3” UUID=“e127fbfa-8631-4bda-a366-e4a60b749ad0” SEC_TYPE=“ext2” TYPE=“ext3”
UUID=e127fbfa-8631-4bda-a366-e4a60b749ad0 /media/local-data.ext3 ext3 defaults 0 0

dataBackup on secondary drive

#/dev/sdb2: LABEL=“dataBackup” UUID=“c290a199-c742-473c-8d7b-3981063f7e7d” TYPE=“ext4”
UUID=c290a199-c742-473c-8d7b-3981063f7e7d /media/dataBackup ext4 defaults 0 0

Hi @daldude, could you be misinterpreting “none” in your original fstab entry that looks like this?..

/swapfile    none    swap    sw    0    0

This is the default entry when installed with no swap partition present. It is using a file named “/swapfile” as swap and “none” means it has no mount point.

But it deceptively looks like no swap file is being used.

Defaulting to using a file is relatively new in 18.04 - I’m not sure exactly when it started. But if a swap file IS present on installation it will default to using it and fstab will have this format:

# swap was on /dev/sda2 during installation
UUID=########-####-####-####-############    none    swap    sw    0    0

The UUID ### must be correct or it may have trouble booting (and personal experience tells me UUID mismatch leads to problems not at all obvious where the problem is). Finding it is covered well in @mexsudo 's info.

If I missed the mark, just ignore my info. :slight_smile:

1 Like

Thanks that worked I got my SWAP Partition loaded and active now, it shows up in System Monitor as the size I set it to and in GPARTED if I right click on the SWAP Partition it has the option swap off so that means if I click it will turn off the swap so there for this confirms it’s active. That was easy just did a simple copy and paste from the output of the sudo blkid -c /dev/null command.

Thanks

1 Like

congrats
glad it worked out OK