# Starting again from base system



## balanga (Aug 29, 2014)

After building and installing numerous packages, I seem to have created a bit of a mess so would like to start again from the base build.

How do I delete all built ports and installed pkgs?


----------



## asteriskRoss (Aug 29, 2014)

The ports-mgmt/portmaster tool has a procedure for doing this, described in the portmaster(8) man page.  Look in the examples section at "Using portmaster to do a complete reinstallation of all your ports".  If you simply want to remove all ports and not reinstall then you can stop before reinstalling ports-mgmnt/portmaster.


----------



## protocelt (Aug 29, 2014)

asteriskRoss said:
			
		

> The ports-mgmt/portmaster tool has a procedure for doing this, described in the portmaster(8) man page.  Look in the examples section at "Using portmaster to do a complete reinstallation of all your ports".  If you simply want to remove all ports and not reinstall then you can stop before reinstalling ports-mgmnt/portmaster.


 
I think that will only work for FreeBSD versions < 10-* due to the old pkg tools being removed in 10-RELEASE if I'm not mistaken.The portmaster(8) man page section might need to be updated to reflect the new pkg framework if so.


----------



## wblock@ (Aug 29, 2014)

To delete all packages, it's just `pkg delete -a`.

An updated portmaster(8) procedure for reinstalling all ports can be found in the diff on bug 191166.


----------



## Beastie (Aug 29, 2014)

The fastest and cleanest way: `rm -fr /var/db/pkg /var/db/ports /usr/ports /usr/local`

Note 1: remove the paths you don't want to clean (duh).
Note 2: be very careful when you type the command; you don't want spaces in the wrong places.


----------



## wblock@ (Aug 29, 2014)

Yikes!  I like to keep /usr/local/etc, generally there is quite a bit of work there.


----------



## balanga (Aug 29, 2014)

If I delete mysql-server, how do I delete any databases which may have been created previously?


----------



## junovitch@ (Aug 31, 2014)

balanga said:
			
		

> If I delete mysql-server, how do I delete any databases which may have been created previously?



I believe MySQL databases are normally under the directory /var/db/mysql.


----------

