# Adding swap /hibernation after install

**URL:** <https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831>\
**Category:** EndeavourOS installation\
**Created:** [December 30, 2020, 7:07pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831 "2020-12-30T19:07:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ricklinux](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ricklinux/32/110798_2.png) [@ricklinux](https://forum.endeavouros.com/u/ricklinux)\
**Post date:** [December 30, 2020, 7:07pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/1 "2020-12-30T19:07:15Z")

</div>

I did a fresh install again on a new laptop dual boot Windows. I created a partition for linux and used replace partition in the installer. Ive been messing with this trying to figure out the best setup. I want the system when i close the lid to hibernate. Right now it is set to suspend but i see i don’t have swap or hibernate so I’m not sure it’s doing that or just shutting down the display. I left it overnight and battery was dead already. My fstab is them following.

```auto
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=F23A-62B4 /boot/efi vfat umask=0077 0 2
UUID=1b3dcd7d-b403-4b62-975f-ebbb0c435982 / ext4 defaults,noatime 0 1
[ricklinux@eos-xfce ~]$ 

```

Can i add hibernation after the fact? I need swap file to do that and add info to my fstab?  
If i do this I’m looking to have the laptop shutdown on hibernation. Is that the way it hibernates?

---

<div class="post-metadata">

**Author:** ![tlmiller76](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/tlmiller76/32/96350_2.png) [@tlmiller76](https://forum.endeavouros.com/u/tlmiller76)\
**Post date:** [December 30, 2020, 7:12pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/2 "2020-12-30T19:12:48Z")

</div>

Yes, you need swap{partition,file} to hibernate.

Also yes, hibernate actually fully powers off the machine after saving your current state into your swap and setting it to resume from swap. However, I will say, if you have an SSD, hibernation doesn’t get you much. Resuming from hibernate vs. power off/on when system is on an SSD is pretty much the same speed (possible 1-3 seconds slower w/ power on, but very similar).

Yes, you can definitely add hibernate after the fact, but there’s a LITTLE more to setting up hibernate from a swapfile than from a swap partition.

---

<div class="post-metadata">

**Author:** ![ricklinux](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ricklinux/32/110798_2.png) [@ricklinux](https://forum.endeavouros.com/u/ricklinux)\
**Post date:** [December 30, 2020, 7:24pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/3 "2020-12-30T19:24:28Z")

</div>

I just might wipe this off again and install it with hibernation and try it first. Then i will add Windows maybe? Everything seems to work including backlighting. I’ve been experimenting with it. It’s not that I mind Windows it’s the 3rd party crapware and Microsoft’s own crap it installs. I usually take everything out except for Windows 10 and then i add what i want with software. Not Windows store apps.

---

<div class="post-metadata">

**Author:** ![tlmiller76](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/tlmiller76/32/96350_2.png) [@tlmiller76](https://forum.endeavouros.com/u/tlmiller76)\
**Post date:** [December 30, 2020, 7:29pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/4 "2020-12-30T19:29:10Z")

</div>

Always install Windows first. Windows does not play well with being installed after other OS’s.

---

<div class="post-metadata">

**Author:** ![joekamprad](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/joekamprad/32/77608_2.png) [@joekamprad](https://forum.endeavouros.com/u/joekamprad)\
**Post date:** [December 30, 2020, 7:40pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/5 "2020-12-30T19:40:55Z")

</div>

swapfile should do the job, as it does not need to change partitions

---

<div class="post-metadata">

**Author:** ![ringo](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ringo/32/66182_2.png) [@ringo](https://forum.endeavouros.com/u/ringo)\
**Post date:** [December 30, 2020, 7:51pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/6 "2020-12-30T19:51:56Z")

</div>

doens forget the resume= otherwise is useless that swapfile 🙂

---

<div class="post-metadata">

**Author:** ![ricklinux](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ricklinux/32/110798_2.png) [@ricklinux](https://forum.endeavouros.com/u/ricklinux)\
**Post date:** [December 30, 2020, 8:08pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/7 "2020-12-30T20:08:56Z")

</div>

Can you explain how i do this before i end up doing another bare metal install? First make a swap file. Then i have to add stuff to fstab? Plus i have to edit grub?

---

<div class="post-metadata">

**Author:** ![otherbarry](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/otherbarry/32/10801_2.png) [@otherbarry](https://forum.endeavouros.com/u/otherbarry)\
**Post date:** [December 30, 2020, 8:14pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/8 "2020-12-30T20:14:25Z")

</div>

You need a swap partition and `resume=swap_device` kernel parameter to hibernate your system state, although this works a bit differently if encryption is involved.

[https://wiki.archlinux.org/index.php/Power\_management/Suspend\_and\_hibernate#Hibernation](https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation)

Better to test install your setup on a VM first, rather than bare metal, particularly if not 100% sure of how it all works.

I’d recommend not just simpy re-installing, this could be a good learning process for you, just make any mistakes in a VM first.

---

<div class="post-metadata">

**Author:** ![ricklinux](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ricklinux/32/110798_2.png) [@ricklinux](https://forum.endeavouros.com/u/ricklinux)\
**Post date:** [December 30, 2020, 8:20pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/9 "2020-12-30T20:20:16Z")

</div>

I just made a swap file but it doesn’t show anything in fstab? I guess that is only if you create a swap partition?

```auto
[ricklinux@eos-xfce ~]$ free
              total used free shared buff/cache available
Mem: 7554380 1236852 138024 149352 6179504 5865508
Swap: 8191996 0 8191996
[ricklinux@eos-xfce ~]$ 

```

Edit: Can i just hibernate to this swap file? Do i need to do anything else?

---

<div class="post-metadata">

**Author:** ![otherbarry](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/otherbarry/32/10801_2.png) [@otherbarry](https://forum.endeavouros.com/u/otherbarry)\
**Post date:** [December 30, 2020, 8:22pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/10 "2020-12-30T20:22:39Z")

</div>

You need to add a swap file entry manually, simply creating a file doesn’t create the fstab entry automatically.

```auto
/swapfile none swap defaults 0 0

```

Take your time. Read the Arch Wiki and understand what you are doing instead of just shooting from from the hip.

I wouldn’t recommend using a swap file for hibernation either.

[https://wiki.archlinux.org/index.php/Swap#Swap\_partition](https://wiki.archlinux.org/index.php/Swap#Swap_partition)

---

<div class="post-metadata">

**Author:** ![joekamprad](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/joekamprad/32/77608_2.png) [@joekamprad](https://forum.endeavouros.com/u/joekamprad)\
**Post date:** [December 30, 2020, 8:31pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/11 "2020-12-30T20:31:18Z")

</div>

`sudo dd if=/dev/zero of=/swapfile bs=1M count=512 status=progress`  
512 must be changed to the size you want (size of your RAM alike)

```auto
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

```

Finally, edit the fstab configuration to add an entry for the swap file:

`sudo nano /etc/fstab`

```auto

/swapfile none swap defaults 0 0

```

simple as this… to get it working for hibernation/suspend:

Add the resume option to grub kernel line  
to the the UUID of the partition containing your `/swapfile`:

```auto
sudo findmnt -no UUID -T /swapfile

```

`sudo nano /etc/default/grub`

```auto
# GRUB boot loader configuration

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="EndeavourOS"
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 resume=UUID= **put the uuid here** nowatchdog"

```

regenerating grub.cfg 🖖  
` sudo grub-mkconfig -o /boot/grub/grub.cfg`

# note:

—\>  
go to the updated wiki page instead it includes also systemd-boot and more:  
[https://discovery.endeavouros.com/storage-and-partitions/adding-swap-after-installation/2021/03/](https://discovery.endeavouros.com/storage-and-partitions/adding-swap-after-installation/2021/03/)

---

<div class="post-metadata">

**Author:** ![ricklinux](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ricklinux/32/110798_2.png) [@ricklinux](https://forum.endeavouros.com/u/ricklinux)\
**Post date:** [December 30, 2020, 8:33pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/12 "2020-12-30T20:33:01Z")

</div>

I have 8G ram. I used 8000 which gave me 7.8G swap file should i go bigger?

---

<div class="post-metadata">

**Author:** ![joekamprad](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/joekamprad/32/77608_2.png) [@joekamprad](https://forum.endeavouros.com/u/joekamprad)\
**Post date:** [December 30, 2020, 8:33pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/13 "2020-12-30T20:33:25Z")

</div>

should be fine

---

<div class="post-metadata">

**Author:** ![tlmiller76](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/tlmiller76/32/96350_2.png) [@tlmiller76](https://forum.endeavouros.com/u/tlmiller76)\
**Post date:** [December 30, 2020, 8:37pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/14 "2020-12-30T20:37:34Z")

</div>

I actually use fallocate for creating mine, so that I can specify the size in GiB (Gibibytes), so that it’s truly 8. Easier than doing the maths for dd. 😃

`fallocate -l 8Gib /swapfile`

---

<div class="post-metadata">

**Author:** ![pebcak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/pebcak/32/100472_2.png) [@pebcak](https://forum.endeavouros.com/u/pebcak)\
**Post date:** [December 30, 2020, 8:43pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/15 "2020-12-30T20:43:10Z")

</div>

Besides the `resume=UUID=` a `resume_offset` value needs also to be added to the boot parameters when hibernating into a swapfile:

[https://wiki.archlinux.org/index.php/Power\_management/Suspend\_and\_hibernate#Hibernation](https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation)

---

<div class="post-metadata">

**Author:** ![ricklinux](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ricklinux/32/110798_2.png) [@ricklinux](https://forum.endeavouros.com/u/ricklinux)\
**Post date:** [December 30, 2020, 8:43pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/16 "2020-12-30T20:43:32Z")

</div>

Okay i left it at 7.8G. I’m going to try it this way. Thanks!

---

<div class="post-metadata">

**Author:** ![joekamprad](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/joekamprad/32/77608_2.png) [@joekamprad](https://forum.endeavouros.com/u/joekamprad)\
**Post date:** [December 30, 2020, 8:50pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/17 "2020-12-30T20:50:35Z")

</div>

> [@tlmiller76](#):
>
> fallocate

be aware of files with holes 🤓  
[https://jlk.fjfi.cvut.cz/arch/manpages/man/swapon.8#Files\_with\_holes](https://jlk.fjfi.cvut.cz/arch/manpages/man/swapon.8#Files_with_holes)

---

<div class="post-metadata">

**Author:** ![ricklinux](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ricklinux/32/110798_2.png) [@ricklinux](https://forum.endeavouros.com/u/ricklinux)\
**Post date:** [December 30, 2020, 8:52pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/18 "2020-12-30T20:52:05Z")

</div>

As if i don’t have enough to hurt my little brain! 🤣

Edit: I think it’s beware of holes in your head?

---

<div class="post-metadata">

**Author:** ![tlmiller76](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/tlmiller76/32/96350_2.png) [@tlmiller76](https://forum.endeavouros.com/u/tlmiller76)\
**Post date:** [December 30, 2020, 8:53pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/19 "2020-12-30T20:53:08Z")

</div>

Eh, it’s not hard. Do it a couple times in a VM and it’ll be simple as anything. Yeah, a few extra commands, but still easy. Just…not worth it to me since I moved to SSD’s.

---

<div class="post-metadata">

**Author:** ![otherbarry](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/otherbarry/32/10801_2.png) [@otherbarry](https://forum.endeavouros.com/u/otherbarry)\
**Post date:** [December 30, 2020, 8:53pm UTC](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831/20 "2020-12-30T20:53:20Z")

</div>

IDK, simply giving a list of commands to blindly copy and paste doesn’t really help  
Rick understand, which IMHO doesn’t really help him in the long run.

I understand EndeavourOS is not Arch, but a certain degree of encouragement to learn should be given for such a simple task.

1 . Create swap partition.  
2 . Set resume kernel parameter to swap partition UUID.

IDK.

[Next page](https://forum.endeavouros.com/t/adding-swap-hibernation-after-install/10831.md?page=2)
