Avoiding Device Confusion in FreeBSD with ZFS

Avoiding Device Confusion in FreeBSD with ZFS

January 25, 2012 in FreeBSD

In tutorial after tutorial, I find people creating zpools using a method that looks like:

% zpool create tank /dev/da2 /dev/da3 /dev/da4 /dev/da5

But, what happens when you reboot without /dev/da2 plugged in? /dev/da3 becomes /dev/da2 and your pool is confused and weird and all that junk.

A simple tip is to create a GPT on each disk you plan to add to a pool and rather than using the device node of /dev/da#p#, use the GPT partition ID device node that’s automatically created under /dev/gptid.

First, wipe the partition table on each of your disks, using:


% dd if=/dev/zero of=/dev/da2 bs=512 count=1
% dd if=/dev/zero of=/dev/da3 bs=512 count=1
% dd if=/dev/zero of=/dev/da4 bs=512 count=1
% dd if=/dev/zero of=/dev/da5 bs=512 count=1

Now create a new GPT on each disk, using:


% gpart create -s gpt da2
% gpart create -s gpt da3
% gpart create -s gpt da4
% gpart create -s gpt da5

Now create a FreeBSD ZFS partition on each disk. This is easy because we’re only making one partition per disk.


% gpart add -t freebsd-zfs da2
% gpart add -t freebsd-zfs da3
% gpart add -t freebsd-zfs da4
% gpart add -t freebsd-zfs da5

You should now see the gptids listed in /dev/gptid/


# ls -l /dev/gptid
total 0
crw-r----- 1 root operator 0, 126 Jan 23 15:44 1bcdc07f-4603-11e1-bd02-003048bb1b96
crw-r----- 1 root operator 0, 135 Jan 23 15:44 1cf8bda4-4603-11e1-bd02-003048bb1b96
crw-r----- 1 root operator 0, 143 Jan 23 15:44 1da00324-4603-11e1-bd02-003048bb1b96
crw-r----- 1 root operator 0, 151 Jan 23 15:45 1e83229b-4603-11e1-bd02-003048bb1b96

Now simply create your zpool however you like, using the gptid device node instead of the device ID.


# zpool create external \
/dev/gptid/1bcdc07f-4603-11e1-bd02-003048bb1b96 \
/dev/gptid/1cf8bda4-4603-11e1-bd02-003048bb1b96 \
/dev/gptid/1da00324-4603-11e1-bd02-003048bb1b96 \
/dev/gptid/1e83229b-4603-11e1-bd02-003048bb1b96

And check on it…


# zpool status external
pool: external
state: ONLINE
scan: none requested
config:

NAME STATE READ WRITE CKSUM
external ONLINE 0 0 0
gptid/1bcdc07f-4603-11e1-bd02-003048bb1b96 ONLINE 0 0 0
gptid/1cf8bda4-4603-11e1-bd02-003048bb1b96 ONLINE 0 0 0
gptid/1da00324-4603-11e1-bd02-003048bb1b96 ONLINE 0 0 0
gptid/1e83229b-4603-11e1-bd02-003048bb1b96 ONLINE 0 0 0

errors: No known data errors

You can use the gpart utility to see all kinds of data about your partitions as well. This is useful to figure out which gptid belongs to which disk.

ZFS Deduplication on Existing Pool

ZFS Deduplication on Existing Pool

October 12, 2011 in FreeBSD

Similarly to enabling compression on a ZFS partition that already has data, enabling deduplication does not deduplicate the data that already exists. This was a problem for me. To add to the problem, this pool had many partitions and the partitions each had many snapshots, all of which I wanted to preserve.

The only solution seems to be moving all the data away and back. I bought 4 external hard drives, made a storagebomb and away I went. This page has a good description of how to move an entire pool to a different device, preserving all the snapshots and whatnot.

Duplicity & S3

Duplicity & S3

May 23, 2011 in FreeBSD

It works really well and it’s cheap. Try it. Also read: http://andyleonard.com/2009…-of-others/

I’ll post my script here later.

Troubleshooting Roundcube 101

Troubleshooting Roundcube 101

March 10, 2011 in RoundCube

I often idle in the #roundcube channel on Freenode and I’ve come to realize that time after time, I offer exactly the same help to numerous users. There are a few basic tasks that you should make sure you’ve completed before asking in the channel:

1. Read The Config Files!!!

RC’s configuration files are well documented and revisiting that potent, inline documentation can often answer your questions.

2. Enable Logging

If you’re experiencing undesired behavior, 9 times out of 10, the problem is the way you’ve configured RC. There is no way to identify yourself as the problem, without knowing exactly what it is that RC is doing behind the scenes. For that, you need to enable logging.

Just think… If the problem is in the logs, you won’t have to look stupid when you realize you made a typo on the mail server hostname. Less public ridicule is always a good thing!

Make sure your log directory is able to be written to by the web server!

3. READ THE LOGS

The logging is written in plain English. If you don’t know English, you’re probably not reading this page.

4. Google The Error

Now that you have thoroughly read through the log file and see errors indicating what may be wrong with your configuration, you have everything you need to make important inferences. If these inferences aren’t enough to guide you into a working configuration, it’s time for you to Google the error message. Chances are you’ll find somebody who has had the same issue and has since fixed it. If you’re lucky enough, this kind fellow may have posted the solution to your very problem!

5. Still Need Help?

If you’re unfortunate enough to come to this section having completed the previous sections thoroughly, you’ve either missed something (which happens), or you’ve got a problem that people in the channel will be interested to help you solve! All that’s left is for you to present the problem in a well-thought-out form. You should also make sure to mention the steps you’ve performed to try to fix your issue.

Now that you’ve asked your question, you have only one thing left to do — WAIT. Nobody in the channel is paid to support you, so if they’re busy, they may be disregarding the channel. You get what you pay for.

Headless FreeBSD Install

Headless FreeBSD Install

June 1, 2010 in FreeBSD

Ever wanted to install without a keyboard and mouse on the system? Do it over serial console! Here’s how to make a CD that can do it.

Extract the ISO

Get your install ISO from somewhere and extract it to some directory.

mkdir ./iso
tar -C ./iso -pxf 8.0-RELEASE-i386-disc1.iso
cd ./iso

loader.conf

Next thing to do is to tell the boot loader to start using the serial port. This can be done by putting:

console="comconsole"

somewhere inside boot/loader.conf (obviously inside the iso directory)

Make the ISO!

Now wrap it all up into an iso using:

mkisofs -J -r -b boot/cdboot -no-emul-boot -o 8.0-RELEASE-i386-disc1-serial.iso ./iso

or something of the sort.

You’re done!

Go burn the ISO file and boot a system off the CD. Set your terminal’s baud rate to 9600 and you’ll eventually see things booting up!

Copyright © 2009 Christopher J. Umina - Powered by WordPress - Portfolio WordPress Theme by ThemeShift.com.