The Ubuntu terminal may throw out an error – Failed to fork on Windows v. This terminal gets installed under the feature of Windows Subsystem for Linux. The cause of this error comes down to be lack of memory and can occur when a user is trying to get the latest updates for the terminal. The error reads:
# apt-get update
FATAL -> Failed to fork.
What is a fork error in Ubuntu?
Fork is a method in Linux or Ubuntu to create a new process. When there is an error or exception when the fork method is called, it results in Fork Error. There can be many reasons, including lack of memory (cannot allocate memory), limit on the number of running processes (too many processes), etc.; the user or program receives this error.
Fatal, Failed to Fork error with Ubuntu on Windows 11/10
If you receive Failed to Fork error with Ubuntu on Windows 11/10, we suggest you try our following suggestions:
- Create a new Swap file.
- Disable the Antivirus.
You may need admin account to execute these suggestions.
1] Create a new Swap file
Open the Terminal for the Windows Subsystem for Linux distro and enter the following command to create a new swap file and allocate 4 Gigabytes to it:
sudo fallocate -1 4G /swapfile
Make the file more secure by entering this command:
sudo chmod 600 /swapfile
Set the swap space with this command:
sudo mkswap /swapfile
Next, enable the swap space with this command:
sudo swapon /swapfile
Reboot your computer after closing the distro and check. Your error should be fixed.
2] Disable the Antivirus
Your antivirus might be affecting the proper functioning of the activities in the WSL Terminal. We recommend you to temporarily turn the Antivirus solution or Windows Defender off and check if that fixes the error.
Turn it on after the operation completes successfully.
We hope you found the steps easy to follow and that you were successful in resolving the issue.
Related: Windows Subsystem for Linux has no installed distributions.
What is a Swap file in Ubuntu?
Like Windows, Ubuntu allocates a portion of storage to store temporary information when the physical memory is full. It comes in handy to ensure processes can run smoothly, and Ubuntu doesn’t fault memory not available issues. Ubuntu also allows users to configure the total size of the Swap file, and it performs better when you have storage with high read-write speed.