How to Use Zsync to Transfer Part of a File in Linux

Download Files With Zsync Linux

Downloading large files like ISO images can be a giant pain. Depending on your Internet connection, sometimes they can take forever to download, and they eat up tons of hard drive space. Then, if you ever need an updated version, you need to go through the entire process again.

There is a solution, though. Zsync is a file synchronization tool for Linux that allows you to update just the parts of your files that have been changed without downloading everything again.

Zsync is based on rsync, another popular Linux tool for synchronizing files and directories, and it’s super easy to use. Most Linux distributions already have zsync in their package repositories, so it’s also easy to install and get started.

Also read: How to Set Up an SFTP Server on Linux

Install Zsync

Before you begin, you’re going to need to install zsync. It’s a small command line utility, so there aren’t many dependencies, and there isn’t much to it.

Ubuntu/Debian

Both Debian and Ubuntu package zsync, and they both have reasonably new versions of it. Go ahead and install it with Apt.

sudo apt install zsync

Fedora

Fedora doesn’t have a zsync package. Once again, Fedora’s limited repositories are somewhat of a hindrance. But you can still install and use zsync from its source.

First, make sure that you have the development tools needed from Fedora.

sudo dnf group install 'Development Tools'

Grab the current source tarball from the zsync download page. Unpack it into the directory where you’d like to build zsync. Then, open a terminal and change into that directory.

cd ~/Downloads/zsync-0.6.2

From there, configure, compile, and install zsync.

./configure
make -j4
sudo make install

Arch Linux

Arch includes zsync in its default repositories. Install with Pacman.

sudo pacman -S zsync

OpenSUSE

You can find the latest version of zsync for every version of OpenSUSE. Install it with your preferred package utility.

sudo zypper in zsync

Solus

Solus also has zsync in its default repositories. Go ahead and install it.

sudo eopkg it zsync

Also read: How to Master the rsync Command in Linux

Downloading a File

Zsync is a straightforward command-line utility. Pass the URL of the zsync file to it that you want to download, and it’ll get right to work. It does have a few flags that you can use to get specific, though. Start by trying to download a file. MX Linux is a popular new distribution based on Debian Stable. They use zsync for their ISOs. Give zsync a try downloading MX Linux. If you don’t actually want the huge file, you can press Ctrl + C to cancel at any time.

zsync http://linuxfreedom.com/mxlinux/MX/Snapshots/MX-18_January_x64.iso.zsync

Zsync Downloading MX Linux

Notice that zsync begins by checking for an existing file to update. If it doesn’t find one, it’ll just download the whole file.

You also have the option to download a .zsync file directly to your computer and use it to download the target. Use the -i flag to specify the path to your file.

zsync -i ~/Downloads/MX-18_January_x64.iso.zsync

The result is exactly the same.

If you’d rather change the name of your output file, you can use the -o flag for that. Sometimes it helps to shorten the file name to make it easier to work with.

zsync http://linuxfreedom.com/mxlinux/MX/Snapshots/MX-18_January_x64.iso.zsync -o MX-18.iso

Once again, you get the same file, just with a different name.

Updating a File

Ubuntu also uses Zsync files for its ISOs. They’re not as easy to get to, though. You can only find them through Ubuntu’s CD image server, but they are there for Ubuntu and its different flavors. The process is exactly the same as downloading a fresh file. Zsync will still start off by looking for an existing file in your current directory. Only when it finds the file, will it compare the differences between them and only download the updated parts. The image below shows what happens when zsync finds an existing Kubuntu ISO.

Zsync Updating Kubuntu

Conclusion

There’s not much else to it. Zsync is an excellent way to keep your downloads to a minimum. The only real downside to zsync is that it’s not as widely used as it probably should be. Even still, it’s worth checking into, especially if you download large files frequently.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Nick Congleton

Nick is a freelance tech. journalist, Linux enthusiast, and a long time PC gamer.