========================
== Artur's Tech Notes ==
========================
Artur's tech notes

Limiting resources on FreeBSD

freebsd rctl
What is rctl In FreeBSD, in addition to login.conf, we also get a very nice and flexible mechanism for setting resource limits: rctl. I like it in particular for limiting resources allocated to each jail. Configuration Here is a short example: jail:example_jail:vmemoryuse:deny=2G/jail jail:example_jail:maxproc:deny=200/jail jail:example_jail:readiops:throttle=500/jail jail:example_jail:pcpu:deny=70/jail In the above, for the jail identified by example_jail we allow: 2G of memory, 200 processes, 500 I/O read operations per second, 70% of CPU. Enabling rctl on boot Actually, there is no need to enable anything in rc. Read more...

Public VMs on OpenBSD

openbsd virtualisation
This is a note on how to make a VM running on OpenBSD connect to the host’s network. Firstly, we need to create a bridge with our external network interface. # echo "em0" > /etc/hostname.bridge0 # /etc/netstart bridge0 In /etc/vm.conf we need to add a switch on bridge0: switch "sw" { interface bridge0 } Then, our VM needs to be attached to that switch: vm "openbsd" { memory 8G enable disk /data/vm/openbsd/main. Read more...

Basic concurrency with fork()

programming linux unix concurrency c
When programming on Linux/Unix, the function fork(2) allows us to create new processes. This is a short and example-driven introduction to the basics of using that function. First stab After a brief look at the manual page for fork(2) we can tell that it returns a value of type pid_t and does not take any arguments: NAME fork – create a new process SYNOPSIS #include <unistd.h> pid_t fork(void); Let us simply call fork and see what happens and what values does it return. Read more...

Quick start: virtual machines on OpenBSD

openbsd virtualisation
Since OpenBSD 5.9 it is possible to run virtual machines using a native virtualisation solution. This is a short note/guide on how to set up a VM on OpenBSD in the simplest way that lets you have a quick play with vmm/vmd. Preliminaries First of all, we need to enable vmd on our host and get it running: # rcctl enable vmd # rcctl start vmd You may also want to make sure you firewall can initially let everything through: Read more...

Reading and monitoring files on Linux

linux basics
Let’s start with something super basic. To print the contents of a file you can use cat: cat file This tool is simple but really powerful when combined (piped) with other commands. However, cat is not very practical if you just want to see the contents of a larger file. In that case you can use less, which also allows you to conveniently browse your file: press space for page down or b for page up, type /pattern to search for pattern in the file (n jumps to the next occurence, while N jumps to the previous one), press q to quit. Read more...
1 of 1