Linux swap file creation and managementWhere to put swap space, at beginning or end and other swap questionsKVM and swap problemWhy my partitions don't show the right capacity on a 4096 byte physical block hard drive?Linux, SSD and swapHow to safely turn off swap permanently and reclaim the space? (on Debian Jessie)Swap Total and Swap free 0K totalHow do I remove a swap partition that no longer exists?Ubuntu 14.04 32 bit swapfile max 60k issueSwap partition and swap file at the same time?Will swap file engage automatically when I write too much to /dev/shm

Shell script can be run only with sh command

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

How can bays and straits be determined in a procedurally generated map?

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

How to make payment on the internet without leaving a money trail?

Why don't electron-positron collisions release infinite energy?

Why CLRS example on residual networks does not follows its formula?

Why is "Reports" in sentence down without "The"

How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?

What makes Graph invariants so useful/important?

Do airline pilots ever risk not hearing communication directed to them specifically, from traffic controllers?

What are these boxed doors outside store fronts in New York?

Are tax years 2016 & 2017 back taxes deductible for tax year 2018?

Infinite past with a beginning?

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?

How do I create uniquely male characters?

Why was the small council so happy for Tyrion to become the Master of Coin?

Why do we use polarized capacitor?

Japan - Plan around max visa duration

Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).

What is the white spray-pattern residue inside these Falcon Heavy nozzles?

How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)

Can I make popcorn with any corn?



Linux swap file creation and management


Where to put swap space, at beginning or end and other swap questionsKVM and swap problemWhy my partitions don't show the right capacity on a 4096 byte physical block hard drive?Linux, SSD and swapHow to safely turn off swap permanently and reclaim the space? (on Debian Jessie)Swap Total and Swap free 0K totalHow do I remove a swap partition that no longer exists?Ubuntu 14.04 32 bit swapfile max 60k issueSwap partition and swap file at the same time?Will swap file engage automatically when I write too much to /dev/shm






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








4















I want to increase my swap size to be able to have the hibernate option. First, I tried to add some swapfile. I followed



https://bogdancornianu.com/change-swap-size-in-ubuntu/



and typed this in my terminal:



sudo dd if=/dev/zero of=swapfile bs=1G count=16


I get:



16+0 records in
16+0 records out
17179869184 bytes (17 GB, 16 GiB) copied, 206.949 s, 83.0 MB/s


then, I followed the instructions:



sudo mkswap /swapfile


But I get this error:



mkswap: cannot open /swapfile: No such file or directory


Then, I decided to resize my swap partition instead of swapfile. So I want to delete them. (I didn't create any before so I assume I can delete them all?)
I followed this:



https://askubuntu.com/questions/904628/default-17-04-swap-file-location



I tried:



$ cat /proc/swaps
$ grep swap /etc/fstab


But I get nothing from the first one. Output from the second one is:



 total used free shared buff/cache 
available
Mem: 11862 3498 1014 138 7349
7907
Swap: 0 0 0


I also tried (after reboot):



swapon -s


and get



Filename Type Size Used Priority
/dev/sdb3 partition 3905532 0 -2


I wonder that did I successfully create swapfiles? How do I delete them if I did?










share|improve this question



















  • 1





    Hello, our new contributor! Please read our guidelines, and maybe more important note: You should really really read properly what you are typing, there is no space for typos in Linux!

    – Vlastimil
    Mar 26 at 16:19

















4















I want to increase my swap size to be able to have the hibernate option. First, I tried to add some swapfile. I followed



https://bogdancornianu.com/change-swap-size-in-ubuntu/



and typed this in my terminal:



sudo dd if=/dev/zero of=swapfile bs=1G count=16


I get:



16+0 records in
16+0 records out
17179869184 bytes (17 GB, 16 GiB) copied, 206.949 s, 83.0 MB/s


then, I followed the instructions:



sudo mkswap /swapfile


But I get this error:



mkswap: cannot open /swapfile: No such file or directory


Then, I decided to resize my swap partition instead of swapfile. So I want to delete them. (I didn't create any before so I assume I can delete them all?)
I followed this:



https://askubuntu.com/questions/904628/default-17-04-swap-file-location



I tried:



$ cat /proc/swaps
$ grep swap /etc/fstab


But I get nothing from the first one. Output from the second one is:



 total used free shared buff/cache 
available
Mem: 11862 3498 1014 138 7349
7907
Swap: 0 0 0


I also tried (after reboot):



swapon -s


and get



Filename Type Size Used Priority
/dev/sdb3 partition 3905532 0 -2


I wonder that did I successfully create swapfiles? How do I delete them if I did?










share|improve this question



















  • 1





    Hello, our new contributor! Please read our guidelines, and maybe more important note: You should really really read properly what you are typing, there is no space for typos in Linux!

    – Vlastimil
    Mar 26 at 16:19













4












4








4








I want to increase my swap size to be able to have the hibernate option. First, I tried to add some swapfile. I followed



https://bogdancornianu.com/change-swap-size-in-ubuntu/



and typed this in my terminal:



sudo dd if=/dev/zero of=swapfile bs=1G count=16


I get:



16+0 records in
16+0 records out
17179869184 bytes (17 GB, 16 GiB) copied, 206.949 s, 83.0 MB/s


then, I followed the instructions:



sudo mkswap /swapfile


But I get this error:



mkswap: cannot open /swapfile: No such file or directory


Then, I decided to resize my swap partition instead of swapfile. So I want to delete them. (I didn't create any before so I assume I can delete them all?)
I followed this:



https://askubuntu.com/questions/904628/default-17-04-swap-file-location



I tried:



$ cat /proc/swaps
$ grep swap /etc/fstab


But I get nothing from the first one. Output from the second one is:



 total used free shared buff/cache 
available
Mem: 11862 3498 1014 138 7349
7907
Swap: 0 0 0


I also tried (after reboot):



swapon -s


and get



Filename Type Size Used Priority
/dev/sdb3 partition 3905532 0 -2


I wonder that did I successfully create swapfiles? How do I delete them if I did?










share|improve this question
















I want to increase my swap size to be able to have the hibernate option. First, I tried to add some swapfile. I followed



https://bogdancornianu.com/change-swap-size-in-ubuntu/



and typed this in my terminal:



sudo dd if=/dev/zero of=swapfile bs=1G count=16


I get:



16+0 records in
16+0 records out
17179869184 bytes (17 GB, 16 GiB) copied, 206.949 s, 83.0 MB/s


then, I followed the instructions:



sudo mkswap /swapfile


But I get this error:



mkswap: cannot open /swapfile: No such file or directory


Then, I decided to resize my swap partition instead of swapfile. So I want to delete them. (I didn't create any before so I assume I can delete them all?)
I followed this:



https://askubuntu.com/questions/904628/default-17-04-swap-file-location



I tried:



$ cat /proc/swaps
$ grep swap /etc/fstab


But I get nothing from the first one. Output from the second one is:



 total used free shared buff/cache 
available
Mem: 11862 3498 1014 138 7349
7907
Swap: 0 0 0


I also tried (after reboot):



swapon -s


and get



Filename Type Size Used Priority
/dev/sdb3 partition 3905532 0 -2


I wonder that did I successfully create swapfiles? How do I delete them if I did?







swap






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 16:08









DopeGhoti

46.9k56190




46.9k56190










asked Mar 26 at 15:57









Frank WangFrank Wang

233




233







  • 1





    Hello, our new contributor! Please read our guidelines, and maybe more important note: You should really really read properly what you are typing, there is no space for typos in Linux!

    – Vlastimil
    Mar 26 at 16:19












  • 1





    Hello, our new contributor! Please read our guidelines, and maybe more important note: You should really really read properly what you are typing, there is no space for typos in Linux!

    – Vlastimil
    Mar 26 at 16:19







1




1





Hello, our new contributor! Please read our guidelines, and maybe more important note: You should really really read properly what you are typing, there is no space for typos in Linux!

– Vlastimil
Mar 26 at 16:19





Hello, our new contributor! Please read our guidelines, and maybe more important note: You should really really read properly what you are typing, there is no space for typos in Linux!

– Vlastimil
Mar 26 at 16:19










3 Answers
3






active

oldest

votes


















9














The first issue is that your first command created a file, swapfile, in your current directory, and that your subsequent command(s) were explicitly referencing /swapfile, a file called swapfile in the root directory. If that was not your current working directory when you executed the first command, all of the subsequent commands would be referring to a file that is not there to operate upon.



If you got no output from cat /proc/swaps, that indicates that either your system does not have procfs running (unlikely), or that you currently have no active swap space configured.



The output you claim to get from grep swap /etc/fstab makes no sense whatsoever. That looks like the output of free -m (incidentally confirming that you have no active swap configured), not the partial contents of the filesystem table.



Your post-reboot swapon -s (which as the manual states gives the same information as cat /proc/swaps) indicates that at some point prior to your reboot, someone executed swapoff.






share|improve this answer

























  • Got it! I found the swapfile in ~/, since I didn't cd to any other directory. So can I just remove it with rm command? Thank you!

    – Frank Wang
    Mar 28 at 15:04






  • 1





    You can indeed, or you can mv it to where you intended it to be if you haven't already started over from the correct directory.

    – DopeGhoti
    Mar 28 at 15:34


















4














You made a typo:



of=swapfile


should be



of=/swapfile


the guide creates the swap file in the root directory, whereas the command that you entered would have created a swap file in your current directory.






share|improve this answer






























    1














    Delete the swapfile(s) by



    sudo swapoff -v /?/swapfile 


    where /? represents the directory where you inadvertently created an extra swapfile.



    sudo nano /etc/fstab 


    allows you to edit fstab where you can delete any reference to /?/swapfile



    sudo rm /?/swapfile


    deletes the spurious swapfile.






    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%2f508781%2flinux-swap-file-creation-and-management%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      9














      The first issue is that your first command created a file, swapfile, in your current directory, and that your subsequent command(s) were explicitly referencing /swapfile, a file called swapfile in the root directory. If that was not your current working directory when you executed the first command, all of the subsequent commands would be referring to a file that is not there to operate upon.



      If you got no output from cat /proc/swaps, that indicates that either your system does not have procfs running (unlikely), or that you currently have no active swap space configured.



      The output you claim to get from grep swap /etc/fstab makes no sense whatsoever. That looks like the output of free -m (incidentally confirming that you have no active swap configured), not the partial contents of the filesystem table.



      Your post-reboot swapon -s (which as the manual states gives the same information as cat /proc/swaps) indicates that at some point prior to your reboot, someone executed swapoff.






      share|improve this answer

























      • Got it! I found the swapfile in ~/, since I didn't cd to any other directory. So can I just remove it with rm command? Thank you!

        – Frank Wang
        Mar 28 at 15:04






      • 1





        You can indeed, or you can mv it to where you intended it to be if you haven't already started over from the correct directory.

        – DopeGhoti
        Mar 28 at 15:34















      9














      The first issue is that your first command created a file, swapfile, in your current directory, and that your subsequent command(s) were explicitly referencing /swapfile, a file called swapfile in the root directory. If that was not your current working directory when you executed the first command, all of the subsequent commands would be referring to a file that is not there to operate upon.



      If you got no output from cat /proc/swaps, that indicates that either your system does not have procfs running (unlikely), or that you currently have no active swap space configured.



      The output you claim to get from grep swap /etc/fstab makes no sense whatsoever. That looks like the output of free -m (incidentally confirming that you have no active swap configured), not the partial contents of the filesystem table.



      Your post-reboot swapon -s (which as the manual states gives the same information as cat /proc/swaps) indicates that at some point prior to your reboot, someone executed swapoff.






      share|improve this answer

























      • Got it! I found the swapfile in ~/, since I didn't cd to any other directory. So can I just remove it with rm command? Thank you!

        – Frank Wang
        Mar 28 at 15:04






      • 1





        You can indeed, or you can mv it to where you intended it to be if you haven't already started over from the correct directory.

        – DopeGhoti
        Mar 28 at 15:34













      9












      9








      9







      The first issue is that your first command created a file, swapfile, in your current directory, and that your subsequent command(s) were explicitly referencing /swapfile, a file called swapfile in the root directory. If that was not your current working directory when you executed the first command, all of the subsequent commands would be referring to a file that is not there to operate upon.



      If you got no output from cat /proc/swaps, that indicates that either your system does not have procfs running (unlikely), or that you currently have no active swap space configured.



      The output you claim to get from grep swap /etc/fstab makes no sense whatsoever. That looks like the output of free -m (incidentally confirming that you have no active swap configured), not the partial contents of the filesystem table.



      Your post-reboot swapon -s (which as the manual states gives the same information as cat /proc/swaps) indicates that at some point prior to your reboot, someone executed swapoff.






      share|improve this answer















      The first issue is that your first command created a file, swapfile, in your current directory, and that your subsequent command(s) were explicitly referencing /swapfile, a file called swapfile in the root directory. If that was not your current working directory when you executed the first command, all of the subsequent commands would be referring to a file that is not there to operate upon.



      If you got no output from cat /proc/swaps, that indicates that either your system does not have procfs running (unlikely), or that you currently have no active swap space configured.



      The output you claim to get from grep swap /etc/fstab makes no sense whatsoever. That looks like the output of free -m (incidentally confirming that you have no active swap configured), not the partial contents of the filesystem table.



      Your post-reboot swapon -s (which as the manual states gives the same information as cat /proc/swaps) indicates that at some point prior to your reboot, someone executed swapoff.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Mar 26 at 20:40

























      answered Mar 26 at 16:03









      DopeGhotiDopeGhoti

      46.9k56190




      46.9k56190












      • Got it! I found the swapfile in ~/, since I didn't cd to any other directory. So can I just remove it with rm command? Thank you!

        – Frank Wang
        Mar 28 at 15:04






      • 1





        You can indeed, or you can mv it to where you intended it to be if you haven't already started over from the correct directory.

        – DopeGhoti
        Mar 28 at 15:34

















      • Got it! I found the swapfile in ~/, since I didn't cd to any other directory. So can I just remove it with rm command? Thank you!

        – Frank Wang
        Mar 28 at 15:04






      • 1





        You can indeed, or you can mv it to where you intended it to be if you haven't already started over from the correct directory.

        – DopeGhoti
        Mar 28 at 15:34
















      Got it! I found the swapfile in ~/, since I didn't cd to any other directory. So can I just remove it with rm command? Thank you!

      – Frank Wang
      Mar 28 at 15:04





      Got it! I found the swapfile in ~/, since I didn't cd to any other directory. So can I just remove it with rm command? Thank you!

      – Frank Wang
      Mar 28 at 15:04




      1




      1





      You can indeed, or you can mv it to where you intended it to be if you haven't already started over from the correct directory.

      – DopeGhoti
      Mar 28 at 15:34





      You can indeed, or you can mv it to where you intended it to be if you haven't already started over from the correct directory.

      – DopeGhoti
      Mar 28 at 15:34













      4














      You made a typo:



      of=swapfile


      should be



      of=/swapfile


      the guide creates the swap file in the root directory, whereas the command that you entered would have created a swap file in your current directory.






      share|improve this answer



























        4














        You made a typo:



        of=swapfile


        should be



        of=/swapfile


        the guide creates the swap file in the root directory, whereas the command that you entered would have created a swap file in your current directory.






        share|improve this answer

























          4












          4








          4







          You made a typo:



          of=swapfile


          should be



          of=/swapfile


          the guide creates the swap file in the root directory, whereas the command that you entered would have created a swap file in your current directory.






          share|improve this answer













          You made a typo:



          of=swapfile


          should be



          of=/swapfile


          the guide creates the swap file in the root directory, whereas the command that you entered would have created a swap file in your current directory.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 16:02









          JShorthouseJShorthouse

          52328




          52328





















              1














              Delete the swapfile(s) by



              sudo swapoff -v /?/swapfile 


              where /? represents the directory where you inadvertently created an extra swapfile.



              sudo nano /etc/fstab 


              allows you to edit fstab where you can delete any reference to /?/swapfile



              sudo rm /?/swapfile


              deletes the spurious swapfile.






              share|improve this answer



























                1














                Delete the swapfile(s) by



                sudo swapoff -v /?/swapfile 


                where /? represents the directory where you inadvertently created an extra swapfile.



                sudo nano /etc/fstab 


                allows you to edit fstab where you can delete any reference to /?/swapfile



                sudo rm /?/swapfile


                deletes the spurious swapfile.






                share|improve this answer

























                  1












                  1








                  1







                  Delete the swapfile(s) by



                  sudo swapoff -v /?/swapfile 


                  where /? represents the directory where you inadvertently created an extra swapfile.



                  sudo nano /etc/fstab 


                  allows you to edit fstab where you can delete any reference to /?/swapfile



                  sudo rm /?/swapfile


                  deletes the spurious swapfile.






                  share|improve this answer













                  Delete the swapfile(s) by



                  sudo swapoff -v /?/swapfile 


                  where /? represents the directory where you inadvertently created an extra swapfile.



                  sudo nano /etc/fstab 


                  allows you to edit fstab where you can delete any reference to /?/swapfile



                  sudo rm /?/swapfile


                  deletes the spurious swapfile.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 26 at 18:43









                  K7AAYK7AAY

                  1,0221028




                  1,0221028



























                      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%2f508781%2flinux-swap-file-creation-and-management%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







                      -swap

                      Popular posts from this blog

                      Frič See also Navigation menuinternal link

                      Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant

                      fontconfig warning: “/etc/fonts/fonts.conf”, line 100: unknown “element blank” The 2019 Stack Overflow Developer Survey Results Are In“tar: unrecognized option --warning” during 'apt-get install'How to fix Fontconfig errorHow do I figure out which font file is chosen for a system generic font alias?Why are some apt-get-installed fonts being ignored by fc-list, xfontsel, etc?Reload settings in /etc/fonts/conf.dTaking 30 seconds longer to boot after upgrade from jessie to stretchHow to match multiple font names with a single <match> element?Adding a custom font to fontconfigRemoving fonts from fontconfig <match> resultsBroken fonts after upgrading Firefox ESR to latest Firefox