Clean up usr/lib

My usr directory is taking up more than 13 Gb and most of it is in /lib and /share
I am puzzled why it is so big. Any ideas how to thin it out?
See screenshots and system info

inxi -F                                                                                     22 ✘ 
  Host: manjaro Kernel: 6.6.7-4-MANJARO arch: x86_64 bits: 64
    Desktop: KDE Plasma v: 5.27.10 Distro: Manjaro Linux
  Type: Desktop Mobo: ASUSTeK model: PRIME B365M-A v: Rev X.0x
    serial: <superuser required> UEFI: American Megatrends v: 2208
    date: 07/09/2021
  ID-1: hidpp_battery_0 charge: 52% condition: N/A
  Info: 8-core model: Intel Core i7-9700 bits: 64 type: MCP cache: L2: 2 MiB
  Speed (MHz): avg: 800 min/max: 800/4700 cores: 1: 800 2: 800 3: 800 4: 800
    5: 800 6: 800 7: 800 8: 800
  Device-1: Intel CoffeeLake-S GT2 [UHD Graphics 630] driver: i915 v: kernel
  Device-2: USB C Video Adaptor driver: N/A type: USB
  Device-3: Microdia USB Live camera driver: snd-usb-audio,uvcvideo
    type: USB
  Display: x11 server: X.Org v: 21.1.10 driver: X: loaded: modesetting
    dri: iris gpu: i915 s-res: 3840x1080 resolution: 1: 2560x1440 2: 1920x1080
  API: EGL v: 1.5 drivers: iris,swrast platforms: x11,surfaceless,device
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa v: 23.1.9-manjaro1.1
    renderer: Mesa Intel UHD Graphics 630 (CFL GT2)
  API: Vulkan v: 1.3.269 drivers: intel surfaces: xcb,xlib
  Device-1: Intel 200 Series PCH HD Audio driver: snd_hda_intel
  Device-2: Microdia USB Live camera driver: snd-usb-audio,uvcvideo
    type: USB
  API: ALSA v: k6.6.7-4-MANJARO status: kernel-api
  Server-1: PipeWire v: 1.0.0 status: active
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    driver: r8169
  IF: enp3s0 state: up speed: 1000 Mbps duplex: full mac: a8:5e:45:e2:87:3c
  Device-2: Realtek RTL8153 Gigabit Ethernet Adapter driver: r8152 type: USB
  IF: enp0s20f0u3u1 state: down mac: 00:e0:4c:68:51:92
  Device-1: Cambridge Silicon Radio Bluetooth Dongle (HCI mode) driver: btusb
    type: USB
  Report: rfkill ID: hci0 state: up address: see --recommends
  Local Storage: total: 2.26 TiB used: 839.66 GiB (36.3%)
  ID-1: /dev/sda vendor: Kingston model: SA400S37480G size: 447.13 GiB
  ID-2: /dev/sdb vendor: Toshiba model: HDWD120 size: 1.82 TiB
  ID-1: / size: 99.1 GiB used: 20.78 GiB (21.0%) fs: ext4 dev: /dev/sda6
  ID-2: /boot/efi size: 96 MiB used: 43.7 MiB (45.5%) fs: vfat
    dev: /dev/sda1
  Alert: No swap data was found.
  System Temperatures: cpu: 30.0 C mobo: N/A
  Fan Speeds (rpm): N/A
  Processes: 312 Uptime: 10m Memory: total: 16 GiB available: 15.49 GiB
  used: 9.56 GiB (61.7%) Shell: Zsh inxi: 3.3.31

I have noticed sometimes old modules are left around in /lib

If you would like to run this script:

#!/usr/bin/env bash
# gcspt
# grub+ configuration search presentation tool
# <3 cscs <3

gcspt=$(find /boot -type f -name '*.cfg' 2>/dev/null | sort);
gscpt=$(find /etc/grub.d -type f ! -name 'README' 2>/dev/null | sort);
initz=$(find /boot -type f -name 'initramfs*' 2>/dev/null | sort); 
imgz=$(find /boot -type f -name 'vmlinuz*' 2>/dev/null | sort); 
modz=$(find /lib/modules -maxdepth 1 -type d 2>/dev/null | sort);
mkinitz=$(find /etc -type f -name 'mkinitcpio*' 2>/dev/null | sort); 
mkinitzd=$(find /etc/mkinitcpio.d -type f 2>/dev/null | sort);
dracutz=$(find /etc -type f -name 'dracut*' 2>/dev/null | sort); 
dracutzd=$(find /etc/dracut.conf.d -type f 2>/dev/null | sort);

_gcspt_format () {
    while read in; do ls -l --time-style=+'%F %R' "$in" | cut --complement -d ' ' -f1,2,3,4,5; done | column -t

#printf '\n...Bite-Sized Boot-Info...\n';

printf "\nCurrently Running Kernel:\n$(uname -s -r)\n";

printf '\nGrub Configuration Files:\n';

echo "$gcspt" | _gcspt_format;
echo "$gscpt" | _gcspt_format;

printf '\nInstalled Kernels:\n';

echo "$imgz" | _gcspt_format;

printf '\nInitramfs Images:\n'; 

echo "$initz" | _gcspt_format;

if which mkinitcpio >/dev/null 2>&1; then

printf '\nmkinitcpio:\n';

echo "$mkinitz" | _gcspt_format;
echo "$mkinitzd" | _gcspt_format;

if which dracut >/dev/null 2>&1; then

printf '\ndracut:\n';

echo "$dracutz" | _gcspt_format;
echo "$dracutzd" | _gcspt_format;


printf '\nModule Directories:\n'; 

for i in $modz; do du --time --time-style=+'%F %R' -sh $i; done | awk '{print $2,$3,$4,$1}' | column -t; 

printf '\nHibernation:\n';

grep -o 'resume=' /etc/default/grub || printf 'No "resume=" option found in /etc/default/grub\n';

printf '\nSettings of /etc/default/grub:\n';

awk 'NF && !/^ *#/ { print; }' /etc/default/grub;

printf "\n"

(save as a file name gcspt, mark it executable with chmod +x gcspt, then run with ./gcspt)

And then also return

mhwd-kernel -li

We might see what directories are expendable.

This might give a better appreciation of space used:

pacman -Qqe > pkglist.txt

It lists all installed packages, and writes them to ‘pkglist.txt’ in your home directory. I hope this helps to an extent.

I found TeX Live, as an example, filled to 6/7GB initially (using a reduced version now).

Currently Running Kernel:
Linux 6.6.7-4-MANJARO

Grub Configuration Files:
2023-12-21  12:48  /boot/grub/grub.cfg
2023-10-12  17:45  /etc/grub.d/00_header
2023-10-12  17:45  /etc/grub.d/10_linux
2023-10-12  17:45  /etc/grub.d/20_linux_xen
2023-10-12  17:45  /etc/grub.d/25_bli
2023-10-12  17:45  /etc/grub.d/30_os-prober
2023-10-12  17:45  /etc/grub.d/30_uefi-firmware
2023-10-12  17:45  /etc/grub.d/40_custom
2023-10-12  17:45  /etc/grub.d/41_custom
2023-06-15  14:12  /etc/grub.d/41_snapshots-btrfs
2023-05-07  20:57  /etc/grub.d/60_memtest86+
2023-05-07  20:57  /etc/grub.d/60_memtest86+-efi

Installed Kernels:
2023-12-21  12:18  /boot/vmlinuz-6.5-x86_64
2023-12-21  12:18  /boot/vmlinuz-6.6-x86_64

Initramfs Images:
2023-12-21  12:18  /boot/initramfs-6.5-x86_64-fallback.img
2023-12-21  12:18  /boot/initramfs-6.5-x86_64.img
2023-12-21  12:19  /boot/initramfs-6.6-x86_64-fallback.img
2023-12-21  12:18  /boot/initramfs-6.6-x86_64.img

2023-10-05  01:34  /etc/mkinitcpio.conf
2023-12-21  12:18  /etc/mkinitcpio.d/linux65.preset
2023-12-21  12:18  /etc/mkinitcpio.d/linux66.preset

Module Directories:
2023-12-21  12:18  /lib/modules                           599M
2023-12-21  12:18  /lib/modules/6.5.13-6-MANJARO          298M
2023-12-21  12:18  /lib/modules/6.6.7-4-MANJARO           300M
2023-12-21  12:17  /lib/modules/extramodules-6.5-MANJARO  324K
2023-12-21  12:17  /lib/modules/extramodules-6.6-MANJARO  324K

No "resume=" option found in /etc/default/grub

Settings of /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash apparmor=1 security=apparmor udev.log_priority=3"
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

    ~/Desktop  mhwd-kernel -li                                                                        ✔ 
Currently running: 6.6.7-4-MANJARO (linux66)
The following kernels are installed in your system:
   * linux65
   * linux66

It gives you a list in alphabetical order, but it doesn’t tell the size of the packages.

No, but it reminds you of the number of packages you have installed.

The package sizes are of no real consequence, as they are extracted during install taking up an even greater amount of space.

I don’t recall the exact command that might also include package sizes, but I’ll check for you. OK, I’ve found no pacman command that does that, as expected, but these may help as you continue your quest:

To list all packages no longer required as dependencies (orphans):

pacman -Qdt

To list all packages explicitly installed and not required as dependencies:

pacman -Qet

These come from Pacman in the ArchWiki.

This command lists packages by size.

expac -s "%-30n %m" | sort -rhk 2 | less

You might need to install expac first.

I did that one and in Konsole I see like below, but I can’t figure out how to navigate the output

Maybe try

expac -s "%-30n %m"

first to see if there is anything returned.

Or, this:

expac -s "%-30n %m" > ~/pkglist_with_sizes.txt

Then check your user directory for the resulting file.
It’s sorted alphabetically by default.

The OP can probably delete that (mainly empty and useless) preformatted text box in the previous post. :slight_smile:

1 Like

Thanks, that actually turned up some interesting stuff that I will need to research if I still need those packages.

Try to focus on packages you know you installed, and avoid those you’re initially unfamiliar with. Some of them you can simply uninstall if not needed. Of those you do uninstall, check for folders under ~/.config etc., that are related to them, and remove those also. Good luck.

This might give you an idea about locales

1 Like