Friday, June 29, 2018

Clearing Out /boot

The /boot partition sometimes needs a bit of attention. If you enable automatic updates, it will fill up with old kernels that you'll probably never need. It also will stop you from running aptitude to install or remove anything. If you find yourself in this situation, you can use dpkg to get around it. dpkg is the higher-level package manager in Debian-based distributions, and it's very useful when aptitude has broken.

To see the status of your partitions run: df -h:


Filesystem      Size  Used Avail Use% Mounted on
udev            3.0G   12K  3.0G   1% /dev
tmpfs           597M  528K  597M   1% /run
/dev/dm-0        97G   14G   78G  15% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            3.0G     0  3.0G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/sda1       228M  219M     0 100% /boot

If you look in the directory /boot you will see it full of old kernels and images. it is not advisable to just delete them as you can break your system. Run the following command, this will tell you what kernel you are currently on: uname -r:


3.13.0-137-generic

Lets find out what kernels are installed and which ones can be purged from your system. To do this, run the following:


dpkg --list "linux-image*" | grep -v $(uname) | grep ii

This will use dpkg to list all linux kernel images excluding the one you are using, that is installed.

The output might still be quite big, let's refine it by piping the results in to awk. The awk command below is an instruction to print the second column from the output.


dpkg --list "linux-image*" | grep -v $(uname -r) |
 ↪grep ii | awk '{ print $2 }'

This gives us a list to work with. We can stick this in a script or run it from the command line to purge them all.

CAUTION: make sure that the kernel you are using is not in the list. We should have eliminated that when we specified grep -v $(uname -r). The -v part tell grep exclude anything that contains the output of uname -r.

If you are happy and have sudo privileges, go ahead:


sudo dpkg --purge $(dpkg --list "linux-image*" | grep -v
 ↪$(uname -r) | grep ii | awk '{ print $2 }')

To finish off run sudo update-grub2 - This will ensure grub is updated with the available kernels - otherwise you may be heading for trouble. Then fix aptitude by running: sudo apt-get -f install followed by sudo apt-get autoremove to clear the images out of aptitude.

Look at your partition you will see it has free space.



from Linux Journal - The Original Magazine of the Linux Community https://ift.tt/2lKEHDY
via IFTTT

No comments:

Post a Comment

Playing Grand Theft Auto Inside A Neural Network’s Hallucination? It’s Possible!

Ever imagined what a Neural Network's hallucination would look like? The post Playing Grand Theft Auto Inside A Neural Network’s Halluc...