Tuesday, December 16, 2008

FreeNAS 0.7.3953, RAID 1, growfs... oh my!

Fooling around in VMWare, preparing to build my two NAS boxen, I started playing with disk upgrade scenarios in a two-drive RAID 1 configuration. I have the embedded FreeNAS on /dev/ad0, and the two mirror disks are /dev/ad2 and /dev/ad3. First, I had them both at 512MB each, then bumped one to 1GB, fixed the mirror, then bumped the other to 1GB and fixed the mirror again. At this point, I had two 1GB disks with a 512MB (give or take) mirror since it was sized from the initial installation with two 512MB disks. Time to figure out growfs...

I tinkered around with growfs, finally got it to work, and ended up with a mirror to match the size (more or less) of the actual disks. Now, let's do it again to make sure it wasn't a fluke! I bumped one disk to 2GB, rebuilt the mirror, then bumped the other disk to 2GB, rebuilt mirror, thus leaving me with a pair of 2GB disks and a 1GB mirror. Then I followed the growfs process again and took some notes this time, here for your reading pleasure.

NOTE -- This worked for me and I make no guarantees, express or implied, that it will work for you. If you follow my instructions, you may come through this just fine, or you may not. Always back up your data before starting on something like this, and understand the commands you are using and what the impact is. If you can, play in a VM sandbox for a while until you are comfortable.


Notes



At this point, I shutdown the FreeNAS VM and replaced /dev/ad3, which was 1GB, with a 2GB disk to match /dev/ad2.

1. At the web gui, edit the /dev/ad3 disk and just click on 'Save' and the new size will be picked up automatically.

2. The raid is still degraded, as expected, so do the 'replace disk' dance...
  • edit the raid1 array
  • click on 'tools', then choose RAID1 (volume name) and command 'forget' and click on 'Send Command!'
  • click on 'tools', then choose RAID1 (volume name), disk ad3, command 'insert', and click on 'Send Command!'
  • go back to the raid1 management tab and the status should be COMPLETE once the mirror is rebuilt
3. The mount point should be in 'Error - Retry' state right now, so click on Retry to ensure that it mounts ok.

[root@freenas ~]# 
[root@freenas ~]#
[root@freenas ~]# df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/md0 80430 74634 5796 93% /
devfs 1 1 0 100% /dev
/dev/md1 31470 12 28942 0% /var
/dev/ad0a 39406 34216 5190 87% /cf
/dev/mirror/RAID1p1 888526 69300 748144 8% /mnt/NAS1
[root@freenas ~]#
[root@freenas ~]#


4. At this point, the mount is back online with the old 1GB mirror size, so let's get into the meat of it.

5. Go back to the mount point configuration and delete the mount point

6. Go to the raid management and delete the raid1 array

7. Add a new raid 1 array, which I will call RAID1, and choose 'create and initialize RAID' option, then click on 'Add'

8. Next, head to the beloved (for me, anyway) CLI via SSH and do the hardcore stuff...

[root@freenas ~]# 
[root@freenas ~]#
[root@freenas ~]# mount
/dev/md0 on / (ufs, local)
devfs on /dev (devfs, local)
/dev/md1 on /var (ufs, local, union)
/dev/ad0a on /cf (ufs, local, read-only)
[root@freenas ~]#
[root@freenas ~]#
[root@freenas ~]#
[root@freenas ~]#
[root@freenas ~]# df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/md0 80430 74612 5818 93% /
devfs 1 1 0 100% /dev
/dev/md1 31470 12 28942 0% /var
/dev/ad0a 39406 34216 5190 87% /cf
[root@freenas ~]#
[root@freenas ~]#
[root@freenas ~]#
[root@freenas ~]#
[root@freenas ~]# cd /dev/mirror
[root@freenas /dev/mirror]# alias ls='ls -al'
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# ls
total 1
dr-xr-xr-x 2 root wheel 512 Dec 16 16:40 .
dr-xr-xr-x 5 root wheel 512 Dec 16 16:40 ..
crw-r----- 1 root operator 0, 81 Dec 16 16:40 RAID1
crw-r----- 1 root operator 0, 85 Dec 16 16:40 RAID1p1
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt remove -i 1 /dev/mirror/RAID1
gpt remove: /dev/mirror/RAID1: error: no secondary GPT header; run recover
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt recover /dev/mirror/RAID1
gpt recover: /dev/mirror/RAID1: recovered secondary GPT table from primary
gpt recover: /dev/mirror/RAID1: recovered secondary GPT header from primary
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt show /dev/mirror/RAID1
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 2097084 1 GPT part - FreeBSD UFS/UFS2
2097118 2097152
4194270 32 Sec GPT table
4194302 1 Sec GPT header
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt remove -i 1 /dev/mirror/RAID1
/dev/mirror/RAID1p1 removed
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt show /dev/mirror/RAID1
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 4194236
4194270 32 Sec GPT table
4194302 1 Sec GPT header
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt add -i 1 -t ufs /dev/mirror/RAID1
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt show /dev/mirror/RAID1
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 4194236 1 GPT part - FreeBSD UFS/UFS2
4194270 32 Sec GPT table
4194302 1 Sec GPT header
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt show -l /dev/mirror/RAID1
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 4194236 1 GPT part - "RAID1"
4194270 32 Sec GPT table
4194302 1 Sec GPT header
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt label -i 1 -l RAID1 /dev/mirror/RAID1
/dev/mirror/RAID1p1 labeled
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt show /dev/mirror/RAID1
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 4194236 1 GPT part - FreeBSD UFS/UFS2
4194270 32 Sec GPT table
4194302 1 Sec GPT header
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# gpt show -l /dev/mirror/RAID1
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 4194236 1 GPT part - "RAID1"
4194270 32 Sec GPT table
4194302 1 Sec GPT header
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# growfs /dev/mirror/RAID1p1
We strongly recommend you to make a backup before growing the Filesystem

Did you backup your data (Yes/No) ? Yes
new file systemsize is: 1048559 frags
Warning: 262076 sector(s) cannot be allocated.
growfs: 1920.0MB (3932160 sectors) block size 16384, fragment size 2048
using 15 cylinder groups of 128.00MB, 8192 blks, 16384 inodes.
with soft updates
super-block backups (for fsck -b #) at:
1835168, 2097312, 2359456, 2621600, 2883744, 3145888, 3408032, 3670176
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# mount
/dev/md0 on / (ufs, local)
devfs on /dev (devfs, local)
/dev/md1 on /var (ufs, local, union)
/dev/ad0a on /cf (ufs, local, read-only)
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/md0 80430 74612 5818 93% /
devfs 1 1 0 100% /dev
/dev/md1 31470 12 28942 0% /var
/dev/ad0a 39406 34216 5190 87% /cf
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#


9. Ok, go back to the webui and create the mount point again, then check the size either via the webui or via 'df' from your ssh session and you should be at full capacity.

[root@freenas /dev/mirror]# 
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]# df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/md0 80430 74614 5816 93% /
devfs 1 1 0 100% /dev
/dev/md1 31470 12 28942 0% /var
/dev/ad0a 39406 34216 5190 87% /cf
/dev/mirror/RAID1p1 1904078 69300 1682452 4% /mnt/NAS1
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#
[root@freenas /dev/mirror]#

Thursday, February 14, 2008

Hamcation!

Yeah, we went camping at Hamcation again this year, and it was a good time except that I forgot to bring my sleeping bag and pillow. This year, we started a day early and drove over on Thursday about noon and checked-in after a quick side trip to Skycraft. Arriving at Hamcation early this year was pretty nice, but we had a little pressure getting the campsite set up due to impending storms which, fortunately, never materialized. Compared to last year, the temperature was warmer and it was a great time for all of us (KI4OFU (me), KG4YNI, KI4EFN, AF1RE, KI4OFV (my wife)). I didn't find any cheap Soekris SBCs this year, dang it all, but I did pick up a few goodies. The biggest was a new ICOM IC-2820H with the D-Star/GPS board. This is a beautiful radio, and now I get to learn all about how D-Star works. I also picked up a TRSB for my Buddipole, as well as the Rotating Arm Kit. Other miscellaneous goodies from here and there filled out the annual shopping spree, and it was a lot of fun. Let me take a minute to tell you how much I like ICOM. Not necessarily the radios, though I do adore my IC-7000 and I think the same will be true for this IC-2820H pretty soon, but the company itself. I have a young son, 2.5 years old, and the comic books that ICOM publishes are a great way for me to read to my son about amateur radio and get him interested in it. I know it's smart business for them to appeal to a younger generation for the future of the hobby and consequently future hardware sales for them, but they stand out because they are doing that and I don't see a hint of that kind of youth-oriented material from either Yaesu or Kenwood. Go ICOM! Our club had a swap table set up again this year with tons of junk on it, both donated to the club and also consigned by club members. I would say that about 1/2 of it was sold and the other 1/2 given to other vendors on Sunday afternoon because we didn't want to haul any of it back to Lakeland. Either way, it was good revenue for the club. I think that when Hamcation 2009 comes around, we will probably still camp but might do it in the travel trailer rather than in the tent. Also, staying on Saturday night, which we didn't do in 2007, was not optimal this year since by mid-morning on Sunday most of the vendors were packing up and getting ready for the trip home. Yeah, I think that next year we may pack up camp when we get up on Saturday morning and then make one final good day of it before heading home. We'll see.

Wednesday, February 6, 2008

NanoBSD - part 1

Wow, where do I start. Last year, I picked up a few Soekris net4521 boards from the Orlando Hamcation. The guy didn't know what he had and sold them to me for $10 each. Nice. I tinkered around with them a little bit last year and got some help with kernel, world, and package building for the NanoBSD image from Bruce Mah. I had built up a nice image on a 512MB CF card and played for a bit, but then life came charging back in and I had to shelve the project for a while.

Now I am back, and here is some stuff to chew on. First, here is a short shell script that I wrote and dropped into /usr/src/tools/tools/nanobsd to evaluate the packages in /usr/src/tools/tools/nanobsd/Pkg and determine if there were any missing dependencies before starting the image building process.

#!/bin/sh
#
# make packages for /usr/src/tools/tools/nanobsd/Pkg:
# if the port is already installed:
# cd /usr/src/tools/tools/nanobsd/Pkg && pkg_create -vyb netcat-1.10_2
# if the port is not installed:
# cd /usr/ports/net/netcat && make package && mv \
# /usr/ports/packages/All/dnsmasq-2.38.tbz /usr/src/tools/tools/nanobsd/Pkg/
#
#
# next, run this script to ensure that you aren't missing any deps for the packages
# you want in your image.
#
# after that, you can run `sh nanobsd.sh -c nanobsd-soekris.conf` to build a new image
#
# or, if you are just adding/removing packages to the existing image, you can
# run `sh nanobsd.sh -b -c nanobsd-soekris.conf` to save the time of building world
# and kernel.
#

cd /usr/src/tools/tools/nanobsd

rm -f pkg_deps.list

cd /usr/src/tools/tools/nanobsd/Pkg

for each in *.tbz;
do
pkg_info -r ${each} | grep Dependency | cut -d' ' -f2 | while read dep
do
/bin/ls -1 | grep ${dep} >/dev/null || echo "${each} needs ${dep}" >>/usr/src/tools/tools/nanobsd/temp.$$
done
done

cd /usr/src/tools/tools/nanobsd

[ -f temp.$$ ] && (cat temp.$$ | sort | uniq >pkg_deps.list && rm -f temp.$$)

That works pretty well. After ensuring that my package list was good to go, I started the build process and it went well. Much thanks need to go to Poul-Henning Kamp for his work on the NanoBSD infrastructure, it's just simply wonderful.

Right now, I am using a Soekris net4521 as my firewall, running off of a little 12v DC wall-wart, instead of the old power-sucking 400w AC-powered tower that I was using. Saving power and money, which are good things, and now I have moved from using IPFW/IP6FW on that old tower to using PF on this Soekris. More about using PF later!

Thursday, January 31, 2008

cacti, cactid -> spine; nanobsd

Hmm, been a while since I upgraded my cacti & cactid ports on my FreeBSD machines, and found that the cactid has been renamed to spine. Yay. Took me a while to notice that the smoke-ping-like Advanced Ping wasn't working with ICMP and even longer to remember why and how to fix it. Had to chmod the spine exec to 4555 (setuid, and yes it's evil) so that it would have the necessary permission to open the socket(s) to send ICMP. Maybe I will remember to check here when the port is renamed again and save myself some time!

I've also been working on a fresh nanobsd build for my Soekris SBCs, and I can't thank Bruce Mah enough for his help earlier last year when I was having some build issues. I had it working after consulting with him last year, but have had many other irons in the fire since then and am just now getting back into this particular project. Ultimately, I want to replace my power-sucking FreeBSD-based firewall with this 12v DC, CF-based storage Soekris board. I will get around to a more detailed post in a few days, I hope.

Wednesday, January 30, 2008

Radio Net Etiquette

Just a little vent for today. I had recently slipped out of the habit of checking into the NI4CE NTS net each evening at 20:30 local time, but now that I am getting back into the habit, I am finding the same irritation that caused me to lose interest before. Other operators who key up their mic and start transmitting non-stop to Net Control without first dropping to see if they are the only station to key up. There are a couple folks in particular who do this incessantly and I figure it's because they don't know any better, and who am I to call them out? It's not like there is some law or regulation that states that they must unkey and verify that they aren't unnecessarily doubling with another station, but you'd think that after hearing so many other stations exercise the same good practice that these folks would attempt to do the same. Alas, they are oblivious and continue forward.

I really peaked last night when a piece of traffic was destined for my city and I was ready to take the traffic. As soon as Net Control called for my county and cleared the repeater, I keyed up and said "Net Control", then unkeyed as usual (for me, anyway) to ensure that I wasn't violating someone else's prior transmission, and as usual one of these one-shot bandits completed their entire check-in and was able to take the traffic. Totally ticked me off, especially because we get so little traffic anymore and it's difficult to keep skills sharp when traffic is so light. Bah.

Friday, January 25, 2008

DD-WRT and IPv6

Yesterday, I took what I thought was a step forward for a long-ignored Linksys WRT54G v3.0 (SN: CDF80E553386) and upgraded from v23 SP2 to v24 RC 6.2, but what a mistake (for me, anyway). I lost IPv6 functionality and that was a killer for me. So, I spent the next couple of hours working backwards through various releases, trying to restore IPv6 functionality. Here's a breakdown:

No IPv6 Support:
DD-WRT v24 RC-6 (01/02/08) std
(SVN revision 8743)

DD-WRT v24 RC-6 (01/02/08) std
(SVN revision 8743)
(this is really the "generic_nokaid" version)

DD-WRT v23 SP3 (12/21/06) std
(SVN revision 5366)
(what's up with the snowflakes?)


IPv6 support restored with the above version, sans kaid, noted below:
DD-WRT v23 SP3 (12/21/06) std
(SVN revision 5366)
(this is really the "nokaid" version)


So, I don't really understand why the versions report themselves to be the same from the browser console, even though they are using a different feature set (if that's the right term). Speaking in terms of feature set, a system like Cisco uses in their IOS would be useful to distinguish between the versions. It's great that the firmware file name is different, but from the web interface, you don't really know which feature set you are using (std, std_nokaid, generic, etc.). Oh well.

For those interested, here are the commands I used to enable IPv6 in the WRT54G using the above firmware (v23 SP3 std nokaid from 2006-12-21). You can set this up for boot-time configuration by navigating to "Administration" -> "Commands", entering the two below commands into the text box, and then click on "Save Startup" button.

(watch for word-wrap on these two commands)
ip -6 addr add 2001:4830:2502:8001::a00:3/64 dev br0
ip -6 route add default via 2001:4830:2502:8001::1 dev br0

Not to bash Linux at this point, but I sure do *LOVE* the way all of the IPv6 configuration in FreeBSD has been integrated into the usual tools (ifconfig, netstat, etc.).