fallocate: fallocate failed: Text file busy in Ubuntu 17.04? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)defragmenting and increasing performance of old lubuntu system with swap partitionIssue with increasing the root partition from the swapthis /usr/bin/dpkg returned error || ubuntu-16.04, 64bitDefault 17.04 swap file locationHow to Resize Ubuntu 17.04 Zesty Swap file size?Ubuntu freezes from online formsMy Laptop is not starting after upgrade ubuntu 16.04 (Kernel 4.8.0-38 to 04.10.0-36)hcp: ERROR: FALLOCATE FAILED!Not sure my swap is being usedWine 3.0 asking for more virtual free swap
Why does Python start at index 1 when iterating an array backwards?
Letter Boxed validator
What's the purpose of writing one's academic bio in 3rd person?
What is the longest distance a 13th-level monk can jump while attacking on the same turn?
What are 'alternative tunings' of a guitar and why would you use them? Doesn't it make it more difficult to play?
Can Pao de Queijo, and similar foods, be kosher for Passover?
When -s is used with third person singular. What's its use in this context?
Right-skewed distribution with mean equals to mode?
Should gear shift center itself while in neutral?
Are my PIs rude or am I just being too sensitive?
When is phishing education going too far?
If 'B is more likely given A', then 'A is more likely given B'
List *all* the tuples!
Is high blood pressure ever a symptom attributable solely to dehydration?
Is there a service that would inform me whenever a new direct route is scheduled from a given airport?
How to find all the available tools in macOS terminal?
Java 8 stream max() function argument type Comparator vs Comparable
Is 1 ppb equal to 1 μg/kg?
How to draw this diagram using TikZ package?
The logistics of corpse disposal
Check which numbers satisfy the condition [A*B*C = A! + B! + C!]
Sorting numerically
What is the musical term for a note that continously plays through a melody?
Can inflation occur in a positive-sum game currency system such as the Stack Exchange reputation system?
fallocate: fallocate failed: Text file busy in Ubuntu 17.04?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)defragmenting and increasing performance of old lubuntu system with swap partitionIssue with increasing the root partition from the swapthis /usr/bin/dpkg returned error || ubuntu-16.04, 64bitDefault 17.04 swap file locationHow to Resize Ubuntu 17.04 Zesty Swap file size?Ubuntu freezes from online formsMy Laptop is not starting after upgrade ubuntu 16.04 (Kernel 4.8.0-38 to 04.10.0-36)hcp: ERROR: FALLOCATE FAILED!Not sure my swap is being usedWine 3.0 asking for more virtual free swap
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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
|
show 3 more comments
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
2
You can't fallocate a swapfile that's currently in use. You'd have to at least do aswapoff -afirst. 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 -aturns off swap usage. You were trying to allocate 15G to /swapfile, but you can't do that if it's in use. You do aswapoff -a,fallocate(you may have to delete the current /swapfile first),mkswap /swapfile, thenswapon -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
|
show 3 more comments
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
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
16.04 swap 17.04
edited 4 hours ago
Kevin Bowen
14.9k155971
14.9k155971
asked May 31 '17 at 4:55
Kumaresan PerumalKumaresan Perumal
1261110
1261110
2
You can't fallocate a swapfile that's currently in use. You'd have to at least do aswapoff -afirst. 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 -aturns off swap usage. You were trying to allocate 15G to /swapfile, but you can't do that if it's in use. You do aswapoff -a,fallocate(you may have to delete the current /swapfile first),mkswap /swapfile, thenswapon -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
|
show 3 more comments
2
You can't fallocate a swapfile that's currently in use. You'd have to at least do aswapoff -afirst. 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 -aturns off swap usage. You were trying to allocate 15G to /swapfile, but you can't do that if it's in use. You do aswapoff -a,fallocate(you may have to delete the current /swapfile first),mkswap /swapfile, thenswapon -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
|
show 3 more comments
2 Answers
2
active
oldest
votes
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 fallocate -l 10G /swapfile
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
add a comment |
I had a bit of an issue following the steps above and encountered the error:
swapon: /swapfile: read swap header failed
I interchanged steps 5 and 6 on your instruction and it seems to have fixed the issue.
New contributor
LBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
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/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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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 fallocate -l 10G /swapfile
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
add a comment |
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 fallocate -l 10G /swapfile
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
add a comment |
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 fallocate -l 10G /swapfile
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
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 fallocate -l 10G /swapfile
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
edited Mar 13 at 19:40
answered Mar 13 at 19:31
ℛɑƒæĿℛɑƒæĿ
1315
1315
add a comment |
add a comment |
I had a bit of an issue following the steps above and encountered the error:
swapon: /swapfile: read swap header failed
I interchanged steps 5 and 6 on your instruction and it seems to have fixed the issue.
New contributor
LBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I had a bit of an issue following the steps above and encountered the error:
swapon: /swapfile: read swap header failed
I interchanged steps 5 and 6 on your instruction and it seems to have fixed the issue.
New contributor
LBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I had a bit of an issue following the steps above and encountered the error:
swapon: /swapfile: read swap header failed
I interchanged steps 5 and 6 on your instruction and it seems to have fixed the issue.
New contributor
LBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I had a bit of an issue following the steps above and encountered the error:
swapon: /swapfile: read swap header failed
I interchanged steps 5 and 6 on your instruction and it seems to have fixed the issue.
New contributor
LBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
LBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 4 hours ago
LBRLBR
1
1
New contributor
LBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
LBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
LBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
2
You can't fallocate a swapfile that's currently in use. You'd have to at least do a
swapoff -afirst. 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 -aturns off swap usage. You were trying to allocate 15G to /swapfile, but you can't do that if it's in use. You do aswapoff -a,fallocate(you may have to delete the current /swapfile first),mkswap /swapfile, thenswapon -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