Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 45

Thread: HOWTO: Use swapfile instead of partition and hibernate

  1. #11
    Join Date
    May 2008
    Beans
    203

    Re: HOWTO: Use swapfile instead of partition and hibernate

    1-How can we reverse this? Activation of swap file takes very long at the boot time.
    2-Plus now i am using lvm. It is not a problem to make a new partition.
    3-How can we sure that hibernate works if we already have not a swap partition before making swapfile?

  2. #12
    Join Date
    May 2008
    Beans
    203

    Re: HOWTO: Use swapfile instead of partition and hibernate

    Up!

  3. #13
    Join Date
    Apr 2006
    Location
    Silicon Valley
    Beans
    19

    Re: HOWTO: Use swapfile instead of partition and hibernate

    To reverse swapfile setup, you need to go through these steps:

    Code:
    sudo -b gedit /etc/fstab
    Edit /etc/fstab and :

    1. Reverse changes (Remove or comment out ALL swap files)
    2. Restore / Add new line:

    Code:
    /dev/...   none   swap   sw   0   0
    Where /dev/... is your swap partition

    Code:
    sudo swapoff -a
    sudo swapon /dev/...
    Replace UUID and resume_offset:
    Code:
    echo "resume=UUID=<your UUID> resume_offset=0" | sudo tee /etc/initramfs-tools/conf.d/resume
    Now edit GRUB configuration:
    Code:
    sudo -b gedit /boot/grub/menu.lst
    Find the line "# kopt=root=UUID=..."
    and change it to "resume=UUID=<your UUID> resume_offset=0" (without quotes).
    Note that your UUID in above two cases will be your swap partition UUID.

    It should look like this (with your UUID and offset):
    Code:
    # kopt=root=UUID=... ro resume=UUID=cd71de6f-907a-40d7-bf26-c17f201e5718 resume_offset=0
    Make sure you have no carriage returns in this line.

    Now let's run the tools to make them work:

    Code:
    sudo update-grub -y
    Answer "install the package maintainer's version" if it asks.

    Code:
    sudo update-initramfs -u
    Verify that all your kernel stanzas (menu entries) got updated in /boot/grub/menu.lst with resume=... and resume_offset=0, if not - verify your # kopt= line - it should have # and space. Rerun update-grub if necessary. It may keep your old file if you chose wrong answer above.

    Now reboot before trying to hibernate, so kernel gets the right resume_offset parameter.

    After reboot, try to hibernate. It should get right back to this window after you power your computer back up.

    Now you can get rid of the old swapfile.
    Last edited by iva2k; September 7th, 2011 at 09:03 PM. Reason: Complete instructions for removal

  4. #14
    Join Date
    May 2008
    Beans
    203

    Re: HOWTO: Use swapfile instead of partition and hibernate

    Thank you. Should we do anything with this command?

    sudo update-initramfs -u

  5. #15
    Join Date
    Apr 2006
    Location
    Silicon Valley
    Beans
    19

    Re: HOWTO: Use swapfile instead of partition and hibernate

    Quote Originally Posted by medic2000 View Post
    Thank you. Should we do anything with this command?

    sudo update-initramfs -u
    You're right, thanks for noticing it. Not only that, but GRUB menu should be changed. I've edited my previous post to include these steps.

  6. #16
    Join Date
    Jun 2006
    Location
    Canberra, Australia
    Beans
    70

    Re: HOWTO: Use swapfile instead of partition and hibernate

    thanks, it worked like a charm (on jaunty, on an apple machine)

  7. #17
    Join Date
    Jun 2008
    Beans
    5

    Re: HOWTO: Use swapfile instead of partition and hibernate

    Hi, will this howto work for karmic with grub2? Any changes or improvements needed?

  8. #18
    Join Date
    Apr 2006
    Location
    Silicon Valley
    Beans
    19

    Re: HOWTO: Use swapfile instead of partition and hibernate

    Quote Originally Posted by asenyshyn View Post
    Hi, will this howto work for karmic with grub2? Any changes or improvements needed?
    I did not try it yet, so cannot say definitively.

  9. #19
    Join Date
    Apr 2008
    Location
    i live on the web!
    Beans
    13
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: HOWTO: Use swapfile instead of partition and hibernate

    interesting post indeed, thank you very much for your efforts.

    Will we have hiberfil.sys-equivalent under karmic?

  10. #20
    Join Date
    Nov 2009
    Beans
    4

    Wink Re: HOWTO: Use swapfile instead of partition and hibernate

    Just got it working with Karmic (Kubuntu amd64).

    As in Karmic grub is " upgraded" to version 2, it took some reading (see: http://ubuntuforums.org/showthread.php?t=1195275 ).

    Another "difference" is the use of filefrag, it seems that one is "upgraded" also, so iva2k's code will not work as printed.

    All other commands are valid still.

    Things I did:
    After creation of the swapfile, I tried to check it with filefrag. However, my 6G file was setting filefrag into a loop and there was no "First block:" output anywhere. It seems that when you have a a file that is bigger than 4G (or about), filefrag restarts counting the logical blocks and gets itself in a loop.

    So I checked filefrag out and it seems it is changed conforming some proposals back in 2007. It now uses FIEMAP instead of FIBMAP and its output is changed. From what I found, the first physical (block?) in its output seems to be the needed offset.

    In post http://forums.fedoraforum.org/showthread.php?t=204114 a swap_offset utility was mentioned, so I installed the corresponding uswsusp and used the tool. It did give me the same number back.

    Then I made an 07_hibernation file in /etc/grub.d/ out of the 40_custom file already given there.
    I picked 07, so I have this on top and selected in grub during boot time and I wouldn' t have to change the grub file in /etc/default/ also.
    Code:
    menuentry "Ubuntu 9.10 Hibernation, Linux 2.6.31-14-generic" {
        set root=(hd0,3)
        search --no-floppy --fs-uuid --set d3b0cf1a-99ca-43c1-a058-d7c38c0b6171
        linux    /boot/vmlinuz-2.6.31-14-generic root=UUID=d3b0cf1a-99ca-43c1-a058-d7c38c0b6171 ro resume=UUID=d3b0cf1a-99ca-43c1-a058-d7c38c0b6171 resume_offset=1544
        initrd    /boot/initrd.img-2.6.31-14-generic
    }
    This text need to come directly below the last comment line in the file, as it seems that when there is an empty line at that position, the entry will not be picked up by upgrade-grub. Note: I omitted the quit and splash parameters to be able to see what was happening, add these if you like.

    After this, I used the update-grub code (I think grub2 didn't like the -y at the end, but I am not sure anymore) and the initramfs-tools code.

    Hibernation will not work at that point, however.
    It seems that you need to reboot the machine and select the boot-option with the resume-entry first, and only then you are able to set the machine into hibernation.

    If you boot with any other (non-resume) entry, now or later, you get an "PM: Swap header not found" message during hibernation and the machine will go into a clean boot the next time.

    I would like to know if this can be solved, or that it is inherent to the way hibernation (and booting) works. However, given the fact that hibernation is working, I can live with that.

    Hibernation in (K)Ubuntu is painfully slow compaired to what I was used to in Windows, but I'll take it because I don' t need to give all my different passwords the next time I boot and want to start WiFi (KWallet), Firefox and my encrypted datacontainers.

Page 2 of 5 FirstFirst 1234 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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