How to Mount a TAR File as a Directory on Ubuntu
Table of Contents
This tutorial shows how to mount a TAR archive file (
.tar, etc.) as a directory on Ubuntu so that you can access the contents without first unpacking them to disk. When you're done viewing (or even modifying) the contents, you can simply unmount the TAR file. Any changes you make will be applied to the TAR file itself.
Step 1. Open a Terminal Session
If you're using an Ubuntu laptop or desktop, you can press
Ctrl + Alt + T on your keyboard to open a new terminal window. If you're using a remote Ubuntu server, you can connect using SSH to open a new terminal session.
Make sure you have
You can mount the TAR file at any directory (called the mount point), as long as you have write permission for the directory. Here, we'll mount it at
To mount a TAR file named
myfiles.tar.gz at our mount point from the previous step:
Now you can access the contents of your TAR file by going to the mount point directory:
When you're done with the contents, you can simply unmount:
Note that the command to unmount is
n right after the
u), not "unmount."
cd && part of the command above moves you to your home directory before unmounting, so that you're not inside the mount point after it is unmounted.
Optionally after you unmount, you can delete your mount point:
You've just accessed the contents of a TAR file without first unpacking them to disk.