Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Aug 2007 15:52:53 -0400
From:      "Maxim Khitrov" <mkhitrov@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   Need clarification on file system parameters (using newfs).
Message-ID:  <26ddd1750708101252o531bf67g17e1bcf9095cdc73@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hello,

I'm installing FreeBSD 7.0 (200606 snapshot) on my laptop just to play
around with it out, and I wanted to learn a little bit more about the
way FreeBSD organizes the available disk space. Let me tell you what I
think I understand about it, and I ask that you please correct me if
something is wrong or elaborate a bit more on how everything is
related.

So first of all, what I'm going to do is use geli full-disk encryption
and boot the system from a usb drive. I have an 80GB hard drive, which
also has Win XP installed on it. I allocated 20 gigs for windows,
about 5 gigs for a shared FAT32 partition in case I need to transfer
files between Windows and FreeBSD, and the rest is a geli-encrypted
bsd partition. So that's what I want to ask about.

As I understand it, a disk is divided into 512 byte sectors, and that
is the smallest addressable unit of space. I'll use geli to initialize
the entire third partition, bsdlabel it, and finally create all the
file systems. Geli offers an option to change the default sector size
for better performance, and the recommendation is to use 4KB. Am I
correct in assuming that if I do this, then all file systems using
this encrypted volume will have 4KB as the smallest addressable unit
of space?

Once I've created my geli volume, I attach it, label it, and use newfs
to prepare everything for use. By the way, this is a bit off-topic,
but how does 1GB for /, 2GB for swap (I have 1GB of ram), 1GB for
/var, and the rest for /usr sound? I plan to symlink /home to
/usr/home and that way have plenty of space for user data and
installed software. I haven't done this type of setup before, so
thought I'd ask if it is a good idea.

Anyway, I'm looking through newfs man page and see several terms that
I'm not exactly familiar with. Or rather I am familiar with them, but
am not sure how they relate to the finished product (i.e. my file
system). First there is the block size set by default to 16KB, and
fragment size set to 1/8 of block size. I'm assuming that a block is a
group of sectors, but how does fragment size fit into the picture?
Does FreeBSD take X number of sectors, make them into a block, and
then divide each block into fragments?

If so, since the underlying geli layer is using 4KB for sector size,
would it make sense for me to modify block and fragment sizes to
something a bit bigger? I guess what I'm really unsure about is say I
create a file with 1 byte of data in it. What gets allocated? Does
that file take up an entire block, or does it get a single fragment?
If fragment, then what is the purpose of blocks?

There is also the -i option which sets "density of inodes in the file
system". It also states that "one inode is required for each distinct
file," so when set to 4 * frag-size with frag-size being 2KB, does my
1 byte file end up taking 8KB in the end?

If you can, please help me link all these parameters together so I can
get a picture of how the file system is actually organized. Also,
given what you know about my setup, I'd appreciate any advice for
tuning these values to get the best performance for a laptop (i.e.
optimized for running user programs as opposed to daemons).

Thanks,
Maxim Khitrov



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?26ddd1750708101252o531bf67g17e1bcf9095cdc73>