On Sat 03 Jul 2021 at 17:50:44 (+0100), mick crane wrote: > On 2021-07-03 17:29, The Wanderer wrote: > > On 2021-07-03 at 12:06, mick crane wrote: > > > > > hello, > > > If I type "lsmod" there is a big list of modules with many > > > followed by a > > > "0" > > > which I guess means they are not needed in the kernel ? > > > > That depends what you mean by "needed". > > > > As I understand matters, what that number being nonzero means is that > > there's something else the kernel knows about (usually another module) > > which won't work if this module isn't loaded. In order to unload this > > module, you'll want to unload the other one first. > > > > If the module is zero, that means that the kernel doesn't know of > > anything other than that module which won't work unless the module is > > present. > > > > That doesn't mean that the module itself isn't needed, however. There > > might be some functionality which you need which is provided > > directly by > > that module, rather than by something which the kernel knows about and > > considers to be "something else", but which won't work if the module > > isn't loaded. > > > > For example, if the driver for your network card is contained in a > > module, then even if no other modules depend on that one, unloading the > > module would mean your network card would stop functioning. If you need > > your network to be functioning, that would mean that you still need the > > module, even though there aren't any other modules (etc.) which depends > > on it. > > > > > Does lsmod know about all installed software and if a module is > > > needed or does software have to be run first ? > > > > As Reco suggested, you'll have to clarify this. Most of the time, > > software does not require loading modules; it's most often > > hardware that > > requires that. > > > > > If I don't need them can somebody remind me how I can remove modules > > > ? > > > > The command to run is 'modprobe -r MODULE_NAME'. > > > > You can also do it with 'rmmod MODULE_NAME', but that's not usually the > > best way; IIRC, modprobe includes smarts which rmmod doesn't. > > > > Both of those commands need to be run as root in order to work. > > I did think that modules are for the kernel to interact with hardware. > There is for example "dell_smm_hwmon" followed "0" which you'd think > was to be used by software for monitoring the PC hardware. > I never used anything like that and wondered if there was some > software that was installed that needed that module > but I never used so it is "0" but if I used it it would change to "1". > I looked because "apt upgrade" failed to install things in /boot > because no room left. I deleted the oldest kernel stuff of the 3 there > and "apt upgrade" worked. > I was thinking then to remove the unwanted modules to make the kernels > smaller. > There is for example a few filesystem modules like msdos which would > be needed if I wanted to mount an msdos filesystem. > Seem to remember "insmod" a module if and when needed. > > If remove modules from kernel are the gone or are they still on disk > and could be put back ?
OK, you're short of space in /boot. Here's mine. $ ls -GlG /boot/ total 109828 -rw-r--r-- 1 root 3421023 Mar 19 09:29 System.map-4.19.0-16-amd64 -rw-r--r-- 1 root 3421235 Jun 21 03:46 System.map-4.19.0-17-amd64 -rw-r--r-- 1 root 206242 Mar 19 09:29 config-4.19.0-16-amd64 -rw-r--r-- 1 root 206214 Jun 21 03:46 config-4.19.0-17-amd64 drwx------ 3 root 4096 Dec 31 1969 efi drwxr-xr-x 5 root 4096 Jun 23 13:47 grub -rw-r--r-- 1 root 31149360 Mar 27 13:03 initrd.img-4.19.0-16-amd64 -rw-r--r-- 1 root 32309222 Jun 26 18:28 initrd.img-4.19.0-17-amd64 -rw-r--r-- 1 root 31156713 Jun 23 13:47 initrd.img-4.19.0-17-amd64.bak -rw-r--r-- 1 root 5287168 Mar 19 09:29 vmlinuz-4.19.0-16-amd64 -rw-r--r-- 1 root 5283072 Jun 21 03:46 vmlinuz-4.19.0-17-amd64 $ So it's obvious that you need to concentrate your attention on the initrd files. You could remove any .bak file, and even not generate any by setting backup_initramfs=no in /etc/initramfs-tools/update-initramfs.conf, but you could also save space by not storing all the modules in your initrd files. Do this by setting MODULES=dep in /etc/initramfs-tools/initramfs.conf and rebuilding it with update-initramfs. MODULES=dep will mean that if you change your booting method, there's a chance it could fail. In which case, you'd first boot with the old method and rebuild an initrd with MODULES=most. When you make these changes, just check for any parameters set in files in /etc/initramfs-tools/conf.d because they take priority. Cheers, David.