How To Move APT's Archive Directory to Another Partition

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
garda

How To Move APT's Archive Directory to Another Partition

Post by garda »

For whatever reason and/or purpose, you may want to move apt's package cache directory to a different location, probably in a different partition. Possible usage scenarios would be:

1. You have multiple computers running Mint which are not connected to the same network (e.g. one at work and one at home) and you want to make the packages you download on one computer available to the other without having to manually copy and paste the files. You can make, for example, your USB stick or hard drive serve as a mobile apt cache medium.

2. Your system (root) partition is getting cramped and you can not or do not want to go through the hassle of resizing partitions. You can free up quite a significant amount of disk space by moving the cached (downloaded) packages to another partition.

3. Anything else you can think of. :)

This method is very simple and does not require any additional programs be installed yet also quite fool-proof. Here is how you do it:

1. In Nautilus, navigate to the partition to which you would like to move the cached packages. Create a new folder (SHIFT+CTRL+N) and use only lower-case characters (no capitals) for the folder name.

Please note: In this example, I want to move the packages to the folder 'apt_cache' in a FAT32 partition titled 'backup'.

2. Still in Nautilus, navigate to File System > var > cache > apt > archives. Press CTRL+S on your keyboard and enter "*.deb" (without quotes) to select all the DEB package files. Press CTRL+C on your keyboard.

3. Navigate back to the folder you created in step no. 1 (apt_cache). Now press CTRL+V on your keyboard to paste the packages to that folder.

4. Stil in the same folder (apt_cache), create a sub-folder and name it "partial" (without quotes, all lowercase). Then create a new blank file (File > Create Document > Empty File) and name it "lock" (without quotes, all lowercase). Please note that the file "lock" should be placed in "apt_cache", not in "partial".

5. Go to File System > var > cache > apt. Right-click on an empty area, and select 'Open in Terminal'.

6. In the Terminal, enter the following commands:

Code: Select all

sudo mv archives archives.old

Code: Select all

sudo ln -s /media/backup/apt_cache/ archives
Change /media/backup/apt_cache/ in the second command to your need. And do not close the Terminal just yet.

Hint: To learn about what a command actually does, you can always type man commandname in a Terminal window. Typing man ln will get you to a manual page describing what the command ln does and how to use it.

7. Perform some tests to check if everything is working properly.

8. If you think everything is working well, then you may delete the files in the original archives folder (renamed to archives.old in step no. 6). To do this, enter the following command in the terminal:

Code: Select all

gksu xfe /var/cache/apt
9. An XFE window should appear. You have to manually delete all the *.deb files in the "archives.old" folder, leaving only the sub-folder "partial" and an empty file "lock".

10. Still in the same XFE window, hit CTRL+DEL on your keyboard to permanently wipe out all the files you deleted in step no. 9.

That's it. Easy, ain't it?
Last edited by garda on Mon Nov 24, 2008 1:47 am, edited 1 time in total.
Husse

Re: How To Move APT's Archive Directory to Another Partition

Post by Husse »

Two comments
Why a FAT32 partition - there is no need to share .deb files with Windows and it is a lousy file system
The xfe file browser is only present in Elyssa main - in other editions you have to use the file browser that's present (Nautilus, Konqueror, Thunar....)
Apart from that a nice little tutorial
garda

Re: How To Move APT's Archive Directory to Another Partition

Post by garda »

Why a FAT32 partition - there is no need to share .deb files with Windows and it is a lousy file system
You've got it, there's no need to do so and it'd be much safer if one use another *NIX filesystem, be it ext3, XFS, RFS or whatever. But using any existing FAT32 partition adds up to simplicity that most typical user needs (seasoned Linux users must've considered this type of operation old hat). This becomes more relevant if one wants to use his/her USB stick or flash memory card to keep the cache and still have it readily available for use on Windows. Believe it or not, I do that sort of thing with an 8 GB microSD. :)
The xfe file browser is only present in Elyssa main - in other editions...
I see and thank you for making that bit clear. I haven't had the time (and disk space) to play around with other flavours of Mint, so I never knew that.

Thank you very much for that last line. :D
ajgreeny
Level 7
Level 7
Posts: 1640
Joined: Mon Nov 19, 2007 3:27 pm

Re: How To Move APT's Archive Directory to Another Partition

Post by ajgreeny »

Could you not do exactly the same thing using

Code: Select all

gksudo nautilus
or

Code: Select all

kdesu konqueror
depending on your DE, and then just drag the files/folders in the filemanager, holding down Ctrl to copy, not move them to the new partition? Or have I missed some simple thing and misunderstood what you are trying to do?
garda

Re: How To Move APT's Archive Directory to Another Partition

Post by garda »

For the Nautilus versus XFE part:
I simply want people who follow this tutorial comply with Mint Main's suggested ways of doing things. One of them is use XFE to deal with files in super user mode. You may, of course, use Nautilus in super user mode if you want to. Mind you though, there are many experienced users in this forum who go against such practice. To be honest, I did all of the steps I put into this tutorial in the Terminal without ever touching any GUI (neither Nautilus nor XFE) at all.

As for the Konqueror part, you can also use it if you're on the KDE CE. But then, as I mentioned in a previous post:
I haven't had the time (and disk space) to play around with other flavours of Mint...
If you're already adequately familiar with Linux or you're of adventurous user type, you may improvize. Otherwise, I recommend sticking to the suggested ways.

Cheers.
Post Reply

Return to “Tutorials”