Archived entries for freebsd

FreeBSD view bandwidth and total bytes transferred for interface

Always installed nload on the server for which I wanted to view the bandwidth usage on.

But there’s preinstalled not-so-fancy-but-usable utility for FreeBSD:

systat -ifstat 1

S.

FreeBSD disk/partition resize – grow on version 8.2 and newer under vmware vSphere / ESXi

This one is easier than previous (FreeBSD 7.x or older).

It may be possible to do it all live but you need to find a way for FreeBSD to see the growed disk size.

  • Shut down the server
  • Grow the disk size
  • Boot FreeBSD in single user mode (number 4 at boot)
Check the partitions layout:

gpart show

Set the system in evil mode that will allow gpart to change live filesystem:

sysctl kern.geom.debugflags=16

Grow the whole disk – consumer. Number 1 is the consumer index shown with gpart show

gpart resize -i 1 da0

Grow desired provider – partition. Number 6 is the provider index shown with gpart show

gpart resize -i 6 da0s1

Now with partition resized you can growfs

growfs /dev/da0s1f

Reboot for a clean feeling and you’re done.

S.

syncing FreeBSD server with NTP is simpler than you may think

After setting up a config file for the NTP on every server, i figured out that a stock settings just work.

so adding:

ntpd_enable="YES"
ntpdate_enable="YES"

to the /etc/rc.conf just does the trick (and starting services if not rebooting the server).

After some moments of running the ntp client you can check it with:

# ntpq -c peers
remote refid st t when poll reach delay offset jitter
==============================================================================
*ntp2.Housing.Be 128.32.206.55 2 u 16 64 377 189.371 -14.785 5.513
mighty.poclabs. 169.229.70.64 3 u 28 64 377 132.913 -14.411 5.034
+vps1.cobryce.co 64.235.98.66 3 u 16 64 377 180.600 -22.410 5.258

where servers marked with * are the selected server and + are the candidates for ntp sync.

FreeBSD and shared iLo 2 port on HP servers

In order for HP iLo 2 management interface to continue working on a shared ethernet port after FreeBSD kernel loads the bge drivers, you must add following line to /boot/loader.conf

hw.bge.allow_asf="1"

And reboot.

Hope it will save you some minutes figuring it out…

S.

FreeBSD massive port forwarding

Portfwd was the choice of software when I ever needed to forward a port from the server to another server – multiple hops away (not NAT port mapping).

It uses configuration like this (193.2.1.66 is the local ip, 193.2.1.80 is destination server IP):

bind-address 193.2.1.66
tcp { 55443 { => 193.2.1.80:443 } }
tcp { 55022 { => 193.2.1.80:22 } }

But it fails doing its job right when you use this on a really busy port/service (500 or more simultaneous established TCP connections).

pf does the forwarding well even over 1000 TCP connections. Example:

rdr on em0 proto tcp from any to 193.2.1.66 port 55443 -> 193.2.1.80 port 443
rdr on em0 proto tcp from any to 193.2.1.66 port 55022 -> 193.2.1.80 port 22
nat on em0 from any to 193.2.1.80 -> 193.2.1.66

- the em0 is the name of the outside interface. Without the nat rule, destination server would see a packet with source ip of the client so it would send a packet back directly to the client which causes asymmetric routing and very possible problems. The nat rule changes the source IP to the port forwarders one.

Happy forwarding,
S.

understanding freebsd memory usage

I think it is better to write in english, since I’m often googling around about some problem and land on a site in chinese with some configuration pasted in the site.

The problem is I don’t know what poor chinese boy wrote: “This configuration is working for me:” or “This configuration is not working at all, can someone help me:”. So I try it. Never worked.

Recently I found a post which nicely describes statuses of FreeBSD memory allocation.

Top shows:

Mem: 4589M Active, 13G Inact, 489M Wired, 733M Cache, 214M Buf, 886M Free

And the snip from the post:

Memory normally moves along the following path:

Wired -> Active -> Inactive -> Cached -> Free

and then when it gets allocated and used it moves back to Wired.

The difference between the categories is mainly that “Inactive” and
“Cached” memory still contains data that the system might be able to
reuse, while “Free” memory is completely free and unused.
In order to use Cached or Inactive memory it might need to be flushed
first, with Inactive probably being dirty and Cached probably not.
(“Active” memory is almost certainly dirty and is therefore somewhat
more expensive to reuse.

samouničenje FreeBSD-ja

Ker je jutri srečanje blogerjev, jaz pa že skoraj pol leta nisem nič napisal, imam slabo vest in pišem…

Po svetu imam kar nekaj strežnikov in pride čas, da strežnik zamenjam za novega, ob tem pa nočem da podatki pridejo v roke “nasledniku” strežnika. Poleg varnega brisanja datotek sem si vedno želel pognati kakšen destruktiven ukaz, ki bi strežnik zares pokončal.

Takoj pride ideja, dd !! Vendar je FreeBSD malo zaščitniški glede pisanja po raw diskih:

[root@dolfi ~]# dd if=/dev/zero of=/dev/da0
dd: /dev/da0: Operation not permitted

Rešitev se skriva v sysctl zastavici. Hvala, bc !

[root@dolfi ~]# sysctl kern.geom.debugflags=16

po spremembi zastavice, bo dd deloval. Uničujoče. Poskusite v službi.

FreeBSD mount_smbfs .nsmbrc

Tale je za v arhiv, ker naslednjič bom vedel, da sem stvar že rešil, ampak ne kako…

Torej za avtomatski mount windows share-a iz /etc/fstab je konfiguracija sledeča…
/etc/fstab:
//BACKUP_USER@BACKUP_SERVER/BACKUP_SHARE /back/ar4 smbfs rw,-N 0 0

~/.nsmbrc:
[default]
workgroup=WORKGROUP
[BACKUP_SERVER]
addr=10.10.10.10
[BACKUP_SERVER:BACKUP_USER]
password=geslo



Copyright © 2004–2009. All rights reserved.

RSS Feed. This blog is proudly powered by Wordpress and uses Modern Clix, a theme by Rodrigo Galindez.