PDA

View Full Version : How to automount swap file in fstab after reinstall?



Candleflame
25th June 2017, 12:15 PM
I had to reinstall Fedora yesterday due to a systemcrash during kernel update.

No problem, I kept my /home and swap partition (LVM) and just reinstalled / and the bootloader.

The problem is that the old swapfile does not get automounted when restarting fedora.

In the diskmanager there is a tick next to automount. It nevertheless does not work.

I have added the swap file to my fstab manually and it looks like this now:

/dev/mapper/fedora-root / ext4 defaults 1 1
UUID=7FBD-02C6 /boot/efi vfat umask=0077,shortname=winnt 0 2
/dev/mapper/fedora-home /home ext4 defaults 1 2
/dev/mapper/fedora-swap none ext4 defaults 0 0


Still, no success.

Fstab -l shows the following (Swap is not mounted):

Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 56155800-7F7F-4641-BAA8-EEF5B3F111F9

Device Start End Sectors Size Type
/dev/sda1 2048 514047 512000 250M EFI System
/dev/sda2 514048 500117503 499603456 238.2G Linux LVM


Disk /dev/mapper/fedora-root: 14.7 GiB, 15728640000 bytes, 30720000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/fedora-swap: 3.9 GiB, 4194304000 bytes, 8192000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/fedora-home: 219.7 GiB, 235870879744 bytes, 460685312 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes


Can anybody help?

sidebrnz
26th June 2017, 12:46 AM
Well, no wonder: /dev/mapper/fedora-swap is formatted as ext4, and it needs to be formatted as swap. What else would you expect?

Candleflame
26th June 2017, 07:52 PM
I would expect nothing less as that it should work as I did not know that swap is formatted as swap - I only typed this in manually after all...

It probably tells you during the installation that swap doesnt use ext but I only ever did this once on my laptop. My desktop doesnt have a swap file. Not one I specifically set up anyways.

thanks anyways for the solution

lsatenstein
26th June 2017, 08:02 PM
After you reformat the swap partition and correct the swap file definition in the fstab,
/dev/mapper/fedora-swap none swap defaults 0 0
you should verify, quite easy with using gparted, that you have swapon enabled for the swap file.
swapon lets Linux know that the swap file is usable.

Candleflame
26th June 2017, 09:24 PM
nah the swap file was always working fine, it is just about being auto mounted which works fine now with changing ext4 to swap.

The definition was wrong as i just typed the wrong definition in.