Solved Is it safe to clean /var/db/freebsd-update/files ?

I've got 107954 files taking up almost 2G of space in the /var/db/freebsd-update/files directory, which I'm assuming are leftovers from performing freebsd-update during the various FreeBSD 10-RC upgrades. Is it safe to remove these? With the ability to rollback an upgrade (using freebsd-update rollback), I'm guessing that this is where that rollback information is saved. I don't see a need to keep all that if I'm past the point of ever wanting to rollback. Perhaps a "cleanup" command needs to be added to freebsd-update.
 
It's all in the freebsd-update(8) manualpage ;-)

Yes, the directory you're referring to here is the so called working directory, which you can also specify yourself by using the -d commandline parameter. As you guessed yourself; this is the place where temporary files and downloaded updates go. So if everything went well it should be safe to simply clean this one out.

As to your idea; I'd suggest to create a Problem Report (PR) for that, if one doesn't exist yet (seems that it doesn't). Just be sure to be precise and descriptive with your suggestion and also mark it as a request for change.
 
I also desire to have freebsd-update keep it's self tidy

I checked man freebsd-update and there was no mention of a clean function
 
I stumbled on this thread from the main menu of the site (right side) and noticed I also have 1.8 gb of files in this directory. Interestingly enough rm could not remove them because there were too many files so I ended up deleting the /var/db/freebsd-update/files directory itself then re-creating it and setting the appropriate permissions. Apparently rm has a parameter limit ;)
 
Apparently rm has a parameter limit ;)
Not exactly, limit is in the shell when expanding commands like rm /var/db/freebsd-update/files/*.
When the '*' is expanded, that expansion is performed from the shell itself, it then exec the rm process passing the file list as a single argument and the latter is size limited.
 
Apparently rm has a parameter limit ;)

When I expereince that I just modify my parameter, and do a rm a few times. Something like this for example:
rm a*
rm b*
rm c*


or for example
rm 201609*
rm 201610*
rm 201611*


I'm guessing there is a way that you don't need to do that, but that is what I do, and its a good way to practice syntax with wild-cards.
 
Why remove just files when the whole directory can be cleaned?

rm -r /var/db/freebsd-update/*

Works great.

==EDIT==

I see it now - you wanted to keep the rollback data. But I don't plan on rolling back so my way works fine for me.
 
When I expereince that I just modify my parameter, and do a rm a few times. Something like this for example:
rm a*
rm b*
rm c*


or for example
rm 201609*
rm 201610*
rm 201611*


I'm guessing there is a way that you don't need to do that, but that is what I do, and its a good way to practice syntax with wild-cards.
I've a clean installation from December 2014, with 160.000 files. Because the characters is always hex, I use:

rm [01]*
rm [23]*
(...)
rm [cd]*
rm *


It works.
But I don't understand one thing: In theory is depending on number of files. For example, I'm clean the portsnap database (/var/db/portsnap/files), with "only" 29.000 files:

rm [0-6]*
/bin/rm: Argument list too long.
rm [0-4]*
/bin/rm: Argument list too long.
rm [0-2]*
/bin/rm: Argument list too long.
rm [0-1]*
-ok-


Probably bug? Where is the limit? Can I delete millions of files with rm [01]* too?

Regards.
 
Probably bug? Where is the limit?
Not a bug, works as intended. It's very easy: every shell has a maximum amount of characters which you can use in one single command. So the error message you got simply tells you that you reached that limit.

So then you could use find or xargs or the routine I showed above: # for a in *; do rm $a; done.
 
What's often overlooked is that wildcards aren't fed to the command, in this case rm(1) never actually sees the [0-1]*. It's the shell that interprets the wildcards first and feeds a list of matching files to the command.
 
What's often overlooked is that wildcards aren't fed to the command, in this case rm(1) never actually sees the [0-1]*. It's the shell that interprets the wildcards first and feeds a list of matching files to the command.
Yes, I know, but for the first path, the wildcard represents near to 10.000 files by each starting letter 'a', 'b', etc. and 2nd path is 1.800 files by letter.
 
Why remove just files when the whole directory can be cleaned?

rm -r /var/db/freebsd-update/*

Works great.
This thread does contain helpful replies detailing ways to workaround the commandline character limit when deleting /var/db/freebsd-update/files/*. However, on a fresh installation of FreeBSD /var/db/freebsd-update/ is empty. It is populated, or repopulated if emptied, including the /files subdirectory, the next time freebsd-update fetch is executed.

Therefore I believe rustyx's reply is the easiest and optimal solution to the OP.
 
Back
Top