Linux.com

Home Linux Community Community Blogs Distributions How-to: Blacklist Packages in Ubuntu

How-to: Blacklist Packages in Ubuntu

 

I don't know about everyone else, but the pushy nature of Ubuntu's auto-update mechanism drives me crazy. In particular the fact that continues to try to force grub2 to be installed. After much searching, asking around and experimenting I finally found how to properly blacklist packages or package sets in Ubuntu.

 

 

In my case I use Slackware Linux as my Primary OS in which I setup grub(legacy) as my primary bootloader, every time I went to update or upgrade ubuntu it tried to force grub2 to overwrite my MBR, this had to stop. I searched the net for answers with none found, I asking in irc channels with no success, so finally I decided to look around /etc/ at the configuration files for an option and I discovered it.

 

The answer is very simple:

 

  1. Remove the packages you don't want using apt-get, synaptic package manager or the software center.
  2. open apt's 01autoremove file by issuing the command sudo gedit /etc/apt/apt.conf.d/01autoremove
  3. Navigate to the bottom of the section titled Never-MarkAuto-Sections
  4. Add and entry to the section in my case to block grub I entered "grub*";.  The contents of the modified file is at the bottom of this page.
  5. You will enter the package name or portion of package names, including using * as a wildcard, in my case grub* blocks all packages that start with the word grub.

 

It is complete, when you next open the update utility it will not show the option to upgrade or update the software  that you chose to block.

The resolution is simple, but no documentation was found prior to this post. 

I hope you find this useful.

 

My /etc/apt/apt.conf.d/01autoremove file:

-------------------------------------------------------------------------------------------------------------------

APT
{
 NeverAutoRemove  {
  "^linux-firmware$";
  "^linux-image.*";   "^linux-restricted-modules.*";
  "^linux-ubuntu-modules-.*";
 };
 Never-MarkAuto-Sections
 {   "metapackages";
  "restricted/metapackages";
  "universe/metapackages";
  "multiverse/metapackages";
  "oldlibs";
  "restricted/oldlibs";
  "universe/oldlibs";
  "multiverse/oldlibs";
  "grub*";
 };
};
 

Comments

Subscribe to Comments Feed

Upcoming Linux Foundation Courses

  1. LFD331 Developing Linux Device Drivers
    13 Oct » 17 Oct - Virtual
    Details
  2. LFS425 Linux Performance Tuning Crash Course
    16 Oct » 16 Oct - Düsseldorf, Germany
    Details
  3. LFS220 Linux System Administration
    20 Oct » 23 Oct - Virtual
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board