Why a file as swap can't be used for hibernation in Linux? The 2019 Stack Overflow Developer Survey Results Are InWhy does Linux use a swap partition rather than a file?Can't resume from Suspend / HibernateWhy does resume from hibernation pause/hang?Swap separation for multiple distributionsExtending swap on Centosdebian 8 shutdown dialog change hibernate button methodhow does systemd activate encrypted swap file on alternate partition?Hibernation of a dual boot machine with a shared writable partitionWhy simultaneous use of multiple swap space rather than sequentially, in accordance with the priority?Attributes of Swap PartitionDual-boot Linux & hiberantion: share swap partitionHibernation not working on Linux Mint 19

Dropping list elements from nested list after evaluation

Is it safe to harvest rainwater that fell on solar panels?

Match Roman Numerals

Worn-tile Scrabble

"as much details as you can remember"

Can you cast a spell on someone in the Ethereal Plane, if you are on the Material Plane and have the True Seeing spell active?

Correct punctuation for showing a character's confusion

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

Why is this code so slow?

Kerning for subscripts of sigma?

Is bread bad for ducks?

Why doesn't shell automatically fix "useless use of cat"?

How to type a long/em dash `—`

Why not take a picture of a closer black hole?

What is the most efficient way to store a numeric range?

Keeping a retro style to sci-fi spaceships?

Variable with quotation marks "$()"

Are spiders unable to hurt humans, especially very small spiders?

How do you keep chess fun when your opponent constantly beats you?

How much of the clove should I use when using big garlic heads?

Why doesn't UInt have a toDouble()?

Why can't wing-mounted spoilers be used to steepen approaches?



Why a file as swap can't be used for hibernation in Linux?



The 2019 Stack Overflow Developer Survey Results Are InWhy does Linux use a swap partition rather than a file?Can't resume from Suspend / HibernateWhy does resume from hibernation pause/hang?Swap separation for multiple distributionsExtending swap on Centosdebian 8 shutdown dialog change hibernate button methodhow does systemd activate encrypted swap file on alternate partition?Hibernation of a dual boot machine with a shared writable partitionWhy simultaneous use of multiple swap space rather than sequentially, in accordance with the priority?Attributes of Swap PartitionDual-boot Linux & hiberantion: share swap partitionHibernation not working on Linux Mint 19



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I was trying to hibernate my Fedora 27 system temporarily using a swap file and failed. Answers in the following question also says that a dedicated swap partition must be used to hibernate the system and swapfile can't server the purpose.



Why does Linux use a swap partition rather than a file?



I'm using ext3 file system in which I created the swapfile. What is stopping the swapfile to be used for hibernation?










share|improve this question

















  • 3





    kernel.org/doc/Documentation/power/swsusp-and-swap-files.txt

    – don_crissti
    Mar 28 '18 at 22:39

















1















I was trying to hibernate my Fedora 27 system temporarily using a swap file and failed. Answers in the following question also says that a dedicated swap partition must be used to hibernate the system and swapfile can't server the purpose.



Why does Linux use a swap partition rather than a file?



I'm using ext3 file system in which I created the swapfile. What is stopping the swapfile to be used for hibernation?










share|improve this question

















  • 3





    kernel.org/doc/Documentation/power/swsusp-and-swap-files.txt

    – don_crissti
    Mar 28 '18 at 22:39













1












1








1








I was trying to hibernate my Fedora 27 system temporarily using a swap file and failed. Answers in the following question also says that a dedicated swap partition must be used to hibernate the system and swapfile can't server the purpose.



Why does Linux use a swap partition rather than a file?



I'm using ext3 file system in which I created the swapfile. What is stopping the swapfile to be used for hibernation?










share|improve this question














I was trying to hibernate my Fedora 27 system temporarily using a swap file and failed. Answers in the following question also says that a dedicated swap partition must be used to hibernate the system and swapfile can't server the purpose.



Why does Linux use a swap partition rather than a file?



I'm using ext3 file system in which I created the swapfile. What is stopping the swapfile to be used for hibernation?







linux swap hibernate






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 '18 at 21:37









Abhik BoseAbhik Bose

1,5811424




1,5811424







  • 3





    kernel.org/doc/Documentation/power/swsusp-and-swap-files.txt

    – don_crissti
    Mar 28 '18 at 22:39












  • 3





    kernel.org/doc/Documentation/power/swsusp-and-swap-files.txt

    – don_crissti
    Mar 28 '18 at 22:39







3




3





kernel.org/doc/Documentation/power/swsusp-and-swap-files.txt

– don_crissti
Mar 28 '18 at 22:39





kernel.org/doc/Documentation/power/swsusp-and-swap-files.txt

– don_crissti
Mar 28 '18 at 22:39










2 Answers
2






active

oldest

votes


















1














As said here (link provided by @don_crissti), the system must locate the swap file's header, but in order to do this the filesystem that contains the swap file must be mounted, and a journaled filesystem (as ext3 is) cannot be mounted during resume from disk.



Quoting from the document:




In order to use a swap file with swsusp, you need to:



1) Create the swap file and make it active, eg.



# dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k>



# mkswap <swap_file_path>



# swapon <swap_file_path>



2) Use an application that will bmap the swap file with the help of the
FIBMAP ioctl and determine the location of the file's swap header, as the
offset, in <PAGE_SIZE> units, from the beginning of the partition which
holds the swap file.



3) Add the following parameters to the kernel command line:



resume=<swap_file_partition> resume_offset=<swap_file_offset>



where <swap_file_partition> is the partition on which the swap file is located
and <swap_file_offset> is the offset of the swap header determined by the
application in 2) (of course, this step may be carried out automatically
by the same application that determines the swap file's header offset using the
FIBMAP ioctl)



OR



Use a userland suspend application that will set the partition and offset
with the help of the SNAPSHOT_SET_SWAP_AREA ioctl described in
Documentation/power/userland-swsusp.txt (this is the only method to suspend
to a swap file allowing the resume to be initiated from an initrd or initramfs
image).







share|improve this answer






























    0














    You can do this, I've written a big documentation in this SO reply, globally it is working by using uswsusp and configuring initramfs & Grub correctly.






    share|improve this answer























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f434177%2fwhy-a-file-as-swap-cant-be-used-for-hibernation-in-linux%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      As said here (link provided by @don_crissti), the system must locate the swap file's header, but in order to do this the filesystem that contains the swap file must be mounted, and a journaled filesystem (as ext3 is) cannot be mounted during resume from disk.



      Quoting from the document:




      In order to use a swap file with swsusp, you need to:



      1) Create the swap file and make it active, eg.



      # dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k>



      # mkswap <swap_file_path>



      # swapon <swap_file_path>



      2) Use an application that will bmap the swap file with the help of the
      FIBMAP ioctl and determine the location of the file's swap header, as the
      offset, in <PAGE_SIZE> units, from the beginning of the partition which
      holds the swap file.



      3) Add the following parameters to the kernel command line:



      resume=<swap_file_partition> resume_offset=<swap_file_offset>



      where <swap_file_partition> is the partition on which the swap file is located
      and <swap_file_offset> is the offset of the swap header determined by the
      application in 2) (of course, this step may be carried out automatically
      by the same application that determines the swap file's header offset using the
      FIBMAP ioctl)



      OR



      Use a userland suspend application that will set the partition and offset
      with the help of the SNAPSHOT_SET_SWAP_AREA ioctl described in
      Documentation/power/userland-swsusp.txt (this is the only method to suspend
      to a swap file allowing the resume to be initiated from an initrd or initramfs
      image).







      share|improve this answer



























        1














        As said here (link provided by @don_crissti), the system must locate the swap file's header, but in order to do this the filesystem that contains the swap file must be mounted, and a journaled filesystem (as ext3 is) cannot be mounted during resume from disk.



        Quoting from the document:




        In order to use a swap file with swsusp, you need to:



        1) Create the swap file and make it active, eg.



        # dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k>



        # mkswap <swap_file_path>



        # swapon <swap_file_path>



        2) Use an application that will bmap the swap file with the help of the
        FIBMAP ioctl and determine the location of the file's swap header, as the
        offset, in <PAGE_SIZE> units, from the beginning of the partition which
        holds the swap file.



        3) Add the following parameters to the kernel command line:



        resume=<swap_file_partition> resume_offset=<swap_file_offset>



        where <swap_file_partition> is the partition on which the swap file is located
        and <swap_file_offset> is the offset of the swap header determined by the
        application in 2) (of course, this step may be carried out automatically
        by the same application that determines the swap file's header offset using the
        FIBMAP ioctl)



        OR



        Use a userland suspend application that will set the partition and offset
        with the help of the SNAPSHOT_SET_SWAP_AREA ioctl described in
        Documentation/power/userland-swsusp.txt (this is the only method to suspend
        to a swap file allowing the resume to be initiated from an initrd or initramfs
        image).







        share|improve this answer

























          1












          1








          1







          As said here (link provided by @don_crissti), the system must locate the swap file's header, but in order to do this the filesystem that contains the swap file must be mounted, and a journaled filesystem (as ext3 is) cannot be mounted during resume from disk.



          Quoting from the document:




          In order to use a swap file with swsusp, you need to:



          1) Create the swap file and make it active, eg.



          # dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k>



          # mkswap <swap_file_path>



          # swapon <swap_file_path>



          2) Use an application that will bmap the swap file with the help of the
          FIBMAP ioctl and determine the location of the file's swap header, as the
          offset, in <PAGE_SIZE> units, from the beginning of the partition which
          holds the swap file.



          3) Add the following parameters to the kernel command line:



          resume=<swap_file_partition> resume_offset=<swap_file_offset>



          where <swap_file_partition> is the partition on which the swap file is located
          and <swap_file_offset> is the offset of the swap header determined by the
          application in 2) (of course, this step may be carried out automatically
          by the same application that determines the swap file's header offset using the
          FIBMAP ioctl)



          OR



          Use a userland suspend application that will set the partition and offset
          with the help of the SNAPSHOT_SET_SWAP_AREA ioctl described in
          Documentation/power/userland-swsusp.txt (this is the only method to suspend
          to a swap file allowing the resume to be initiated from an initrd or initramfs
          image).







          share|improve this answer













          As said here (link provided by @don_crissti), the system must locate the swap file's header, but in order to do this the filesystem that contains the swap file must be mounted, and a journaled filesystem (as ext3 is) cannot be mounted during resume from disk.



          Quoting from the document:




          In order to use a swap file with swsusp, you need to:



          1) Create the swap file and make it active, eg.



          # dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k>



          # mkswap <swap_file_path>



          # swapon <swap_file_path>



          2) Use an application that will bmap the swap file with the help of the
          FIBMAP ioctl and determine the location of the file's swap header, as the
          offset, in <PAGE_SIZE> units, from the beginning of the partition which
          holds the swap file.



          3) Add the following parameters to the kernel command line:



          resume=<swap_file_partition> resume_offset=<swap_file_offset>



          where <swap_file_partition> is the partition on which the swap file is located
          and <swap_file_offset> is the offset of the swap header determined by the
          application in 2) (of course, this step may be carried out automatically
          by the same application that determines the swap file's header offset using the
          FIBMAP ioctl)



          OR



          Use a userland suspend application that will set the partition and offset
          with the help of the SNAPSHOT_SET_SWAP_AREA ioctl described in
          Documentation/power/userland-swsusp.txt (this is the only method to suspend
          to a swap file allowing the resume to be initiated from an initrd or initramfs
          image).








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 29 '18 at 10:43









          dr01dr01

          16.3k115475




          16.3k115475























              0














              You can do this, I've written a big documentation in this SO reply, globally it is working by using uswsusp and configuring initramfs & Grub correctly.






              share|improve this answer



























                0














                You can do this, I've written a big documentation in this SO reply, globally it is working by using uswsusp and configuring initramfs & Grub correctly.






                share|improve this answer

























                  0












                  0








                  0







                  You can do this, I've written a big documentation in this SO reply, globally it is working by using uswsusp and configuring initramfs & Grub correctly.






                  share|improve this answer













                  You can do this, I've written a big documentation in this SO reply, globally it is working by using uswsusp and configuring initramfs & Grub correctly.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 8 at 13:50









                  Anthony O.Anthony O.

                  34538




                  34538



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f434177%2fwhy-a-file-as-swap-cant-be-used-for-hibernation-in-linux%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

                      Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

                      Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.