You are not logged in.

#1 2017-10-18 21:51:54

tbg
Member
Registered: 2017-06-22
Posts: 74

Reduce the size of linux on SSD

Hi Archers. I still consider myself newb with Arch, so I thought I'd post here. I try to keep my SSD drive to a minimum size for backup purposes. What ways have you accomplished this without having to do a lot of scrubbing manually. I found the most wasted space on my root drive was from old stored packages. I didn't want to outright delete them in case I needed to downgrade problem packages. I found a few new tricks I had not used before to reduce my SSD drive size substantially.

This method seems to work well, (from my limited testing). Do you see any problems with the way I have accomplished moving my cached packages to a separate storage drive? Do you have any other suggestions of ways to reduce wasted space on my Linux partitions.

Any tips or suggestions appreciated. Thanks in advance.

Below is the way I relocated my cached packages. Please excuse the length.
===============================================
CHANGE THE PACMAN & PACAUR PACKAGE STORE LOCATIONS TO A DIFFERENT DRIVE

this will substantially reduce the size of cached packages stored in root, (or the need to purge the cache constantly)
===============================================
EDIT PACMAN.CONF TO RELOCATE CACHED PACKAGES TO ANOTHER DRIVE
===============================================

create a new Pacman cache storage location, such as:

/run/media/htpc/3TB_Toshiba16/pac_cache/packages

I believe it is best to add both the user and root accounts to the folder permissions

sudo chown -R htpc:root /run/media/htpc/3TB_Toshiba16/pac_cache/packages
sudo chmod -R 775 /run/media/htpc/3TB_Toshiba16/pac_cache/packages

edit /etc/pacman.conf to use the new alternate drive directory as the default pacman cache dir.

make a backup of the pacman configuration file before editing

sudo cp /etc/pacman.conf /etc/pacman_conf.bak

uncomment the "CacheDir" config line , and insert the new cache destination directory into /etc/pacman.conf :

CacheDir    =/run/media/htpc/3TB_Toshiba16/pac_cache/packages

test that newly relocated cache directory is being utilized by performing a small package install

once confirmed that this change is working, move the contents of /var/cache/pacman/pkg into the new cache folder

su to root: #

find /var/cache/pacman/pkg/ -type f -print0 | xargs -0 mv -t /run/media/htpc/3TB_Toshiba16/pac_cache/packages

===============================================
CHANGE THE DEFAULT PACAUR CACHED PACKAGE FILES LOCATION TO ANOTHER DRIVE
===============================================

The default user cached AUR package files location for pacaur is:  /home/user/.cache/pacaur/

===============================================
CHANGE THE DEFAULT PACAUR CACHE LOCATION BY SYMLINKING TO ANOTHER DRIVE
===============================================

Copy all cached AUR packages from /home/htpc/.cache/pacaur/ to /run/media/htpc/3TB_Toshiba16/pac_cache/pacaur/

some packages may create errors during transfer, copy first,  (do not perform a GUI  move operation), to avoid problems.

once the folder contents of /home/user/.cache/pacaur/ have been copied successfully (and confirmed completely transferred):

then delete the original ~//pacaur  source folder from ~/ .cache.

After the ~//pacaur folder has been deleted,  symlink /run/media/htpc/3TB_Toshiba16/pac_cache/pacaur/ into /home/htpc/.cache/

the new symlinked directory should now be the default AUR Packages store location if everything has been configured correctly

===============================================
EDIT /ETC/MAKEPKG.CONF TO RELOCATE SAVED PACKAGES TO ANOTHER DRIVE
===============================================

make a backup of the configuration file before editing

sudo cp /etc/makepkg.conf /etc/makepkg_conf.bak

===============================================
EDIT THE  /ETC/MAKEPKG.CONF  "PKGDEST" LINE AS FOLLOWS
===============================================

insert the new destination

PKGDEST=/run/media/htpc/3TB_Toshiba16/pac_cache/packages

Again,  apologies for the length. Comments, suggestions?

Last edited by tbg (2017-10-19 00:51:19)

Offline

#2 2017-10-18 21:55:30

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Reduce the size of linux on SSD

Please use code tags when pasting to the boards: https://wiki.archlinux.org/index.php/Co … s_and_code


I just rsync my package cache to a central server and then run paccache; my machines root partitions remain within reasonable bounds (up to about 80%), and I have access to older packages if required (generally the last 2 to 3).


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2017-10-18 22:36:11

tbg
Member
Registered: 2017-06-22
Posts: 74

Re: Reduce the size of linux on SSD

My apologies for not using code tags. I am rather new on the forum and am just trying to learn the ropes. Thank you for the rsync suggestion. I am using this machine in a simple home configuration. That is why I have used the external drive via esata connection option.

Offline

#4 2017-10-18 22:38:02

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Reduce the size of linux on SSD

The best way to learn the ropes is to edit your post and include the code tags. There is a link under every text box (bottom left) that says "BBCode", it includes instructions.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2017-10-18 22:42:08

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Reduce the size of linux on SSD

I just use the following pacman hook to automatically clear the cache  every time a package is installed/removed...

/etc/pacman.d/hooks/clean-pacman-cache.hook

[Trigger]
Operation = Remove
Operation = Install
Operation = Upgrade
Type = Package
Target = *

[Action]
Description = Cleaning pacman cache...
When = PostTransaction
Exec = /usr/bin/paccache -rqk2

I can't think of any good reason to keep old packages except the current plus one previous version (for troubleshooting), if you really do need anything older then it can be downloaded from the archive. Bear in mind that installing/reverting to an old package leaves you in a partital upgrade situation, which is unsupported by Arch.

I don't have a separate cache for AUR packages as these are all built on a different machine and added to a custom repo.

Last edited by Slithery (2017-10-18 22:45:40)


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#6 2017-10-18 23:41:01

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: Reduce the size of linux on SSD

When my backup script fails for want of space, I remember to run

paccache -r

But I wouldn't particularly recommend this solution.

I have no good way of clearing out AUR packages. These just accumulate and accumulate until I deal with the worst offenders (looking at you, dropbox) manually.

I think it is wise to keep more than just the 2 versions of a package and always go with the default (3). Sometimes, a package might be updated more than once before it is really tested and, while partial updates are not supported, sometimes a partial upgrade situation is supported in practice, though not in theory, while a fully updated system is supported in theory, but not in practice. When that happens, a partial upgrade is a lifesaver until practice comes back in line with theory and a full upgrade is a working proposition.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB