# Cleaning up my current system. Without Reinstall



## albertobsd (Aug 5, 2017)

Hi everyone, I have some trouble with my laptop, I cant boot from boot USB to format again my laptop.

Actually I have a stable FreeBSD 10.1 in the hard drive, but my disk is full of old files and folders. I dont need any of those things. 

So, I want to know what is the easy way to clean my filesystem (remove all packages. erase old directories) like a fresh install, but without reinstall!!

There is a command to delete all current packages in a single line?

Regards!


----------



## ShelLuser (Aug 5, 2017)

albertobsd said:


> Actually I have a stable FreeBSD 10.1 in the hard drive, but my disk is full of old files and folders. I dont need any of those things.


With stable do you mean that it simply runs solid enough or that you installed STABLE?  Because the latter isn't really a suitable version for production; despite its name it's basically a developer snapshot which is a little less "bleeding edge" than CURRENT.

Also keep in mind that version 10.1 is outdated; it went EOL in 2014 (almost 3 years ago). Current is 10.3 (with 10.4 on the horizon) or 11.1.

The reason I mention this....



albertobsd said:


> So, I want to know what is the easy way to clean my filesystem (remove all packages. erase old directories) like a fresh install, but without reinstall!!
> 
> There is a command to delete all current packages in a single line?


`# pkg delete -a`, maybe even: `# pkg delete -ay`.

However, there's a problem here. FreeBSD only has 1 single version of the ports collection and it's fully aimed at the currently supporter version(s). Meaning that there are no guarantees that you'll be able to (re)install any software at all on outdated versions, you may want to keep this in mind before you whack your system.

You should definitely consider upgrading to 10.3 at least.


----------



## balanga (Aug 5, 2017)

albertobsd said:


> Hi everyone, I have some trouble with my laptop, I cant boot from boot USB to format again my laptop.
> 
> Actually I have a stable FreeBSD 10.1 in the hard drive, but my disk is full of old files and folders. I dont need any of those things.
> 
> ...



I'd suggest you install a new version of FreeBSD on a USB device and boot from that, make a list of the pkgs you have, mark the ones you want to keep and those that you want to delete, then install the ones you want to keep on the new installation.


----------



## albertobsd (Aug 5, 2017)

Thanks for reply to all.



ShelLuser said:


> it simply runs solid enough



That its! I mean stable to use daily. I know that version is outdated but. But is enough for me.



ShelLuser said:


> You should definitely consider upgrading to 10.3 at least.



Well, I will upgrade from source to its version. Following the Handbook:

https://www.freebsd.org/doc/handbook/updating-upgrading.html



balanga said:


> I'd suggest you install a new version of FreeBSD on a USB device and boot from that, make a list of the pkgs you have, mark the ones you want to keep and those that you want to delete, then install the ones you want to keep on the new installation.



I cant do that. Every time that I try boot from USB the laptop shutdown and restart without run any single line of the boostrap process.

There is a way to restore every single directory to its "initial status" like a fresh install?


----------



## IPTRACE (Aug 5, 2017)

Is there any CD/DVD drive you can burn the FreeBSD ISO and run installation?
If no, maybe try to use external CD/DVD drive?
If it's not possible, try to use another USB stick?


----------



## balanga (Aug 6, 2017)

albertobsd said:


> I cant do that. Every time that I try boot from USB the laptop shutdown and restart without run any single line of the boostrap process.



Is this a general problem with the laptop or something specific to a USB device with a FreeBSD installation?


----------



## Beastie (Aug 6, 2017)

In cases where booting off of external media is difficult or impossible, I basically solve the problem of upgrading safely by having both a production system and an upgrade testing system on the same machine.
In other words, I have a setup with 2 bootable slices/partitions. In the live system, I mount the second partition, extract the base and kernel distributions and add/edit a few system files (e.g. fstab). I then reboot, load the second system, install third-party software and test the whole thing.
When I'm satisfied with the results, I do the same with the first partition. I end up with 2 fully-functional and up-to-date systems, never having taken the risk of ruining the current system.

Of course, if your system slice/partition already occupies the entire disk, this may be a bit difficult to achieve.


----------



## albertobsd (Aug 8, 2017)

balanga said:


> Is this a general problem with the laptop or something specific to a USB device with a FreeBSD installation?



Is specific of the USB device with FreeBSD, I can boot others usb with Windows or Linux. And I'm pretty sure that the USB with FreeBSD boots in others computers.



Beastie said:


> Of course, if your system slice/partition already occupies the entire disk, this may be a bit difficult to achieve.



I can do that with jails, but im looking the fast and easy way to do that.



IPTRACE said:


> Is there any CD/DVD drive you can burn the FreeBSD ISO and run installation?
> If no, maybe try to use external CD/DVD drive?
> If it's not possible, try to use another USB stick?



Well the DVD drive don't work properly.
I don't have an external drive.
I try with many others USB, I can boot with windows or linux but it fail with the USB FreeBSD. Those USB stick work in others computers but I dont know why shutdown my laptop.

I will try to upgrade via source code.

Let me ask again:
*There is no way to copy again all the whole filesystem (cleaned) files and directories from an external source and run the bsdinstall again?*

Regards!


----------



## Deleted member 30996 (Aug 8, 2017)

albertobsd said:


> And I'm pretty sure that the USB with FreeBSD boots in others computers.



I'm building FreeBSD 11.1-RELEASE on my new laptop right now after having booted from a USB stick.

Some laptops require you tap a different button during boot to boot from USB. Esc, F1, F12, etc.

I take it you've already gone into BIOS and adjusted your boot menu to boot first from USB?

Edit: And you got the correct memstick.img file for a USB stick to boot from.

If you can boot Linux from a USB there's no reason you shouldn't be able to boot FreeBSD.


----------



## albertobsd (Aug 10, 2017)

Trihexagonal said:


> If you can boot Linux from a USB there's no reason you shouldn't be able to boot FreeBSD.



Yes I agree with you there's no reason. But this is a weird hardware problem of my laptop.

I download now the FreeBSD 11.1 RELEASE i386 memstick from FreeBSD 
FreeBSD-11.1-RELEASE-i386-memstick.img
https://download.freebsd.org/ftp/re...S/11.1/FreeBSD-11.1-RELEASE-i386-memstick.img

I make the USB with Win32DiskImager

Them I press F12 to show the boot menu. I select the USB device listed on it. But them the laptop restart again and show the usual BIOS output.

I do the process again to get the same result.

Trusme I know how to make a bootable a FreeBSD USB device from windows with such tool (Win32DiskImager) and from other systems with DD

The last time that I installed FreeBSD on tha computer (some years ago) I need boot from Ethernet In such occasion I deployed an PXE Server in other FreeBSD computer. But now I dont have any other computer with FreeBSD to do that.

I will search how to do a PXE server in Windows to install FreeBSD on the laptop.

Let me ask again:
*There is no way to copy again all the whole filesystem (cleaned) files and directories from an external source and run the bsdinstall again?*

Regards!


----------



## rigoletto@ (Aug 10, 2017)

Create a file containing the list of you origin pkgs, and edit/remove what you want:

`pkg prime-list > origins.txt`

Backup your /usr/local/etc config files and wherever you want to, and:

`pkg delete -af`
`rm -rf /usr/local/*`
`rm -rf /var/db/pkg/*`
`rm -rf /var/db/ports/*`
`rm -rf /usr/ports/distfiles/*`
`rm -rf /usr/obj`
`mtree -deU -f /usr/ports/Templates/BSD.local.dist -p /usr/local`
`pkg install `cat origins.txt``


----------



## Beastie (Aug 12, 2017)

albertobsd said:


> I can do that with jails, but im looking the fast and easy way to do that.


Jails can modify the host's entire system now?! That's... very bad news


----------

