Optimizing Baidu Netdisk on Linux: Three Key Solutions

Addressing high CPU usage, stalled download progress, and frequent crashes of Baidu Netdisk on Linux.

Resolving High CPU Usage of Baidu Netdisk on Linux

As summer arrives, the CPU temperature displayed by conky during Baidu Netdisk downloads skyrockets to 99 degrees Celsius, with the fan roaring, yet the CPU usage shows only 4%. Even after optimizing the water pump speed, the issue remains unresolved. Eventually, I found online that although it occupies fewer cores, it can still drain them dry… It is well-known that on Windows, high CPU usage by Baidu Netdisk can be limited through the Task Manager’s CPU quota. So how can we handle high CPU usage of Baidu Netdisk on Linux?After comparing usability, I ultimately chose the command-line tool cpulimit for this purpose, using Manjaro Linux as an example:Execute<span>yay -S cpulimit</span>to install the cpulimit tool,and check the help information:

 cpulimit -h                                                                                                            ✔ 
Usage: cpulimit [OPTIONS...] TARGET
   OPTIONS
-l, --limit=N          percentage of cpu allowed from 0 to 2400 (required)
-v, --verbose          show control statistics
-z, --lazy             exit if there is no target process, or if it dies
-i, --include-children limit also the children processes
-h, --help             display this help and exit
   TARGET must be exactly one of these:
-p, --pid=N            pid of the process (implies -z)
-e, --exe=FILE         name of the executable program file or path name
      COMMAND [ARGS]         run this command and limit it (implies -z)

Report bugs to<[email protected]>.

Execute in the terminal<span>cpulimit -e baidunetdisk -l 100</span>to impose limits; the higher the number, the more CPU usage is allowed. If the number is too low, it will reduce download speed, so you can adjust it flexibly based on your device and bandwidth conditions.This command will continuously monitor in the background, and if Baidu Netdisk exits, it will still monitor, dynamically controlling approximately once per second.

Resolving Stalled Download Progress of Baidu Netdisk on Linux

Even with a network connection, the progress bar remains stagnant, while the Baidu Netdisk interface shows the download speed is maxed out, but the actual system monitoring interface shows a traffic rate of zero. After various attempts, I finally discovered a method to resolve this:Step 1: Exit Baidu NetdiskStep 2: <span>rm -rf ~/.config/baidunetdisk/BaiduYunKernel</span>Step 3: Restart Baidu NetdiskThen the download speed returns to normal. As for the principle, it’s purely mystical.

Resolving Crashes of Baidu Netdisk on Linux After a Period of Downloading

When there are many download tasks, the cache data directory and other information of Baidu Netdisk on Linux may crash due to various formatting issues. To ensure it continues downloading, I devised a solution—writing a daemon script to continuously monitor it, and if it exits, restart it. The code is as follows:

#!/bin/sh

while true
 do
         process=`ps aux | grep "baidunetdisk --no-sandbox" | grep -v grep`;

if [ "$process" == "" ]; then
sleep 1;
echo $(date) " process does not exist, starting execution";
                /usr/lib/baidunetdisk/baidunetdisk --no-sandbox %U 2>> stderr.log 1>> /dev/null;
else
sleep 10;
echo $(date) " process exists";
fi
done

pgrep can also achieve a similar effect, but it may not be included by default in the system, so interested readers can download it as needed. Save the script as xx.sh,<span>chmod +x xx.sh</span>to grant execution permissions. Then<span>./xx.sh</span>is all you need to do.

Reflections

The original intention of using Linux was to avoid CPU usage issues on Windows, but it has turned out to be quite troublesome. It might be better to just run it in a Windows virtual machine and limit resources directly from the Task Manager while allocating minimal resources to the virtual machine externally.

Leave a Comment