UFS file system space allocation policy

Ivan Voras has an interesting post explaining UFS file system space allocation:

Users coming from other systems don’t usually know it (and probably don’t care, in today’s environment of multi-TB drives), but UFS has a rather interesting approach to space allocation which is different from the “usual suspects” like ext2/3, NTFS and FAT(32). Though it sometimes feels “interesting” in the sense of the Chinese proverb, it’s time-tested to work.
I’m talking about clustering, blocks and fragments.

As in more common file systems like ext2/3, NTFS and FAT/FAT32, there is a concept of a “block” or a “cluster” of sectors. Typically, 8 sectors of 512 bytes are clustered together to form a block of 4 kB in size – with time this has become the “traditional” cluster size and is used by default on ext2/3, NTFS and, if drive sizes permit, FAT/FAT32.

This form of clustering means the operating system must maintain less data about what blocks are allocated and where. Since average file size is certainly larger than the sector size (which is the absolute minimum size allocatable on the drive), it makes sense to use a bigger amount of space and consider it “atomic”.

This has two obvious consequences: first, a 1-byte file takes 1 block of space, eg 4 kB and there is nothing to be done about it. Second, all “normal” files usually have some padding at their end to fit on a 4 kB boundary. Even if the operating system records that a file is exactly 5000 bytes in size, it will internally consider this file to take 2 blocks (8 kB). The space between the logical end of the file (5000 bytes) and the accounted space (8 kB) is irrevocably wasted. All usable file systems have variable block sizes; some file systems like FAT and FAT32 have built-in limitations that dictate minimum block (cluster) sizes depending on the drive size – a FAT32 file system of 64 GB will have to use a minimum cluster size of 32 kB to avoid memory and performance problems, meaning up to 32 kB is wasted on small files and there is usually large padding space at the files’ ends.


More about UFS on Wikipedia

Porting Chromium to FreeBSD

Ben Laurie has started porting Chromium (the open source project behind the Google Chrome browser) to FreeBSD.

In my copious spare time, I’ve started work on a FreeBSD port of Chromium. So far it doesn’t even build, but I’ve identified a few problem areas people might like to pitch in on.

  • NSS port: the FreeBSD NSS port needs to be upgraded to at least NSS 3.12. Ideally to the latest version because it fixes some security holes.
  • Sound: mostly whatever Linux does it likely to be the right thing for FreeBSD, too, so much of the porting work at this stage is pretty mechanical. But sound isn’t – the Linux port uses ALSA, which FreeBSD has no truck with. I am informed that the right thing to use on FreeBSD is OSS. But someone needs to do that.
  • Build farm: building this sucker is slow. I wouldn’t mind having access to a nice big build farm.

So far none of the work has been committed, but I am optimistic that some will be soon. In the meantime, you’ll be needing some patches. (source)

Google Chrome can already be run with Wine on FreeBSD (winehqhowto) but a native version would be better, obviously

FreeBSD as a WiFi Access Point

At a recent Linux users’ gathering Ivan Voras temporarily saved the day when a WRT router was not working. He set up his Acer Aspire One netbook as a wireless access point on FreeBSD 8.0. It had wired connectivity to the Internet from one side and offered WiFi via its Atheros card on the other side. In between it did NAT and protected the LAN side from the Linux hackers, both with ipfw. Here is how he configured it.

Firstly, only one non-base utility was used – dns/dnsmasq, a lightweight DHCP and DNS server. Everything else is in the base system.

Overall steps taken to create a functional FreeBSD AP with a wired connection are:

  • Configure the network interface
  • Configure firewall and NAT
  • Configure dnsmasq

Step-by-step wifi-access-point set up

netboot.me – Netbooting over the internet

netboot.me is a service that allows you to boot nearly any operating system or utility on any computer with a wired internet connection – without having to know ahead of time what you’ll want to boot. Once you can netboot.me, you never need to update your boot disk again!

netboot.me works through the magic of netbooting. There are a number of ways to boot a computer with netboot.me. The simplest is to download a bootable image and burn it to a CD, USB memory stick, or floppy disk. Boot off it on any networked computer, and it will automatically fetch the latest boot options from netboot.me and let you choose from dozens of installation, recovery, testing, portable desktop and other tools. You can also start netboot.me from any computer running gPXE, or from any netbootable computer with some simple tweaks to your DHCP server. (source: netboot.me)

FreeBSD netboot installers can be downloaded from the FreeBSD netboot page

New BSD Licensed debugger: D

D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. Special attention is given to the needs of quality assurance, documentation, management, portability and reliability.

The D language is statically typed and compiles directly to machine code. It’s multiparadigm, supporting many programming styles: imperative, object oriented, and metaprogramming. It’s a member of the C syntax family, and its appearance is very similar to that of C++. Here’s a quick list of features.


EuroBSDCon 2009

ukuugThe U.K. Unix and Open Systems User Group (UKUUG) is hosting the EuroBSDCon 2009 in Cambridge from 18-20 September. The conference by many seen as the annual get-together for the European BSD community.

The conference runs over three days starting with many tutorials.

  • Tutorial 1: Kirk McKusick’s FreeBSD Overview, and a focus on FileSystems and VM
  • Tutorial 2: Building the network you need with PF – Peter Hansteen
  • Tutorial 3: SCTP Introduction and Workshop – Randall Stewart

On the second and third day there will be talks on various BSD systems related talks (FreeBSD, NetBSD and PC-BSD).

The BSD Certification Group (BSDCG) will be taking exams on these days too.

Check the EuroBSDCon website for prices, directions, time tables ets

S0urce: www.bsdevents.net (check the BSD calendar for any BSD related events in your area).

Keeping FreeBSD up-to-date

Richard Bejtlich wrote four years ago an article titled Keeping FreeBSD Up-To-Date. His goal was to document various ways that a FreeBSD 5.2 system could be updated and upgraded using tools from that time, in an example-drive way that complemented the FreeBSD Handbook.

He has now an updated version that starts with a FreeBSD 7.1 RELEASE system and ends by running FreeBSD 7.2-STABLE.

Sections included are:

  • Introduction
  • FreeBSD Handbook
  • The Short Answer
  • Understanding FreeBSD Versions
  • Learning About Security Issues
  • Starting with the Installation
  • Installing Gnupg and Importing Keys
  • Installing Source Code
  • Installing CVSup
  • Applying Kernel Patches Manually
  • Applying Userland Patches Manually
  • Using CVSup to Apply Patches
  • Using Csup to Apply Patches
  • FreeBSD Update to Upgrade FreeBSD within Versions
  • STABLE: The End of the Line for a Single Version
  • What Comes Next?
  • Conclusion

Download the Keeping FreeBSD Up-To-Date PDF. Richard appreciates any comments and feedback.

Anyone who updates FreeBSD using CVSup through an HTTP Proxy, have a read here.