What is the best way to remove all packages and start over?

Running 9.0 Stable.

Want to completely remove all installed packages and start over and install just a few packages. I use portmaster to maintain my packages. Seems to me this is what I should do.

  1. Update the ports tree.
  2. Run pkg_delete
    # pkg_delete -a
  3. Back up /usr/local/etc/
  4. Clean out directories
    # rm -Rf /var/db/pkg/* /usr/local/* /usr/ports/distfiles/*

Reinstall portmaster and proceed from there to install the ports I need.

Does that seem correct? Am I missing any steps?
 
mdg said:
Running 9.0 Stable.

Want to completely remove all installed packages and start over and install just a few packages.
I use portmaster to maintain my packages. Seems to me this is what I should do.

  1. Update the ports tree.
  2. Run pkg_delete
    # pkg_delete -a
  3. Back up /usr/local/etc/
  4. Clean out directories
    # rm -Rf /var/db/pkg/* /usr/local/* /usr/ports/distfiles/*

Reinstall portmaster and proceed from there to install the ports I need.

Does that seem correct? Am I missing any steps?

I prefer to
Code:
# rm -Rf /var/db/pkg/*
# rm -Rf /usr/local/* # except etc

if /usr/local/ is on a separate partition, back up etc and format the partition.
 
mdg said:
Running 9.0 Stable.

Want to completely remove all installed packages and start over and install just a few packages.
I use portmaster to maintain my packages. Seems to me this is what I should do.

  1. Update the ports tree.
  2. Run pkg_delete
    # pkg_delete -a
  3. Back up /usr/local/etc/
  4. Clean out directories
    # rm -Rf /var/db/pkg/* /usr/local/* /usr/ports/distfiles/*

Pretty much. The portmaster(8) man page has a procedure at the end that shows doing that.
 
gkontos said:
Why don't you just reinstall the OS and start over with a fresh system?

That's a lot of work for just removing installed ports. Unless the system is foobarred for some reason there is no reason to start over with a fresh install.
 
wblock@ said:
Pretty much. The portmaster(8) man page has a procedure at the end that shows doing that.

I wouldn't recommend # rm -Rf /usr/ports/distfiles/*
HDD space is very cheap these days. Use /usr/ports/distfiles/ for cache.
Next time you update or reinstall there will be much fewer tarballs (tar archives) to download.
After you're done installing run # portmaster -y --clean-distfile (you may remove -y if you want to pick tarballs that you want to remove). This will remove obsolete tarballs.
 
  • Thanks
Reactions: mdg
UNIXgod said:
That's alot of work for just removing installed ports. Unless the system is foobarred for some reason there is no reason to start over with a fresh install.

Installing takes a few minutes, even cli. If you back up some important files in /etc & /usr/local/etc then you pretty much have everything you need.
 
gkontos said:
Installing takes a few minutes, even cli. If you back up some important files in /etc & /usr/local/etc then you pretty much have everything you need.

Not really a few minutes. Everyone has different setups. You still have to recompile your kernel and patch any security issues that have been disclosed since the initial install as well as a countless other customizations which may have been deployed depending on the setup the OP has (jails, zfs, hardware etc.). This isn't some linux distro where world and ports are considered the same and re-installs are suggested to fix breakage. There is no reason to blow away a system when all the OP needs it to blow away the ports cleanly. It's really a bad policy and is not recommended.
 
gkontos said:
Installing takes a few minutes, even cli. If you back up some important files in /etc & /usr/local/etc then you pretty much have everything you need.

Not sure why the OP wants to remove *most* packages, but I recall the following from
updating python etc:
Code:
cd /var/db/pkg
ls -lac | grep py26
... adapted to this use until the number of ports is pared down...
Code:
cd /var/db/pkg
ls -oSr  # the largest installs *may* be listed at the bottom
pkg_delete -f ... 
pkg_delete -f ...
...Seems like it would take only a few minutes rather than hours.
 
UNIXgod said:
Not really a few minutes. Everyone has different setups. You still have to recompile your kernel and patch any security issues that have been disclosed since the initial install as well as a countless other customizations which may have been deployed depending on the setup the OP has (jails, zfs, hardware etc.).
This isn't some linux distro where world and ports are considered the same and re-installs are suggested to fix breakage. There is no reason to blow away a system when all the OP needs it to blow away the ports cleanly. It's really a bad policy and is not recommended.

The OP asked for a way to wipe out all ports and start over. Before we provide an answer we have to think why would someone want to do something like this.

  • He is playing on a production server (Highly unlikely)
  • He is a power user with a complex customized KERNEL including exotic hardware and a few hundred jails (Highly unlikely)
  • He is learning FreeBSD, installed a few hundred ports and now wants to keep only a few.

Your Linux/FreeBSD comparison is really off topic here. I also wonder why you think that a reinstall is a bad policy. Unless of course you believe that someone is born a FreeBSD power user and doesn't have to break a few systems in the way.
 
gkontos said:
I also wonder why you think that a reinstall is a bad policy. Unless of course you believe that someone is born a FreeBSD power user and doesn't have to break a few systems in the way.

I don't believe the Linux/FreeBSD comparison is off topic as I have seen first hand misinformation passed down from individual to individual in a classic Dunning–Kruger effect.

The OP didn't break the system. If that was the case it would be imperative, whether for data retention or educational purposes, to exhaust every recovery technique before suggesting re-installation.

This has nothing to do with power users or new users. It has to do with properly distilling information on a help forum to facilitate the proper procedures which may not have been documented or could be obfuscated in it's current documented form.
 
@UNIXgod,

I am stopping this here because it is getting off topic and it appears to become personal. Something which clearly doesn't help the purpose of this forum.
 
Back
Top