Personal.X-Istence.com

Bert JW Regeer (畢傑龍)

Sick hackery -- FreeBSD's GEOM is awesome

I was really bored. Which normally results in some destructive thing happening to something I am playing with. This time it was Some of the hard drives in my FreeBSD box. Just a little back-story:

/dev/ad0 - 20 GB
/dev/ad1 - 40 GB
/dev/ad2 - 100 GB
/dev/ad3 - 60 GB
/dev/da0 - 8 GB
/dev/da1 - 8 GB

So, I had already made a gstripe(8) out of the two SCSI drives, da[1|2], however I wanted to see if I could do the same with ad[1|2|3]. As I did not want to resort to gvinum, which is rather heavy, and I was unable to figure out how it worked. The entire point behind gstripe is that since it is striped, the writes/reads are faster since it writes/reads to all the drives at the same time. So first I tried:

gstripe label -v st1 /dev/ad1 /dev/ad2 /dev/ad3

That however complained that it would only use 40 GB's on all of the drives, since the smallest drive in the collection was 40 GB. I then read up on gconcat(8), which concatenates all the drives together to look like one big drive, without the speed improvement of striping. So I figured, since FreeBSD's gstripe is GEOM based, it should not care about what the underlying data sink is, just that it is a device, so just maybe this could work:

gconcat label -v gb100 /dev/ad1 /dev/ad3

So now I had created a 100 GB "hd" at /dev/concat/gb100. I now did what I was planning to do:

gstripe label -v st1 /dev/ad2 /dev/concat/gb100

No problem! :-D. I now had 180.48 GB, of which only about 166 GB was usable. Which is still excellent. As it still came with a speed improvement. Followed up with the standard advice from the handbook I did the following:

bsdlabel -wB /dev/stripe/st1
newfs -U /dev/stripe/st1a
mount /dev/stripe/st1a /mnt

Which got me the following:

/dev/stripe/st1a    180G    5.5G    161G     3%    /mnt

Full:

Filesystem          Size    Used   Avail Capacity  Mounted on
/dev/ad0s1a         496M     63M    393M    14%    /
devfs               1.0K    1.0K      0B   100%    /dev
/dev/ad0s1e         496M    230K    456M     0%    /tmp
/dev/ad0s1f          15G    2.2G     11G    17%    /usr
/dev/ad0s1d         1.4G    115M    1.2G     9%    /var
/dev/stripe/st0a     16G    4.0K     15G     0%    /usr/scsi
/dev/stripe/st1a    180G    5.5G    161G     3%    /mnt

w00tage. Next up I might actually add gdbe(8) or geli(8) even in front of the stripe, so that I will have an encrypted stripe. Talk about stacking. Might give gvinum a try sometime :P

All working:

keyhole# gconcat status
        Name  Status  Components
concat/gb100      UP  ad1
                      ad3
keyhole# gstripe status
      Name  Status  Components
stripe/st0      UP  da0
                    da1
stripe/st1      UP  ad2
                    concat/gb100