i deleted my swap partition


  • 1
    Oops 😐
  • 8
    Recreating it is easy. Are you having trouble with it?
  • 0
    yeah, i tried several approaches.
    it's not working
    i'm going to reinstall linux
  • 2
    Should be easy
  • 12
    @amirbig that's... not the way you solve a problem like that
  • 4
    @amirbig Don't solve it as you would in Windows. All you have to do is create a deap partition and put it into fstab from another OS (live USB?) lol
  • 7
    Just create the partition in fdisk, mark it as swap for posterity, do a mkswap and swapon on the device.
  • 14
    “I lost the keys to my car. Oh well, I’ll just buy another car.”
  • 6
    @amirbig Don't reinstall. You can make a new swap partition of any size (generally x1 - x1.5 times of the installed RAM size is what swap size is set to).

    Then you can do 'sudo swapon /dev/sdX' (/dev/sdX being the swap partition) and bam - you got your swap back.

    Next just update your '/etcfstab' you should probably still have the old swap specified here, so kust update that.
  • 4
    Sorry it's '/etc/fstab'.
  • 3
    Recreat flag it like swap
  • 2
    thank you guys for your help ☺️
  • 4
    @theKarlisK so I should set my swap to 16gb if I have 16gb RAM ? Yes I do have it set like that indeed but only because I use the ram.
    Normal people firstly won't need 16gb RAM and second surely not 1x ram for swap. Its usually 0.5x ram size for swap if its larger then 8gb.
  • 0
    @Haxk20 see, this is why it has always confused me - every distro tries to set it to 1:1 or more, no matter how much ram you got... some even refuse to to install if no swap is specified, which I find annoying (I got 32GB RAM... but apparently that's not enough? Wut?).

    Fedora even tried to smuggle in 128GB swap partition when I was trying to set up a test KVM host on an old Intel server once.
  • 4
    @theKarlisK 128Gb ? WTF ? See this is why i set swap manually. Always to half my ram on big RAM. I would even set it to 8Gb with 32Gb RAM.
  • 1
    @theKarlisK if you plan to use hibernation, swap size should be larger than ram size. If no hibernation, a couple gigs should be fine.
  • 0
    @Haxk20 I know right? I usually autocreate the partitions then adjust the size and partitions.

    @electrineer admittedly I haven't encountered a computer which was able to do hibernation successfully. That and most of the computers run on SSDs so if I'm not mistaken, hybernation is unhealty for SSDs.
  • 3
    @theKarlisK With modern SSDs its kind of OK. And @theellectrocioner has a point tho. But I think Linux kernel now hibernates onto a disk if the swap isn't big enough.
  • 3
    My laptop can do hibernation properly BTW. I'm fucking lucky I guess.
  • 2
    all distros i tried force hibernated on poweroff (on an SSD, which it saw as an SSD) so i had to manually break the hibernation feature by giving my swap a new UID after install so initramtools didn't see it anymore.

    I want my shit to actually SHUT DOWN when i tell it to shut down. This is shit Windows pulls, why is Linux doing it now...

    anyways i usually use LARGE partitions for everything (1GB for /boot, 32GB for root, /usr, /usr/bin, /lib, /opt, /etc, etc. /home gets everything that's left, split 50/50 with another partition if I need one) so swap gets 1x to 2x the physical RAM size (better safe than SIGSEGV!)
Your Job Suck?
Get a Better Job
Add Comment