Announcement

Collapse
No announcement yet.

Swap not working after reinstall

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Swap not working after reinstall

    Background: My original problem was that when I tried to do a normal update to the OS, it failed most of the way through, and afterwards very little worked right. Everything I tried only made it worse, so I had to wipe out my OS partition and install a clean copy (my Home is on a separate partition). That went smooth and everything appeared to work fine.

    My problem: It appears that my swap partition isn't working. When I get close to filling up my memory, I start getting memory allocation errors at first, and eventually some program will eventually just die, while my swap never sees any use. (This was unfortunate because it screwed up the installation of a program that was happening at the time that I haven't been able to fix, but I guess that's a different problem.) I checked my fstab and fiddled with it a bit, but that hasn't helped. Here is what it originally was:

    # <file system> <mount point> <type> <options> <dump> <pass>
    # / was on /dev/sda6 during installation
    UUID=number / ext4 errors=remount-ro 0 1
    # /boot/efi was on /dev/sda2 during installation
    UUID=number /boot/efi vfat defaults 0 1
    # /home was on /dev/sda8 during installation
    UUID=number /home ext4 defaults 0 2
    # swap was on /dev/sda7 during installation
    # UUID=number none swap sw 0 0
    /dev/mapper/cryptswap1 none swap sw 0 0
    # Windows is on /dev/sda4
    /dev/sda4 /media/myname/Windows ntfs user,auto,noexec,umask=0 0 0

    Actually I had to add in the Windows bit after install because it wasn't automatically mounting.

    The "fiddling" I did was only to uncomment the "UUID=number none swap sw 0 0" line, but I'm still getting memory allocation errors. I'm afraid I'm out of ideas at this point. TIA
    -Those who dance are considered insane by those who can't hear the music.

    #2
    This is how mine looks

    Code:
    # swap was on /dev/sda9 during installationUUID=f8cd3c1d-1248-4e57-b752-d0978b90c46a none            swap    sw              0       0
    kubuntu 20.10

    Comment


      #3
      The fstab entry looks OK (odd that it was commented out though). But what is that cryptswap line?

      How are your disks set up?
      Code:
      sudo parted -l
      And what does the system think the swap setup is?
      Code:
      swapon -s
      I'd rather be locked out than locked in.

      Comment


        #4
        Originally posted by SecretCode View Post
        The fstab entry looks OK (odd that it was commented out though). But what is that cryptswap line?
        I assume that has something to do with the disk being encrypted?

        Originally posted by SecretCode View Post
        How are your disks set up?
        Code:
        sudo parted -l
        Disk /dev/sda: 1000GB
        Sector size (logical/physical): 512B/4096B
        Partition Table: gpt
        Disk Flags:

        Number Start End Size File system Name Flags
        1 1049kB 1074MB 1073MB ntfs Basic data partition hidden, diag
        2 1074MB 1451MB 377MB fat32 EFI system partition boot, esp
        3 1451MB 1585MB 134MB Microsoft reserved partition msftres
        4 1585MB 251GB 249GB ntfs Basic data partition msftdata
        6 251GB 291GB 40.0GB ext4 msftdata
        7 291GB 300GB 9000MB
        8 300GB 981GB 681GB ext4 msftdata
        5 981GB 1000GB 19.4GB ntfs Basic data partition hidden, msftdata

        Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0
        has been opened read-only.
        Error: /dev/sr0: unrecognised disk label

        Originally posted by SecretCode View Post
        And what does the system think the swap setup is?
        Code:
        swapon -s
        I put that in but it did nothing. Just got the usual command prompt. Could that be because the swap is not active somehow?
        -Those who dance are considered insane by those who can't hear the music.

        Comment


          #5
          Hello Murdoc,
          You do not appear to have a swap partition, not on your first disk anyway, maybe you have another disk?
          The easiest thing to do in this case would be to use a swap file instead of a partition.
          This link has clear instructions.

          Comment


            #6
            I'm pretty sure that is what #7 was there for originally. I guess I must have forgotten to tell the OS this when I reinstalled. Can I just use the partition manager to tell the OS to use it for the swap?
            -Those who dance are considered insane by those who can't hear the music.

            Comment


              #7
              It look like sda7 is available for the swap partition, but because you have encrypted swap set up things may work completely differently ...

              I know nothing about cryptswap, and little about GPT and EFI systems, so you might want to take the following suggestion with a pinch of salt.

              You could try uncommenting the original swap line and commenting out the cryptswap line:
              Code:
              # swap was on /dev/sda7 during installation
              UUID=number none swap sw 0 0
              # /dev/mapper/cryptswap1 none swap sw 0 0
              I'd rather be locked out than locked in.

              Comment


                #8
                Originally posted by Murdoc View Post
                I'm pretty sure that is what #7 was there for originally. I guess I must have forgotten to tell the OS this when I reinstalled. Can I just use the partition manager to tell the OS to use it for the swap?
                You can uncomment it in fstab and then run
                Code:
                sudo mount -a
                and to see if it worked
                Code:
                sudo swapon -s
                If that does not work the easiest way foward is a swap file.

                By the way, this is all detailed in the link I posted above.

                Comment


                  #9
                  Ok, I tried that, and some other fstab configurations, and I still got no result on swapon, as well as still getting the occasional memory allocation error. Thanks for the swap file idea Anika, but I would prefer to leave that as a last resort. I think it would bug me knowing that there's a perfectly good swap partition still there going unused. So I'm going to keep looking into it. Is there any reason I shouldn't give the Partition Editor a try? (I'm using the KDE one.)
                  -Those who dance are considered insane by those who can't hear the music.

                  Comment


                    #10
                    Originally posted by SecretCode View Post
                    It look like sda7 is available for the swap partition, but because you have encrypted swap set up things may work completely differently ...

                    I know nothing about cryptswap, and little about GPT and EFI systems, so you might want to take the following suggestion with a pinch of salt.

                    You could try uncommenting the original swap line and commenting out the cryptswap line:
                    Code:
                    # swap was on /dev/sda7 during installation
                    UUID=number none swap sw 0 0
                    # /dev/mapper/cryptswap1 none swap sw 0 0
                    I would suggest the same.
                    run, to find out the UUID for swap:
                    Code:
                     [FONT=monospace][COLOR=#000000]sudo blkid[/COLOR]
                    [/FONT]
                    if a swap is found it will be shown by the "TYPE", e.g.
                    Code:
                     [FONT=monospace][COLOR=#000000]/dev/sdb5: UUID="8e4d4b42-d629-4fb1-9002-27e2dfd5c548" TYPE="swap"[/COLOR]
                    [/FONT]
                    then run:
                    Code:
                    sudo mount -a
                    then run:
                    Code:
                    sudo swapon -a

                    Comment


                      #11
                      I had this cryptswap as well after installation. But... I also had a non-encrypted swap partition (volume) inside a LVM volume group:

                      Code:
                      # swapon -s
                      Filename                                Type            Size    Used    Priority
                      /dev/dm-2                               partition       4194300 4       -1
                      Code:
                      # vdir /dev/kubuntu-vg/swap
                      lrwxrwxrwx 1 root root 7 mrt 19 22:17 /dev/kubuntu-vg/swap -> ../dm-2
                      I just removed the cryptswap line, I'm not sure what it was good for.

                      Comment


                        #12
                        Originally posted by T[m]LJ View Post
                        I would suggest the same.
                        run, to find out the UUID for swap:
                        Code:
                         [FONT=monospace][COLOR=#000000]sudo blkid[/COLOR]
                        [/FONT]
                        if a swap is found it will be shown by the "TYPE", e.g.
                        Code:
                         [FONT=monospace][COLOR=#000000]/dev/sdb5: UUID="8e4d4b42-d629-4fb1-9002-27e2dfd5c548" TYPE="swap"[/COLOR]
                        [/FONT]
                        then run:
                        Code:
                        sudo mount -a
                        then run:
                        Code:
                        sudo swapon -a
                        Thanks for that idea. I tried the blkid command and it gave me (among other things): /dev/sda7: PARTUUID="96f5bc4e-25d8-403a-962f-d27a6c05cea3"
                        No "TYPE", and nothing else was listed as swap. So I guess I just missed putting it in when I installed the OS, and fstab can't mount it because it was not supposed to be swap as far as the OS is concerned? If so, could using the partition editor help? I would have tried it already given how easy that would be but since I'm still not very familiar with it I didn't want to risk accidentally deleting a partition by trying. But as far as I know, as long as I don't tell it to format any other partitions, or change their sizes, the other partitions should be safe, right? That's what happened when I installed the OS and my home partition was fine.
                        -Those who dance are considered insane by those who can't hear the music.

                        Comment


                          #13
                          The partition editor route should work.

                          There is also mkswap.

                          Code:
                          $ man mkswap
                          
                          NAME
                                 mkswap - set up a Linux swap area
                          
                          SYNOPSIS
                                 mkswap [options] device [size]
                          
                          DESCRIPTION
                                 mkswap sets up a Linux swap area on a device or in a file.
                          Note the "-U, --uuid" option, since it seems like that partition may already have a UUID. Or let it generate a new one and adjust fstab afterwards.

                          Caveat: I know essentially nothing about encrypted swap, so I don't if your device for mkswap would be /dev/sda7 or /dev/mapper/cryptswap1.

                          If mkswap works, then you would do the swapon as noted in earlier posts, and adjust fstab to mount the swap partition during boot.

                          Comment

                          Working...
                          X