Advertisement
CTpaHHoe

Ubuntu Reduce installation size

Mar 24th, 2022 (edited)
933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.13 KB | None | 0 0
  1. # just in case we are retrying and apt is in a bad state
  2. dpkg --configure -a
  3.  
  4. # DEBIAN_FRONTEND=noninteractive is useful for scripting.
  5. # prevents getting prompts that will hang our script.
  6.  
  7. # ubuntu-minimal is a meta package that depends on the packages
  8. # in ubuntu-minimal install.
  9. # Need aptitude to autoremove everything we don't depend on.
  10. DEBIAN_FRONTEND=noninteractive \
  11.   apt-get --assume-yes install aptitude ubuntu-minimal
  12.  
  13. # mark all packages as automatically installed except
  14. # ubuntu-minimal, kernel, systemd and openssh.
  15. # For some reason systemd isn't part of ubuntu-minimal.
  16. # Any dependencies of these four packages will be kept.
  17. # All others that aren't dependencies will be removed since
  18. # we have told apt they are automatically installed
  19. # (ie we don't care about them unless we need them as a dep)
  20. DEBIAN_FRONTEND=noninteractive \
  21.   aptitude --assume-yes markauto \
  22.     '~i!?name(ubuntu-minimal~|linux-generic~|systemd~|openssh-server|grub~|lvm2~)'
  23.  
  24. # purge all removed packages that were not purged.
  25. # removes leftover config/cruft.
  26. DEBIAN_FRONTEND=noninteractive \
  27.   aptitude --assume-yes purge '~c'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement