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
SWAP PARTITION
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):
Code:
$ sudo swapon --show
NAME TYPE SIZE USED PRIO
/dev/sdb2 partition 17G 0B -1
Code:
$ 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:
Code:
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: http://ift.tt/Tuh3e5
- Restart your computer and boot from the USB stick and select `Try Ubuntu without installing`.
- Select `Search your computer` and type: `GParted Partition Editor` (which is standard included in the LiveUSB)
- Select your drive with Ubuntu on it in the right-top corner (in my case: `/dev/sdb`)
- Right-click your partition with Ubuntu and select `Resize/Move` (in my case `/dev/sdb1` with File System `ext4`)
- 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
- Right-click your now unallocated space and select `New`
- Leave the default options, except change File system from `ext4` --> `linux-swap`
- Press the checkmark icon ✓ to apply all changes when you're sure.
- Shutdown your computer, remove your USB and reboot into Ubuntu.
- Congratulations, you made a swap partition! but it's not activated yet
Get UUID of swap partition
Based on: http://ift.tt/1eKSv5D
Code:
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
Code:
sudo fdisk -l
and find something that looks similar to:
Code:
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
Code:
sudo blkid /dev/sdXY /dev/sdb2: UUID="735b3be3-779c-4d21-a944-b033225f3ab4" TYPE="swap" PARTUUID="352a5b25-02"
Activate swap partition
- Make a backup of your fstab file:
-
Code:
sudo cp /etc/fstab /etc/fstab.bak
-
- Edit your `fstab` file to include the UUID of your swap partition:
-
Code:
sudo nano /etc/fstab
- Add the following line (with `xxx` being your UUID):
Code:
UUID=xxx none swap sw 0 0
- Save the file and exit (ctrl+x --> y --> enter)
-
- Reboot your computer
- 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
- Backup your `grub` file
-
Code:
sudo cp /etc/default/grub /etc/default/grub.bak
-
- Edit your grub file:
-
Code:
sudo nano /etc/default/grub
- Edit the line `GRUB_CMDLINE_LINUX=""` (with xxx being your own UUID) -->
Code:
GRUB_CMDLINE_LINUX="resume=UUID=xxx"
- Save the file and exit (ctrl+x --> y --> enter)
-
-
Code:
sudo update-grub
- Create a resume file an add your UUID with the following commands:
-
Code:
sudo nano /etc/initramfs-tools/conf.d/resume
- resume=UUID=xxx
- Save the file and exit (ctrl+x --> y --> enter)
-
-
Code:
sudo update-initramfs -u
- Reboot!
HIBERNATE in start menu
Based on: http://ift.tt/2b323xe
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:
Code:
sudo pm-hibernate
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
-
Code:
sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
- Paste the following in it:
Code:
[Re-enable hibernate by default in upower] Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=yes [Re-enable hibernate by default in logind] Identity=unix-user:* Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions ResultActive=yes
- Save the file
- Reboot and you have your hibernate option!
Problem
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:
Code:
[Re-enable hibernate by default in upower] Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=yes
and not skip BIOS at startup, that would be a nice addition to this guide.
[ubuntu] Guide to hibernation dual-boot Ubuntu 16.04 and Windows 7
Aucun commentaire:
Enregistrer un commentaire