Shared qBittorrent data on a dual-boot PC
One of my computers has both Linux and Windows installed. I often switch between operating systems, but I want to use the same torrents. Normally I would use a server or NAS in such a scenario, but this time I didnāt have such a solution. This blogpost is meant for advanced computer users who want to accomplish the same.
Note that you have to change directory pathnames to suit your own configuration.
You can also download the scripts: qBittorrent_dualboot.zip
Set a shared filesystem
First, you need storage that is accessible by both Linux and Windows.
I choose a spare SSD, formatted with the exfat filesystem. In Windows,
itās mounted asĀ S:
, and in Linux,
asĀ /mnt/scratch
.
Default Save Path
Second, you need to set the right download āDefault Save Pathā in qBittorrent, both in Linux and in Windows.

Fastresume and Torrent file location
The torrent files and their state, fastresume files, are stored in theseĀ locations:
- Windows:Ā
%LOCALAPPDATA%\qBittorrent\BT_backup
- Linux:Ā
~/.local/share/data/qBittorrent/BT_backup
You also need to store the files inĀ BT_backup
Ā in the
same location, accessible by both Linux and Windows. Iāve symlinked
theĀ BT_backup
Ā folders to a new folder on my āscratchā
disk:
mkdir -p /mnt/scratch/qBittorrent/_activetorrents/BT_backup
cd ~/.local/share/data/qBittorrent
rmdir BT_backup
ln -s /mnt/scratch/qBittorrent/_activetorrents/BT_backup BT_backup
And then in Windows:
cd %LOCALAPPDATA%\qBittorrent
rmdir BT_backup
mklink /d BT_backup S:\qBittorrent\_activetorrents\BT_backup
Convert savepaths between Linux and Windows
The savepaths are stored in fastresume files. Alas, the savepaths are incompatible between Linux and Windows. The same base location for downloaded files is written differently:
- Windows:Ā
S:\qBittorrent\
- Linux:Ā
/mnt/scratch/qBittorrent/
Ā (using POSIX filenames)
The torrent and fastresume files are encoded asĀ bencodedĀ files. This
means you cannot just useĀ sed
because strings are precedes
with a number indicating their length.
To convert bencoded files to something you can edit from a
shellscript easily, you can useĀ bencode-pretty.
Download, runĀ make
, and copy the binaries
toĀ /usr/local/bin/
.
Iāve make a quick-and-dirty shellscript to convert the Windows savepaths to POSIX savepaths and back again. Note that if you use different paths, then you need to edit the script.
/usr/local/bin/qbittorrent_fastresume_savepaths_convert.sh
#!/bin/sh
# Converts qBittorrent shared storage between POSIX and Windows savepaths
# Evert Mouw, 2021-03
# change savepaths for .fastresume files used by qBittorrent
# handy when switching between Windows and Linux (posix paths)
# while using the same qBittorrent download folder and BT_backup folder
# dependency: https://github.com/tool-maker/bencode-pretty
# also see the systemd unit below
# argument 1: { windows || posix }
# These constants should be set in a configuration file or set
# as an argument, but currenty this is just for personal use.
BT_backup="/home/evert/qBittorrent/_activetorrents/BT_backup"
sed_toPos='s/S:\\qBittorrent\\/\/home\/evert\/qBittorrent\//g'
sed_toWin='s/\/home\/evert\/qBittorrent\//S:\\qBittorrent\\/g'
case $1 in
windows) SED_STRING="$sed_toWin" ;;
posix) SED_STRING="$sed_toPos" ;;
*)
echo "No valid first argument."
exit 1
;;
esac
cd "$BT_backup"
for FILE in *.fastresume
do
cat $FILE | bencode_pretty | sed "$SED_STRING" | bencode_unpretty > $1.tmp
cp $1.tmp $FILE
rm $1.tmp
done
Make it happen automatically
Now I donāt want to have to run this manually. I want this:
- On Linux bootup, change the savepaths to POSIX style.
- On Linux shutdown, change the savepahts to Windows style.
Then you can boot into Windows and the fastresume files are ready, or you can boot back in Linux and the savepaths will be converted to POSIX style.
Just use this systemd unit file:
[Unit]
Description=Converts qBittorrent shared storage between POSIX and Windows savepaths
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/local/bin/qbittorrent_fastresume_savepaths_convert.sh posix
ExecStop=/usr/local/bin/qbittorrent_fastresume_savepaths_convert.sh windows
[Install]
WantedBy=multi-user.target
Iāve saved it
as:Ā /etc/systemd/system/qbittorrent_fastresume_savepaths_convert.service
Enable and start using:
systemctl enable qbittorrent_fastresume_savepaths_convert
systemctl start qbittorrent_fastresume_savepaths_convert
systemctl status qbittorrent_fastresume_savepaths_convert
Youāre set!
If all goes well, you will see downloads resuming after booting into another operating system.
Note, however, that I didnāt include support to categorize torrents or use subfolders or download locations other than the default.
Happy leeching š
Deze blogpost werd in december 2022 overgezet van WordPress naar een methode gebaseerd op Markdown; het is mogelijk dat hierbij fouten of wijzigingen zijn ontstaan t.o.v. de originele blogpost.