fallocate: fallocate failed: Text file busy in Ubuntu 17.04?defragmenting and increasing performance of old lubuntu system with swap partitionthis /usr/bin/dpkg returned error || ubuntu-16.04, 64bitDefault 17.04 swap file locationUbuntu freezes from online formsMy Laptop is not starting after upgrade ubuntu 16.04 (Kernel 4.8.0-38 to 04.10.0-36)Ubuntu 17.04 - why is my swap file not being used?hcp: ERROR: FALLOCATE FAILED!Not sure my swap is being used

Is there a way to hide HTML source code yet keeping it effective?

What causes the traces to wrinkle like this and should I be worried

Is this a Sherman, and if so what model?

What is the need of methods like GET and POST in the HTTP protocol?

Why did UK NHS pay for homeopathic treatments?

Do the villains know Batman has no superpowers?

Where Does VDD+0.3V Input Limit Come From on IC chips?

Painting a 4x6 grid with 2 colours

Worms crawling under skin

How do pilots align the HUD with their eyeballs?

What's the story to "WotC gave up on fixing Polymorph"?

Social leper versus social leopard

Is it true that, "just ten trading days represent 63 per cent of the returns of the past 50 years"?

Resolving moral conflict

Is it a good idea to leave minor world details to the reader's imagination?

How do you use the interjection for snorting?

My Project Manager does not accept carry-over in Scrum, Is that normal?

Why is there not a feasible solution for a MIP?

Safely hang a mirror that does not have hooks

Magneto 2 How to call Helper function in observer file

Guitar tuning (EADGBE), "perfect" fourths?

Is it impolite to ask for an in-flight catalogue with no intention of buying?

Performance for simple code that converts a RGB tuple to hex string

How to make interviewee comfortable interviewing in lounge chairs



fallocate: fallocate failed: Text file busy in Ubuntu 17.04?


defragmenting and increasing performance of old lubuntu system with swap partitionthis /usr/bin/dpkg returned error || ubuntu-16.04, 64bitDefault 17.04 swap file locationUbuntu freezes from online formsMy Laptop is not starting after upgrade ubuntu 16.04 (Kernel 4.8.0-38 to 04.10.0-36)Ubuntu 17.04 - why is my swap file not being used?hcp: ERROR: FALLOCATE FAILED!Not sure my swap is being used






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








3















I installed Ubuntu a few weeks ago and I usually run more than 6 programs(sts,web browsers, and so on).



The system is getting stuck.



My RAM size is 6 GB and swap 2 GB. I decided to increase swap size to 15 GB. When I was trying to accomplish this work, I got the following error. I have linked to the tutorial that I was following.



sudo swapon --show
[sudo] password for decoders:
NAME TYPE SIZE USED PRIO
/swapfile file 2G 0B -1
decoders@10decoders:~$ free -h
total used free shared buff/cache available
Mem: 5.7G 1.1G 3.4G 217M 1.1G 4.1G
Swap: 2.0G 0B 2.0G
decoders@10decoders:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.9G 0 2.9G 0% /dev
tmpfs 583M 9.0M 574M 2% /run
/dev/sda1 293G 14G 265G 5% /
tmpfs 2.9G 4.7M 2.9G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.9G 0 2.9G 0% /sys/fs/cgroup
tmpfs 583M 144K 583M 1% /run/user/1000
decoders@10decoders:~$ sudo fallocate -l 15G /swapfile
fallocate: fallocate failed: Text file busy
decoders@10decoders:~$ ls -lh /swapfile
-rw------- 1 root root 2.0G May 19 11:43 /swapfile
decoders@10decoders:~$


I followed this tutorial link: http://www.tutorialspoint.com/articles/how-to-increase-swap-space-on-linux-ubuntu










share|improve this question





















  • 2





    You can't fallocate a swapfile that's currently in use. You'd have to at least do a swapoff -a first. Secondly, why do you think that increasing swap would solve your problem when your current swapon command shows no swap usage? Lastly, setting is to 15G is excessive. Figure on 6G... 12G max.

    – heynnema
    May 31 '17 at 15:41











  • now i do not have swap usage. When i run more than five programs, I see swap usage. what is swapoff -a?

    – Kumaresan Perumal
    Jun 1 '17 at 4:59






  • 4





    swapoff -a turns off swap usage. You were trying to allocate 15G to /swapfile, but you can't do that if it's in use. You do a swapoff -a, fallocate (you may have to delete the current /swapfile first), mkswap /swapfile, then swapon -a. If you're not sure what you're doing... then don't do it.

    – heynnema
    Jun 1 '17 at 12:50











  • @heynnema please tell me the procedure to accomplish the work.

    – Kumaresan Perumal
    Jun 1 '17 at 12:52











  • See digitalocean.com/community/tutorials/…. Don't do the vm.swappiness or cache pressure parts.

    – heynnema
    Jun 1 '17 at 13:35


















3















I installed Ubuntu a few weeks ago and I usually run more than 6 programs(sts,web browsers, and so on).



The system is getting stuck.



My RAM size is 6 GB and swap 2 GB. I decided to increase swap size to 15 GB. When I was trying to accomplish this work, I got the following error. I have linked to the tutorial that I was following.



sudo swapon --show
[sudo] password for decoders:
NAME TYPE SIZE USED PRIO
/swapfile file 2G 0B -1
decoders@10decoders:~$ free -h
total used free shared buff/cache available
Mem: 5.7G 1.1G 3.4G 217M 1.1G 4.1G
Swap: 2.0G 0B 2.0G
decoders@10decoders:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.9G 0 2.9G 0% /dev
tmpfs 583M 9.0M 574M 2% /run
/dev/sda1 293G 14G 265G 5% /
tmpfs 2.9G 4.7M 2.9G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.9G 0 2.9G 0% /sys/fs/cgroup
tmpfs 583M 144K 583M 1% /run/user/1000
decoders@10decoders:~$ sudo fallocate -l 15G /swapfile
fallocate: fallocate failed: Text file busy
decoders@10decoders:~$ ls -lh /swapfile
-rw------- 1 root root 2.0G May 19 11:43 /swapfile
decoders@10decoders:~$


I followed this tutorial link: http://www.tutorialspoint.com/articles/how-to-increase-swap-space-on-linux-ubuntu










share|improve this question





















  • 2





    You can't fallocate a swapfile that's currently in use. You'd have to at least do a swapoff -a first. Secondly, why do you think that increasing swap would solve your problem when your current swapon command shows no swap usage? Lastly, setting is to 15G is excessive. Figure on 6G... 12G max.

    – heynnema
    May 31 '17 at 15:41











  • now i do not have swap usage. When i run more than five programs, I see swap usage. what is swapoff -a?

    – Kumaresan Perumal
    Jun 1 '17 at 4:59






  • 4





    swapoff -a turns off swap usage. You were trying to allocate 15G to /swapfile, but you can't do that if it's in use. You do a swapoff -a, fallocate (you may have to delete the current /swapfile first), mkswap /swapfile, then swapon -a. If you're not sure what you're doing... then don't do it.

    – heynnema
    Jun 1 '17 at 12:50











  • @heynnema please tell me the procedure to accomplish the work.

    – Kumaresan Perumal
    Jun 1 '17 at 12:52











  • See digitalocean.com/community/tutorials/…. Don't do the vm.swappiness or cache pressure parts.

    – heynnema
    Jun 1 '17 at 13:35














3












3








3


3






I installed Ubuntu a few weeks ago and I usually run more than 6 programs(sts,web browsers, and so on).



The system is getting stuck.



My RAM size is 6 GB and swap 2 GB. I decided to increase swap size to 15 GB. When I was trying to accomplish this work, I got the following error. I have linked to the tutorial that I was following.



sudo swapon --show
[sudo] password for decoders:
NAME TYPE SIZE USED PRIO
/swapfile file 2G 0B -1
decoders@10decoders:~$ free -h
total used free shared buff/cache available
Mem: 5.7G 1.1G 3.4G 217M 1.1G 4.1G
Swap: 2.0G 0B 2.0G
decoders@10decoders:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.9G 0 2.9G 0% /dev
tmpfs 583M 9.0M 574M 2% /run
/dev/sda1 293G 14G 265G 5% /
tmpfs 2.9G 4.7M 2.9G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.9G 0 2.9G 0% /sys/fs/cgroup
tmpfs 583M 144K 583M 1% /run/user/1000
decoders@10decoders:~$ sudo fallocate -l 15G /swapfile
fallocate: fallocate failed: Text file busy
decoders@10decoders:~$ ls -lh /swapfile
-rw------- 1 root root 2.0G May 19 11:43 /swapfile
decoders@10decoders:~$


I followed this tutorial link: http://www.tutorialspoint.com/articles/how-to-increase-swap-space-on-linux-ubuntu










share|improve this question
















I installed Ubuntu a few weeks ago and I usually run more than 6 programs(sts,web browsers, and so on).



The system is getting stuck.



My RAM size is 6 GB and swap 2 GB. I decided to increase swap size to 15 GB. When I was trying to accomplish this work, I got the following error. I have linked to the tutorial that I was following.



sudo swapon --show
[sudo] password for decoders:
NAME TYPE SIZE USED PRIO
/swapfile file 2G 0B -1
decoders@10decoders:~$ free -h
total used free shared buff/cache available
Mem: 5.7G 1.1G 3.4G 217M 1.1G 4.1G
Swap: 2.0G 0B 2.0G
decoders@10decoders:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.9G 0 2.9G 0% /dev
tmpfs 583M 9.0M 574M 2% /run
/dev/sda1 293G 14G 265G 5% /
tmpfs 2.9G 4.7M 2.9G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.9G 0 2.9G 0% /sys/fs/cgroup
tmpfs 583M 144K 583M 1% /run/user/1000
decoders@10decoders:~$ sudo fallocate -l 15G /swapfile
fallocate: fallocate failed: Text file busy
decoders@10decoders:~$ ls -lh /swapfile
-rw------- 1 root root 2.0G May 19 11:43 /swapfile
decoders@10decoders:~$


I followed this tutorial link: http://www.tutorialspoint.com/articles/how-to-increase-swap-space-on-linux-ubuntu







16.04 swap 17.04






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 15 at 20:47









Kevin Bowen

15.9k15 gold badges62 silver badges73 bronze badges




15.9k15 gold badges62 silver badges73 bronze badges










asked May 31 '17 at 4:55









Kumaresan PerumalKumaresan Perumal

1261 gold badge1 silver badge10 bronze badges




1261 gold badge1 silver badge10 bronze badges










  • 2





    You can't fallocate a swapfile that's currently in use. You'd have to at least do a swapoff -a first. Secondly, why do you think that increasing swap would solve your problem when your current swapon command shows no swap usage? Lastly, setting is to 15G is excessive. Figure on 6G... 12G max.

    – heynnema
    May 31 '17 at 15:41











  • now i do not have swap usage. When i run more than five programs, I see swap usage. what is swapoff -a?

    – Kumaresan Perumal
    Jun 1 '17 at 4:59






  • 4





    swapoff -a turns off swap usage. You were trying to allocate 15G to /swapfile, but you can't do that if it's in use. You do a swapoff -a, fallocate (you may have to delete the current /swapfile first), mkswap /swapfile, then swapon -a. If you're not sure what you're doing... then don't do it.

    – heynnema
    Jun 1 '17 at 12:50











  • @heynnema please tell me the procedure to accomplish the work.

    – Kumaresan Perumal
    Jun 1 '17 at 12:52











  • See digitalocean.com/community/tutorials/…. Don't do the vm.swappiness or cache pressure parts.

    – heynnema
    Jun 1 '17 at 13:35













  • 2





    You can't fallocate a swapfile that's currently in use. You'd have to at least do a swapoff -a first. Secondly, why do you think that increasing swap would solve your problem when your current swapon command shows no swap usage? Lastly, setting is to 15G is excessive. Figure on 6G... 12G max.

    – heynnema
    May 31 '17 at 15:41











  • now i do not have swap usage. When i run more than five programs, I see swap usage. what is swapoff -a?

    – Kumaresan Perumal
    Jun 1 '17 at 4:59






  • 4





    swapoff -a turns off swap usage. You were trying to allocate 15G to /swapfile, but you can't do that if it's in use. You do a swapoff -a, fallocate (you may have to delete the current /swapfile first), mkswap /swapfile, then swapon -a. If you're not sure what you're doing... then don't do it.

    – heynnema
    Jun 1 '17 at 12:50











  • @heynnema please tell me the procedure to accomplish the work.

    – Kumaresan Perumal
    Jun 1 '17 at 12:52











  • See digitalocean.com/community/tutorials/…. Don't do the vm.swappiness or cache pressure parts.

    – heynnema
    Jun 1 '17 at 13:35








2




2





You can't fallocate a swapfile that's currently in use. You'd have to at least do a swapoff -a first. Secondly, why do you think that increasing swap would solve your problem when your current swapon command shows no swap usage? Lastly, setting is to 15G is excessive. Figure on 6G... 12G max.

– heynnema
May 31 '17 at 15:41





You can't fallocate a swapfile that's currently in use. You'd have to at least do a swapoff -a first. Secondly, why do you think that increasing swap would solve your problem when your current swapon command shows no swap usage? Lastly, setting is to 15G is excessive. Figure on 6G... 12G max.

– heynnema
May 31 '17 at 15:41













now i do not have swap usage. When i run more than five programs, I see swap usage. what is swapoff -a?

– Kumaresan Perumal
Jun 1 '17 at 4:59





now i do not have swap usage. When i run more than five programs, I see swap usage. what is swapoff -a?

– Kumaresan Perumal
Jun 1 '17 at 4:59




4




4





swapoff -a turns off swap usage. You were trying to allocate 15G to /swapfile, but you can't do that if it's in use. You do a swapoff -a, fallocate (you may have to delete the current /swapfile first), mkswap /swapfile, then swapon -a. If you're not sure what you're doing... then don't do it.

– heynnema
Jun 1 '17 at 12:50





swapoff -a turns off swap usage. You were trying to allocate 15G to /swapfile, but you can't do that if it's in use. You do a swapoff -a, fallocate (you may have to delete the current /swapfile first), mkswap /swapfile, then swapon -a. If you're not sure what you're doing... then don't do it.

– heynnema
Jun 1 '17 at 12:50













@heynnema please tell me the procedure to accomplish the work.

– Kumaresan Perumal
Jun 1 '17 at 12:52





@heynnema please tell me the procedure to accomplish the work.

– Kumaresan Perumal
Jun 1 '17 at 12:52













See digitalocean.com/community/tutorials/…. Don't do the vm.swappiness or cache pressure parts.

– heynnema
Jun 1 '17 at 13:35






See digitalocean.com/community/tutorials/…. Don't do the vm.swappiness or cache pressure parts.

– heynnema
Jun 1 '17 at 13:35











2 Answers
2






active

oldest

votes


















1
















Creating a SWAP partition in Ubuntu, Linux Mint and derivatives




METHOD 1: Command-line Way from Terminal (Fastest way!)



STEP 1: First step is to check if by chance is there any SWAP partition already created in your PC:



sudo swapon --show


Enter your root password. If you see no output, it means that the SWAP doesn’t exist.



STEP 2: Next, let’s see the current partition structure of your computer’s hard disk:



df -h


STEP 3: As heynnema commented, before you start the changes disable the use of swap:



sudo swapoff -a



STEP 4: Now it's time to create the SWAP file. Make sure you have enough space on the hard disk. It is a matter of preference in how much SWAP size you need.



My suggestion is: If you have a maximum of 4GB of RAM I would suggest putting twice the RAM for the SWAP (8GB for SWAP). For PCs with more than 4GB I recommend the same number of RAM for SWAP plus 2GB. Example: In my case it's 8GB, I put 8GB + 2GB, totaling 10GB for SWAP. But you may feel free to make your choice.



sudo dd if=/dev/zero of=/swapfile bs=5M count=5120 status=progress


STEP 5: SWAP file is now created. Let’s give root-only permissions to it.



sudo chmod 600 /swapfile


STEP 6: Mark the file as SWAP space:



sudo mkswap /swapfile


STEP 7: Finally enable the SWAP.



sudo swapon /swapfile


STEP 8: You can now check using the same swapon command to check if SWAP is created.



sudo swapon --show


STEP 9: Also check the final partition structure again.



free -h


STEP 10: Once everything is set, you must set the SWAP file as permanent, else you will lose the SWAP after reboot. Run this command:



echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab


Finished, now exit the terminal!



You can check SWAP status on System Monitor utility.




METHOD 2: GUI Way using GParted



If you want to go directly through the graphical interface, enter the reference link below that is well explained.




Reference:



  • https://www.fosslinux.com/1064/how-to-create-or-add-a-swap-partition-in-ubuntu-and-linux-mint.htm





share|improve this answer


































    0
















    swapoff -a
    sudo fallocate -l 15G /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    swapon -a





    share|improve this answer




















    • 2





      It is good practice to explain what the provided commands actually do

      – dsSTORM
      Apr 20 at 16:08






    • 1





      Please note as mentioned in man mkswap that the use of fallocate on filesystems that support prealocated files, such as ext4, is not recommended.

      – Charles Green
      Apr 20 at 16:08













    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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/4.0/"u003ecc by-sa 4.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%2faskubuntu.com%2fquestions%2f920595%2ffallocate-fallocate-failed-text-file-busy-in-ubuntu-17-04%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
















    Creating a SWAP partition in Ubuntu, Linux Mint and derivatives




    METHOD 1: Command-line Way from Terminal (Fastest way!)



    STEP 1: First step is to check if by chance is there any SWAP partition already created in your PC:



    sudo swapon --show


    Enter your root password. If you see no output, it means that the SWAP doesn’t exist.



    STEP 2: Next, let’s see the current partition structure of your computer’s hard disk:



    df -h


    STEP 3: As heynnema commented, before you start the changes disable the use of swap:



    sudo swapoff -a



    STEP 4: Now it's time to create the SWAP file. Make sure you have enough space on the hard disk. It is a matter of preference in how much SWAP size you need.



    My suggestion is: If you have a maximum of 4GB of RAM I would suggest putting twice the RAM for the SWAP (8GB for SWAP). For PCs with more than 4GB I recommend the same number of RAM for SWAP plus 2GB. Example: In my case it's 8GB, I put 8GB + 2GB, totaling 10GB for SWAP. But you may feel free to make your choice.



    sudo dd if=/dev/zero of=/swapfile bs=5M count=5120 status=progress


    STEP 5: SWAP file is now created. Let’s give root-only permissions to it.



    sudo chmod 600 /swapfile


    STEP 6: Mark the file as SWAP space:



    sudo mkswap /swapfile


    STEP 7: Finally enable the SWAP.



    sudo swapon /swapfile


    STEP 8: You can now check using the same swapon command to check if SWAP is created.



    sudo swapon --show


    STEP 9: Also check the final partition structure again.



    free -h


    STEP 10: Once everything is set, you must set the SWAP file as permanent, else you will lose the SWAP after reboot. Run this command:



    echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab


    Finished, now exit the terminal!



    You can check SWAP status on System Monitor utility.




    METHOD 2: GUI Way using GParted



    If you want to go directly through the graphical interface, enter the reference link below that is well explained.




    Reference:



    • https://www.fosslinux.com/1064/how-to-create-or-add-a-swap-partition-in-ubuntu-and-linux-mint.htm





    share|improve this answer































      1
















      Creating a SWAP partition in Ubuntu, Linux Mint and derivatives




      METHOD 1: Command-line Way from Terminal (Fastest way!)



      STEP 1: First step is to check if by chance is there any SWAP partition already created in your PC:



      sudo swapon --show


      Enter your root password. If you see no output, it means that the SWAP doesn’t exist.



      STEP 2: Next, let’s see the current partition structure of your computer’s hard disk:



      df -h


      STEP 3: As heynnema commented, before you start the changes disable the use of swap:



      sudo swapoff -a



      STEP 4: Now it's time to create the SWAP file. Make sure you have enough space on the hard disk. It is a matter of preference in how much SWAP size you need.



      My suggestion is: If you have a maximum of 4GB of RAM I would suggest putting twice the RAM for the SWAP (8GB for SWAP). For PCs with more than 4GB I recommend the same number of RAM for SWAP plus 2GB. Example: In my case it's 8GB, I put 8GB + 2GB, totaling 10GB for SWAP. But you may feel free to make your choice.



      sudo dd if=/dev/zero of=/swapfile bs=5M count=5120 status=progress


      STEP 5: SWAP file is now created. Let’s give root-only permissions to it.



      sudo chmod 600 /swapfile


      STEP 6: Mark the file as SWAP space:



      sudo mkswap /swapfile


      STEP 7: Finally enable the SWAP.



      sudo swapon /swapfile


      STEP 8: You can now check using the same swapon command to check if SWAP is created.



      sudo swapon --show


      STEP 9: Also check the final partition structure again.



      free -h


      STEP 10: Once everything is set, you must set the SWAP file as permanent, else you will lose the SWAP after reboot. Run this command:



      echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab


      Finished, now exit the terminal!



      You can check SWAP status on System Monitor utility.




      METHOD 2: GUI Way using GParted



      If you want to go directly through the graphical interface, enter the reference link below that is well explained.




      Reference:



      • https://www.fosslinux.com/1064/how-to-create-or-add-a-swap-partition-in-ubuntu-and-linux-mint.htm





      share|improve this answer





























        1














        1










        1









        Creating a SWAP partition in Ubuntu, Linux Mint and derivatives




        METHOD 1: Command-line Way from Terminal (Fastest way!)



        STEP 1: First step is to check if by chance is there any SWAP partition already created in your PC:



        sudo swapon --show


        Enter your root password. If you see no output, it means that the SWAP doesn’t exist.



        STEP 2: Next, let’s see the current partition structure of your computer’s hard disk:



        df -h


        STEP 3: As heynnema commented, before you start the changes disable the use of swap:



        sudo swapoff -a



        STEP 4: Now it's time to create the SWAP file. Make sure you have enough space on the hard disk. It is a matter of preference in how much SWAP size you need.



        My suggestion is: If you have a maximum of 4GB of RAM I would suggest putting twice the RAM for the SWAP (8GB for SWAP). For PCs with more than 4GB I recommend the same number of RAM for SWAP plus 2GB. Example: In my case it's 8GB, I put 8GB + 2GB, totaling 10GB for SWAP. But you may feel free to make your choice.



        sudo dd if=/dev/zero of=/swapfile bs=5M count=5120 status=progress


        STEP 5: SWAP file is now created. Let’s give root-only permissions to it.



        sudo chmod 600 /swapfile


        STEP 6: Mark the file as SWAP space:



        sudo mkswap /swapfile


        STEP 7: Finally enable the SWAP.



        sudo swapon /swapfile


        STEP 8: You can now check using the same swapon command to check if SWAP is created.



        sudo swapon --show


        STEP 9: Also check the final partition structure again.



        free -h


        STEP 10: Once everything is set, you must set the SWAP file as permanent, else you will lose the SWAP after reboot. Run this command:



        echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab


        Finished, now exit the terminal!



        You can check SWAP status on System Monitor utility.




        METHOD 2: GUI Way using GParted



        If you want to go directly through the graphical interface, enter the reference link below that is well explained.




        Reference:



        • https://www.fosslinux.com/1064/how-to-create-or-add-a-swap-partition-in-ubuntu-and-linux-mint.htm





        share|improve this answer















        Creating a SWAP partition in Ubuntu, Linux Mint and derivatives




        METHOD 1: Command-line Way from Terminal (Fastest way!)



        STEP 1: First step is to check if by chance is there any SWAP partition already created in your PC:



        sudo swapon --show


        Enter your root password. If you see no output, it means that the SWAP doesn’t exist.



        STEP 2: Next, let’s see the current partition structure of your computer’s hard disk:



        df -h


        STEP 3: As heynnema commented, before you start the changes disable the use of swap:



        sudo swapoff -a



        STEP 4: Now it's time to create the SWAP file. Make sure you have enough space on the hard disk. It is a matter of preference in how much SWAP size you need.



        My suggestion is: If you have a maximum of 4GB of RAM I would suggest putting twice the RAM for the SWAP (8GB for SWAP). For PCs with more than 4GB I recommend the same number of RAM for SWAP plus 2GB. Example: In my case it's 8GB, I put 8GB + 2GB, totaling 10GB for SWAP. But you may feel free to make your choice.



        sudo dd if=/dev/zero of=/swapfile bs=5M count=5120 status=progress


        STEP 5: SWAP file is now created. Let’s give root-only permissions to it.



        sudo chmod 600 /swapfile


        STEP 6: Mark the file as SWAP space:



        sudo mkswap /swapfile


        STEP 7: Finally enable the SWAP.



        sudo swapon /swapfile


        STEP 8: You can now check using the same swapon command to check if SWAP is created.



        sudo swapon --show


        STEP 9: Also check the final partition structure again.



        free -h


        STEP 10: Once everything is set, you must set the SWAP file as permanent, else you will lose the SWAP after reboot. Run this command:



        echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab


        Finished, now exit the terminal!



        You can check SWAP status on System Monitor utility.




        METHOD 2: GUI Way using GParted



        If you want to go directly through the graphical interface, enter the reference link below that is well explained.




        Reference:



        • https://www.fosslinux.com/1064/how-to-create-or-add-a-swap-partition-in-ubuntu-and-linux-mint.htm






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 20 at 16:12









        Charles Green

        15.5k7 gold badges42 silver badges63 bronze badges




        15.5k7 gold badges42 silver badges63 bronze badges










        answered Mar 13 at 19:31









        ℛɑƒæĿℛɑƒæĿ

        1315 bronze badges




        1315 bronze badges


























            0
















            swapoff -a
            sudo fallocate -l 15G /swapfile
            sudo mkswap /swapfile
            sudo swapon /swapfile
            swapon -a





            share|improve this answer




















            • 2





              It is good practice to explain what the provided commands actually do

              – dsSTORM
              Apr 20 at 16:08






            • 1





              Please note as mentioned in man mkswap that the use of fallocate on filesystems that support prealocated files, such as ext4, is not recommended.

              – Charles Green
              Apr 20 at 16:08















            0
















            swapoff -a
            sudo fallocate -l 15G /swapfile
            sudo mkswap /swapfile
            sudo swapon /swapfile
            swapon -a





            share|improve this answer




















            • 2





              It is good practice to explain what the provided commands actually do

              – dsSTORM
              Apr 20 at 16:08






            • 1





              Please note as mentioned in man mkswap that the use of fallocate on filesystems that support prealocated files, such as ext4, is not recommended.

              – Charles Green
              Apr 20 at 16:08













            0














            0










            0









            swapoff -a
            sudo fallocate -l 15G /swapfile
            sudo mkswap /swapfile
            sudo swapon /swapfile
            swapon -a





            share|improve this answer













            swapoff -a
            sudo fallocate -l 15G /swapfile
            sudo mkswap /swapfile
            sudo swapon /swapfile
            swapon -a






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 20 at 15:56









            samir belhadjersamir belhadjer

            1




            1










            • 2





              It is good practice to explain what the provided commands actually do

              – dsSTORM
              Apr 20 at 16:08






            • 1





              Please note as mentioned in man mkswap that the use of fallocate on filesystems that support prealocated files, such as ext4, is not recommended.

              – Charles Green
              Apr 20 at 16:08












            • 2





              It is good practice to explain what the provided commands actually do

              – dsSTORM
              Apr 20 at 16:08






            • 1





              Please note as mentioned in man mkswap that the use of fallocate on filesystems that support prealocated files, such as ext4, is not recommended.

              – Charles Green
              Apr 20 at 16:08







            2




            2





            It is good practice to explain what the provided commands actually do

            – dsSTORM
            Apr 20 at 16:08





            It is good practice to explain what the provided commands actually do

            – dsSTORM
            Apr 20 at 16:08




            1




            1





            Please note as mentioned in man mkswap that the use of fallocate on filesystems that support prealocated files, such as ext4, is not recommended.

            – Charles Green
            Apr 20 at 16:08





            Please note as mentioned in man mkswap that the use of fallocate on filesystems that support prealocated files, such as ext4, is not recommended.

            – Charles Green
            Apr 20 at 16:08


















            draft saved

            draft discarded















































            Thanks for contributing an answer to Ask Ubuntu!


            • 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%2faskubuntu.com%2fquestions%2f920595%2ffallocate-fallocate-failed-text-file-busy-in-ubuntu-17-04%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

            Distance measures on a map of a game The 2019 Stack Overflow Developer Survey Results Are Inmin distance in a graphShortest distance path on contour plotHow to plot a tilted map?Finding points outside of a diskDelaunay link distanceAnnulus from GeoDisks: drawing a ring on a mapNegative Correlation DistanceFind distance along a path (GPS coordinates)Finding position at given distance in a GeoPathMathematics behind distance estimation using camera

            How to get a smooth, uniform ParametricPlot of a 2D Region?How to plot a complicated Region?How to exclude a region from ParametricPlotHow discretize a region placing vertices on a specific non-uniform gridHow to transform a Plot or a ParametricPlot into a RegionHow can I get a smooth plot of a bounded region?Smooth ParametricPlot3D with RegionFunction?Smooth border of a region ParametricPlotSmooth region boundarySmooth region plot from list of pointsGet minimum y of a certain x in a region

            Genealogie vun de Merowenger Vum Merowech bis zum Chilperich I. | Navigatiounsmenü