How to clean system

Markiyan Kushnir markiyan.kushnir at gmail.com
Sun Jan 9 11:13:52 UTC 2011


2011/1/8 Giorgos Keramidas <keramida at ceid.upatras.gr>:
> On Sat, 8 Jan 2011 23:18:07 +0200, Коньков Евгений <kes-kes at yandex.ru> wrote:
>> Hi
>> System have many programs.
>> Wanna to upgrade to new version of FBSD
>>
>> Is it possible to clean system from garbage (all programs, files,
>> header files, except configuration files)
>> like installing FBSD from CD?
>>
>> is there cmd?
>> make clean-system
>
> No, there's no such command.  If you are looking for a way to 'deinstall
> all ports & packages' though, it may be as easy as:
>
> 1. Remove all the currently installed ports:
>
>    # rm -fr /usr/local
>    # mkdir /usr/local && cd /usr/local
>    # mtree -deU < /etc/mtree/BSD.local.dist
>

Deleting /usr/local will also delete /usr/local/etc -- which might be
not what the OP expects given the "except configuration files". I
would still follow the pkg_delete path, along with some other actions:

  - if you have fusefs, ntfs-3g, linprocfs, etc in your /etc/fstab --
unmount and comment out temporarily
  - if you have third party services in your /etc/rc.conf[.local] --
stop and comment out
  - if you have third party modules in /boot/loader.conf -- the same thing

% pkg_delete -adf
% rm -R /usr/local/lib/compat/pkg
% rm -R /var/db/pkg/* # if anything was left there
% rm -R /var/db/ports/* #if you want to clean up your ports' configurations
% rm -R /usr/ports/distfiles/* # not sure if you need it, but I do it
in some cases...
% rm -R /usr/obj

Check /usr/local and /usr/compat to see if you want to remove anything
from there manually. You might want to clean up /usr/local/include,
/usr/compat/linux/var, /usr/compat/linux/usr/local, /usr/local/bin
(?), /usr/local/info ... etc. OTOH, I always preserve
/usr/local/lib/X11/fonts -- I have some custom fonts stored there,
/usr/local/share/stardict -- custom dictionaries I want to survive
across upgrade ... etc.

I also place in /etc/mergemaster.rc something I want to preserve:
  /etc/master.passwd
  /etc/group
  /etc/ppp/ppp.conf
  /etc/syslog.conf
  /etc/sysctl.conf
  /etc/hosts
  /etc/namedb/named.conf

Regarding this last item, it might not always be the best way to do,
since sometimes it might be necessary to upgrade some of the default
settings in these files.

Then you can build and install the base system and the ports you need.
Almost all of these steps are easy to automate.

Thanks,
Markiyan.


> 2. Remove all the information about 'installed packages', because you
>   don't have any of these anymore:
>
>    # rm -fr /var/db/pkg/*
>
> 3. Optionally, if you are going to reconfigure all your ports from
>   scratch, remove the saved port configuration options:
>
>    # rm -fr /var/db/ports/*
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>


More information about the freebsd-questions mailing list