Results 1 to 3 of 3

Thread: Guide to hibernation dual-boot Ubuntu 16.04 and Windows 7

  1. #1
    Join Date
    Aug 2016

    Post Guide to hibernation dual-boot Ubuntu 16.04 and Windows 7

    Reason for this guide
    There is a lot on hibernation around the internet, but when I tried to activate hibernate in combination with dual boot Ubuntu 16.04 and Windows 7, I noticed much was outdated or scattered all over the interwebz.
    So therefore I would like to post all information I gathered in a single post, hopefully helping others.

    General information / remarks

    My setup
    • BIOS (not UEFI)
    • SSD NTFS with Windows 7 (first in boot order)
    • SSD ext4 with Ubuntu 16.04
    • HDD NTFS for data
    • RAM: 16GB

    If you already have a swap partition with at least the size of your RAM (if you want to be on the safe side, use a swap partition of double the size of your RAM), you can skip the swap partition step and go to HIBERNATE step.
    To check whether you have a swap partition (shows nothing if you don't have it, else the following):
    $ sudo swapon --show
    /dev/sdb2 partition  17G   0B   -1
    Or to also check your RAM size (total is 0 if you don't have a swap partition active):
    $ free -h
                  total        used        free      shared  buff/cache   available
    Mem:            15G        2,3G         12G        143M        1,1G         12G
    Swap:           16G          0B         16G
    If you don't have a swap partition yet, we're going to make one now using `gparted`.
    If you have unallocated disk space on your HDD / SSD, I think you can just use `gparted` while running Ubuntu. It doesn't come standard with your Ubuntu installation, so use:
    sudo apt install gparted
    If you don't have any unallocated space left (which is likely the case), we have to resize your Ubuntu partition first (or some other partition, but that's outside the scope of this guide).
    You cannot resize a partition while it is in use, so you need to make a LiveUSB (or CD) first.
    Download your Ubuntu distribution and follow this guide:

    1. Restart your computer and boot from the USB stick and select `Try Ubuntu without installing`.
    2. Select `Search your computer` and type: `GParted Partition Editor` (which is standard included in the LiveUSB)
    3. Select your drive with Ubuntu on it in the right-top corner (in my case: `/dev/sdb`)
    4. Right-click your partition with Ubuntu and select `Resize/Move` (in my case `/dev/sdb1` with File System `ext4`)
    5. Change the `Free space following (MiB)` from `0` to a minimum of your RAM size and if you want to be on the safe side, double of your RAM size. (not preceding, because then you probably corrupt your

    6. Right-click your now unallocated space and select `New`
    7. Leave the default options, except change File system from `ext4` --> `linux-swap`
    8. Press the checkmark icon ✓ to apply all changes when you're sure.
    9. Shutdown your computer, remove your USB and reboot into Ubuntu.
    10. Congratulations, you made a swap partition! but it's not activated yet

    Get UUID of swap partition
    Based on:

    To get a nice overview of your HDD/SSD and partitions:
    but to get the actual swap partition, run:
    sudo fdisk -l
    and find something that looks similar to:
    Device     Boot     Start       End   Sectors   Size Id Type
    /dev/sdb1  *         2048 464465919 464463872 221,5G 83 Linux
    /dev/sdb2       464465920 500117503  35651584    17G 82 Linux swap / Solaris
    Referring to your device based on where it is mounted is not really robust and can change if you for example plug in a USB stick. Therefore we need the UUID of our swap partition (in this case `/dev/sdb2`, but change XY to your own):
    sudo blkid /dev/sdXY
    /dev/sdb2: UUID="735b3be3-779c-4d21-a944-b033225f3ab4" TYPE="swap" PARTUUID="352a5b25-02"
    We need this UUID for later so notate this somewhere: UUID=735b3be3-779c-4d21-a944-b033225f3ab4 (but with your own UUID).

    Activate swap partition
    1. Make a backup of your fstab file:
      • Code:
        sudo cp /etc/fstab /etc/fstab.bak

    2. Edit your `fstab` file to include the UUID of your swap partition:
      1. Code:
        sudo nano /etc/fstab
      2. Add the following line (with `xxx` being your UUID):
        UUID=xxx none            swap    sw                0       0
      3. Save the file and exit (ctrl+x --> y --> enter)

    3. Reboot your computer
    4. Check if swap partition still exist with:
      • Code:
        $ cat /proc/swaps
        Filename                Type        Size    Used    Priority
        /dev/sdb2                               partition    17825788    0    -1

    Edit grub so your swap partition can be used at resume

    1. Backup your `grub` file
      • Code:
        sudo cp /etc/default/grub /etc/default/grub.bak

    2. Edit your grub file:
      1. Code:
        sudo nano /etc/default/grub
      2. Edit the line `GRUB_CMDLINE_LINUX=""` (with xxx being your own UUID) -->
      3. Save the file and exit (ctrl+x --> y --> enter)

    3. Code:
      sudo update-grub
    4. Create a resume file an add your UUID with the following commands:
      1. Code:
        sudo nano /etc/initramfs-tools/conf.d/resume
      2. resume=UUID=xxx
      3. Save the file and exit (ctrl+x --> y --> enter)

    5. Code:
      sudo update-initramfs -u
    6. Reboot!

    HIBERNATE in start menu
    Based on:

    First we try if hibernate works, otherwise you either missed something above, my guide is incomplete or your computer needs something specific. Try hibernate with the following code:
    sudo pm-hibernate
    In my case my computer starts with: `Resuming hibernate` and then boots into W7...
    but if I restart my computer again, press in my BIOS boot options and select my SSD with Ubuntu, Grub starts, I select Ubuntu and it indeed resumes

    To add hibernate as option to the start menu we first have to create the file: `com.ubuntu.enable-hibernate.pkla` and then add the hibernate information
    1. Code:
      sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
    2. Paste the following in it:
      [Re-enable hibernate by default in upower]
      [Re-enable hibernate by default in logind]
    3. Save the file
    4. Reboot and you have your hibernate option!

    After the first hibernation I get a resume hibernation and always have to boot to Windows 7. After that I can restart and choose W7 or Ubuntu. Probably because I have my W7 SSD as first boot priority. I tried removing:
    [Re-enable hibernate by default in upower]
    but to no avail. If anyone has suggestion on how to only get resume hibernation when the Ubuntu SSD is selected,
    and not skip BIOS at startup, that would be a nice addition to this guide.
    Last edited by ajgreeny; August 18th, 2016 at 02:07 PM. Reason: Font normalised

  2. #2
    Join Date
    Jul 2005
    I think I'm here! Maybe?

    Re: Guide to hibernation dual-boot Ubuntu 16.04 and Windows 7

    Thread moved to Ubuntu, Linux and OS Chat. which is more appropriate for the post which is not a support request.
    DISTRO: Xubuntu 18.04-64bit --- Code-tags --- Boot-Repair --- Grub2 wiki & Grub2 Basics --- RootSudo --- Wireless-Info --- SolvedThreads

  3. #3
    Join Date
    Aug 2016

    Re: Guide to hibernation dual-boot Ubuntu 16.04 and Windows 7

    To reduce the risk of bricking your Windows so that it won't start, you can disable auto-mount and/or write access to your drives such as your Windows drive:

    In case you suffer data-corruption, take a look here:

    And IMPORTANT, auto unmount drives on hibernate if your setup allows you (to prevent data-corruption):

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts