Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a general purpose (mail, web, file, etc) server running on a small mixed (Windows/FreeBSD) network. I'm not pleased with how I laid out the disk originally and since it's rather out of date anyway I intend to simply reinstall the entire machine and fix every little annoyance while I'm at it.

I've been using gjournaling on other machines and I'm pleased with it. I know how to set up new partitions so that they contain both journal and data, and I know how to create a journal for an existing partition on a newly created partition. I still have a couple of questions left about gjournal before I get started on the machine:

  1. How do I create partitions to contain both journal and data during the FreeBSD install, if I have to create a seperate journal partition for each partition I will hit the limit of 8 partition letters.

  2. I know it's safe to mount filesystems async when journaling, but do people mount the root file system async as well while journaling or is this unwise?

  3. Is it possible to journal an entire slice at once? This would save the trouble of significantly increasing the size of my root, /var and several other small partitions to actually have enough space to store the journal data.

share|improve this question

2 Answers 2

Just a suggestion for 1. - use gpt table, it supports up to 26 partitions

For 3. - you can gjournal whole disk at once (data from here)

PS. And anyway you should try this all from some VM like VirtualBox.

PPS. May be you should try ZFS?

share|improve this answer

After some messing around I did finally find a way to accomplish what I want some time ago, but forgot to update my question here. In the future (beginning of October) I'm replacing the entire machine and indeed switching to ZFS. In the mean time I'll post my solution here so other people might use it.

The solution is to make the filesystem to install to from within FreeBSD. I was unable to load the gJournal kernel module from the fixit disk, so I installed a basic install to an USB stick. After wiping the entire disk I was going to install on I booted the machine from the USB stick.

The first step was to load the gJournal kernel module with "gjournal load" and then labeling the disk I was going to install on (/dev/ad0) "gjournal label ad0". You should now see a /dev/ad0.journal entry inside /dev. The next step is to write a boot sector to this disk with bsdlabel. In case of my amd64 system this was "bsdlabel -wBm amd64 ad0.journal", for the specifics for your system see the bsdlabel(8) manual page. I proceeded to edit the labels with bsdlabel as you normally would changing the disk lay out, but using /dev/ad0.journal where you would normally use /dev/ad0. I ended up specifying the following lay-out in bsdlabel -e ad0.journal:

# size offset fstype [fsize bsize bps/cpg]
a: 256M    16 4.2BSD   2048 16384
b:   2G     *   swap
c:    *     * unused
d:   2G     * 4.2BSD   2048 16384
e: 512M     * 4.2BSD   2048 16384
f:   6G     * 4.2BSD   2048 16384
g:    *     * 4.2BSD   2048 16384

The specific sizes you require will differ of course. After specifying these partitions /dev/ should show the various /dev/ad0.journala through /dev/ad0.journalg entries. Now we can format the new filesystems using newfs(8). I used UFS2 with labels so I could refer to /dev/label/<label> in /etc/fstab instead of the disk device. The command I ran was newfs -O 2 -J -L rootfs /dev/ad0.journala, -O 2 uses UFS2, -J turns on journaling on a specific partition and -L rootfs names /dev/ad0.journala to /dev/label/rootfs. Do not forget that you might want to disable journaling on for instance the /tmp partition, in that case don't pass the -J flag for those partitions. Even though they are on the journaled disk, GEOM will only journal UFS systems which signal whether data being written is meta-data or not which only happens for filesystems created with -J or for which you turn on journaling manually via tunefs(8).

Now the tricky part is over and we just need to install the OS to our freshly created journaled filesystem, I simply used the install disk. Since we already created our filesystem the CD installer cannot be used. Instead simply mount the CD from within the USB install, then mount the newly created root filesystem somewhere (I'll use /tmp/newinstall as mountpoint here). Then mount all the other partitions you created inside /tmp/newinstall as /var, /usr and whatever else you partitioned. Next set the environment variable DESTDIR to this new path (export DESTDIR=/tmp/newinstall).

Now change directory to where you mounted the install CD, on the CD you'll find a folder named after the FreeBSD version you downloaded, inside this folder there are several folders each containing an install.sh file, run each of these scripts (you have to specify the kernel GENERIC as an argument to the install script in the kernel directory).

After this is done, do not forget to copy/move /tmp/newinstall/boot/GENERIC to /tmp/newinstall/boot/kernel or you will find the system can't find a kernel to boot. Last but not least edit /tmp/newinstall/boot/loader.conf and add the line geom_journal_load="YES" to load gjournal support at boot time, you can (and must) remove this line if you compile a custom kernel with gJournal support included (the required options for this are options UFS_GJOURNAL and options GEOM_JOURNAL).

The very last thing that remains to be done is creating an /tmp/newinstall/etc/fstab file that mounts the required partitions at boot time. You can either specify /dev/ad0.journala devices or the /dev/label/rootfs and other labels you provided. Details on the syntax and options for the file can be read in fstab(5)'s manual page. Keep in mind that with journaling it is now "safe"[1] to mount your filesystems async. Also note that while journaled devices don't need fsck you should still fill in the fsck column in the fstab file. If you do not, your system WILL NOT BOOT. The system recognizes journaled disks and treats them differently in the automated fsck checks, instead running the appropriate checks for a journaled system.

[1] - Safe means your filesystem will not be corrupted by a crash while journaling. Data that has not been written to disk at the time of the crash can still be lost, for instance if it's being buffered by the OS or the disk. Data can remain in these buffers for quite a while.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.