Remove sets from the NetBSD base system

From ezUnix
Jump to: navigation, search
                                    pdf_icon.png Download this article as a single PDF document 


I am renting a small Xen host which came with a preinstalled O.S of choice, in my case NetBSD.
It turned out the provider installed all the NetBSD sets including Xorg, which I don't really need.
I wanted to remove some of the sets from my system leaving it cleaner and smaller. And this is how I did it.


First of all check your /etc/mtree to see what sets were installed on the system.

# ls /etc/mtree

In my case I wanted particulary to remove these sets:



Approach I

Find the sets you want to remove. To test what is going to happen just simple use echo:

# /usr/sbin/mtree -C -f /etc/mtree/set.xcomp | grep type=file | cut -f1 -d ' ' | xargs echo rm -rf

And now run the real command (from / ) and remove the sets :

# /usr/sbin/mtree -C -f /etc/mtree/set.xcomp | grep type=file | cut -f1 -d ' ' | xargs rm -rf

Do the same for all the sets you wish to remove.

Approach II

You can also use following command to achieve exactly the same result. To list the files run:

# /usr/sbin/mtree -D -f /etc/mtree/set.comp -p / -k type | sed -e /^type=dir/d -e 's/^[^ ]* \.//'

And to remove them:

# /usr/sbin/mtree -D -f /etc/mtree/set.comp -p / -k type | sed -e /^type=dir/d -e 's/^[^ ]* \.//' | xargs rm -rf


I want to thank Asau in #NetBSD on for helping me with this task.

That's all folks. Marcin

<comments />

zat said ...
11:44, 5 May 2010 (CEST)
it could be nice !

Gaby said ...

<comment date="2012-04-19T02:46:08Z" name="Gaby"> Hello all. Thanks.Josiah, I switched a short time ago. It works ptrtey well I must say.Eric, yeah the story behind that one liner is long and varied, it started with needing to sniff a port and then killing that PID after that start apache, wheather it was apache you killed or not. So I came up with that. :) Fuzzie, no. </comment>

Jonny said ...

<comment date="2012-05-19T05:53:36Z" name="Jonny"> Almost . . . The path to prtdiag dendpes on the architecture of the system. The one you listed works on any Sun with a sun4u microprocessor. Use the following instead:/usr/platform/`/usr/bin/uname -i`/sbin/prtdiag -vRunning this on a CoolThreads machine will yeild some interesting data:czar / 3% /usr/platform/`/usr/bin/uname -i`/sbin/prtdiag -v | moreSystem Configuration: Sun Microsystems sun4v Sun Fire(TM) T1000System clock frequency: 200 MHzMemory size: 2040 Megabytes========================= CPUs =============================================== CPU CPULocation CPU Freq Implementation Mask------------ ----- -------- ------------------- -----MB/CMP0/P0 0 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P1 1 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P2 2 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P3 3 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P4 4 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P5 5 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P6 6 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P7 7 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P8 8 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P9 9 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P10 10 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P11 11 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P12 12 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P13 13 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P14 14 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P15 15 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P16 16 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P17 17 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P18 18 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P19 19 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P20 20 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P21 21 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P22 22 1000 MHz SUNW,UltraSPARC-T1MB/CMP0/P23 23 1000 MHz SUNW,UltraSPARC-T1========================= IO Configuration ========================= IOLocation Type Slot Path Name Model----------- ----- ---- --------------------------------------------- ------------------------- ---------MB/NET0 PCIE MB /pci@7c0/pci@0/network@4 network-pci14e4,1668MB/NET1 PCIE MB /pci@7c0/pci@0/network@4,1 network-pci14e4,1668MB/NET2 PCIX MB /pci@7c0/pci@0/pci@8/network@1 network-pci108e,1648MB/NET3 PCIX MB /pci@7c0/pci@0/pci@8/network@1,1 network-pci108e,1648MB/PCIX PCIX MB /pci@7c0/pci@0/pci@8/scsi@2 scsi-pci1000,50 LSI,1064========================= HW Revisions =======================================System PROM revisions:----------------------OBP 4.20.0 2005/12/15 16:49IO ASIC revisions:------------------Location Path Device Revision-------------------- ---------------------------------------- ------------------------------ ---------MB/IO-BRIDGE /pci@780 SUNW,sun4v-pci 0MB/SAS-SATA-HBA /pci@7c0 SUNW,sun4v-pci 0MB/SAS-SATA-HBA /pci@7c0/pci@0 pciex1166,103.b3 179MB/SAS-SATA-HBA /pci@7c0/pci@0/pci@8 pci1166,104.b3 179MB/GBE0 /pci@7c0/pci@0/network@4 pci14e4,1668.108e.1668.a2 162MB/GBE0 /pci@7c0/pci@0/network@4,1 pci14e4,1668.108e.1668.a2 162MB/GBE1 /pci@7c0/pci@0/pci@8/network@1 pci14e4,1648.108e.1648.10 16MB/GBE1 /pci@7c0/pci@0/pci@8/network@1,1 pci14e4,1648.108e.1648.10 16MB/SAS-SATA-HBA /pci@7c0/pci@0/pci@8/scsi@2 pci13e9,50 2 a0|a0 </comment>