Race Report: St James 5-Miler

I have a friend who started running on a treadmill over the winter. We got to talking about some of the races I did late last year and he told me he’d be interested in trying some in 2011. Shortly after that, he sent me the information about this race, held on April 16. At first glance, I thought it was a 5K, not a 5-miler, so I thought it would be a good first race for him.

As the date approached, he then sent me a map of the course. At this point, I realized not only was it 5 miles, but a hilly race with a big climb towards the end. I told him I thought it would be totally fine if he wanted to skip it, but he decided to tackle it.

It was about as tough as I expected. All my runs have been on the south shore of Long Island where it is very flat. I have no experience with hills and that was a bit of a problem for me. I was mostly happy with my performance on the climbs but it was the steep downhill runs that surprised me. At first, I let physics have its way, and flew down the hills at top speed. However, at times, it felt as if I was somewhat out-of-control. Also, my feet were slamming into the pavement pretty hard and I was passing a lot of people. It made me feel as if I was doing something inadvisable and possibly dangerous, so I started to try and control my descent.  However, I could tell that slowing myself was using a lot of energy. At this point, I was confused; should I be using more energy to run slower during a race?

I say I was mostly happy with my performance on the hills because there was one really long climb at the end that killed me. From about the 3.3-mile point to the 4.3 mile point is one tough climb up Cordwood Path. This hill kicked my butt. I was running only a little behind my normal pace and then got beaten badly by this climb. I finished at 41:06 whereas I had conservatively estimated I could finish it in under 40 minutes.

Despite this being a tough run, I want a rematch. I fully intend on running it again next year. The post-race spread behind the firehouse was on par with any of the races I’ve done. We waited through the raffle, but didn’t stick around for the awards ceremony because the temperature was only in the 40s and the wind was picking up, which made it pretty uncomfortable for damp running clothes.

My friend finished the race several minutes behind me. Considering he had never run on the road before, I thought he did really well. He noted that since he got the toughest race out of the way first, everything else should seem easy by comparison.

Posted in Running | Tagged | Comments Off on Race Report: St James 5-Miler

Race Report: Race for Spinal Victory 2011

Ok, so I’m really late with this post. I wasn’t planning on turning this into a running blog, so I was thinking I should limit the running posts and not report on all the races I’m doing. I really wanted to make more technical and programming-related posts, but I’m spending much more of my free time on running-related things these days.

Also, when deciding which races I want to do, I find race reports helpful, so hopefully, when these events roll around next year, someone out there will find my reports helpful.

Anyway, this event was held on April 10, 2011. The start and finish were at Wantagh High School. I was very curious about the route because it was advertised as having only 4 turns.  I could think of several ways you could do a 5K with a start and finish at the high school, but with only 4 turns?

We started north on Daffodil Lane and the first turn is a right on Jerusalem Ave. The second turn is a right on Wantagh Ave. We ran all the way down to the train station where the third turn hooked us back up north. The final turn was a left on Beltagh, taking us back to the High School.

This race was on par with the other local events I’ve done. It was well-organized, plenty of food and water were provided and I was impressed with how Wantagh Ave was closed that whole stretch. For me, this race is automatic for next year, but I’m biased because this race had something special in store for me.

I wasn’t feeling 100% when I woke up that morning and very briefly flirted with the idea of skipping it. I ended up getting there a little late and arrived just in time to line up and start. Luckily, I had picked up my racing bib and chip the day before.

The hard winter had upset my running schedule for months and just as the cold and snow began to subside, I injured my left Achilles tendon. Soon after it got better, I caught a bad cold. By the beginning of April, I was back on my regular schedule, but I noticed my times were off from December, when I had put up some nice personal records.

As a result, my confidence was not very high; I ran a conservative race and I didn’t think much of my 23:32.7 result.

I hung around for the awards and raffle, totally unprepared for what was about to happen…

When they announced my age group, they called off the name of the first place finisher, then for second place, they called my name!

I’ve never come close to the top three at any of these events and I didn’t look closely enough at the results posted after to race to realize I was second in my age group. I walked up and got my medal in a complete state of  surprise and shock.

I’ll readily admit my age group was a bit soft that day, but I have put a hell of a lot of work into running the past two years, so getting some hardware to show for it was really awesome.

I’ve done a couple of more races since then, which I will post about soon.

Posted in Running | Tagged , | Comments Off on Race Report: Race for Spinal Victory 2011

Welcome, C++ 2011!

Herb Sutter, the chair of the ISO C++ standards committee, reports that C++ 2011 is finally a standard!

I had the rare privilege of meeting and learning from Herb at one of his Effective Concurrency courses last summer. In addition to being a terrific instructor and author, he’s also amazingly friendly and approachable. Congratulations Herb, and of course, the rest of the committee!

I’m already using portions of C++0x C++ 2011 in my latest personal project thanks to Visual C++ 2010’s partial support. So far, I really like working with it and I’m already looking forward to the availability of more features.

I’ve seen complaints that this latest revision steepens the C++ learning curve, but I have to disagree. I can attest that C++ 2011 has already made my code simpler.  Getting into specifics will turn this into a very long post, though, so you doubters will have to take my word for it for now.

Posted in C++ | Tagged | Comments Off on Welcome, C++ 2011!

apcupsd to the rescue!

We had some fierce wind here today and a little after 10 this morning, the power went out. I had configured apcupsd to properly shut down the server, but I never actually tested it.

Setting up apcupsd was so straightforward, I didn’t even bother posting about it. Basically, you can install it using apt-get and configure it by editing /etc/apcupsd/apcupsd.conf.  The file has a simple layout and the comments are very helpful.

When I got home from work, I powered the machine (named governor) back on, checked /var/log/syslog and was happy to find this:

Feb 25 10:14:41 governor apcupsd[2350]: Power failure.
Feb 25 10:14:41 governor kernel: [1421562.103162] r8169 0000:00:0b.0: eth0: link down
Feb 25 10:14:41 governor kernel: [1421562.149510] usb 1-5: USB disconnect, address 2
Feb 25 10:14:47 governor apcupsd[2350]: Running on UPS batteries.
Feb 25 10:14:58 governor apcupsd[2350]: Reached run time limit on batteries.
Feb 25 10:14:58 governor apcupsd[2350]: Initiating system shutdown!

... more messages from various things shutting down ...

Perfect!  Oh wait — it was great that it shut down properly, but just this short part of the log tells an interesting story.

First

Feb 25 10:14:41 governor kernel: [1421562.103162] r8169 0000:00:0b.0: eth0: link down

My switch is not on a UPS, so eth0 lost its link. No biggie.

Second

Feb 25 10:14:41 governor kernel: [1421562.149510] usb 1-5: USB disconnect, address 2

The USB drive I’m using as a backup wasn’t plugged into the UPS. This is easily fixed.

Third

It powered off after only 10 seconds? That’s because I set TIMEOUT 10 in /etc/apcupsd/apcupsd.conf, thinking the value was in minutes. It says seconds right there in the helpful comments. Silly me. Fixed.

By the way, I set this timeout value on the assumption that if the power is out for more than 10 minutes, it’s probably going to be out for a while. This machine only serves two people, it is not critical that it stays up for a long as possible during a power outage.

Oh and just for reference, I check the status of the UPS with the apcaccess status command.

Also, ironically, these lines appear in the log just before the power failure:

Feb 25 08:52:26 governor apcupsd[2350]: UPS Self Test switch to battery.
Feb 25 08:52:34 governor apcupsd[2350]: UPS Self Test completed: Battery OK

It passed a self-test a little more than an hour before it got a real test.

Posted in Linux | Tagged , , | Comments Off on apcupsd to the rescue!

Home Server Migration Complete!

As mentioned in several of my previous posts, I recently switched my home server from Windows Server 2003 to Ubuntu Linux 10.10.

The machine is an old bare-bones Shuttle SK21G system equipped with the cheapest processor I could find 5 or 6 years ago and only 1GB of RAM. The processor is a 1.6GHz Sempron I’m pretty sure I bought new for about $40.

Primarily, it is a file server. Between my wife and I, we have a desktop and a laptop and we commonly share files. Why not just share everything from the desktop? Well, I like my desktop to just be a desktop.  I just want to use it for hobby work and play games.  I don’t want to leave my computer on all the time, I don’t want to sit next to a noisy array of disks and I don’t want to load it down with server daemons.

Samba (SMB) is used to share files with Windows, and as it turns out, setting up SMB on Ubuntu is pretty easy. Amazingly, connecting to and browsing files on this machine with Linux and Samba is much faster than Windows’ native file sharing.

Ironically, while I was mulling over the Linux switch, I discovered, completely by accident, that one of the disks had failed! While it was great that the system kept running and I ended up with no downtime or data loss, it was somewhat unsettling that there were no alerts of any kind.

Now, With mdadm monitoring my mirror, I get e-mailed if a problem occurs. I tested it, it works.

Wait, there’s more — and this is my favorite part — a couple of years ago I realized that a RAID is not a backup, so I hung a 1 TB external USB drive off the machine and had Robocopy run a nightly mirror.  I also enabled Volume Shadow Copy as a measure against accidental overwrites and deletions. However, what I really wanted was Time Machine, and now, I finally have it thanks to rsync and rsnapshot.

This machine may still be a dinosaur, but thanks to Ubuntu Server 10.10, it’s now a fire-breathing, bad-guy-eating, tyrannosaur with robot gun arms. It just barely meets the minimum specs for Windows Server 2003, but handles Ubuntu with ease.

It will be useful having a Linux install around to mess with and, best of all, the whole setup was fun.

Posted in Linux | Tagged , , , | Comments Off on Home Server Migration Complete!

Testing a failure on my RAID1 array

When I configured my Ubuntu system to boot from a software RAID1 array, Postfix came with it. I needed to setup Postfix to pass messages to my Internet e-mail address. Luckily, David Grant seems to have already figured that part out.

sudo dpkg-reconfigure postfix

After selecting satellite, the only info I needed to supply was my ISP’s SMTP server. I accepted the defaults for everything else. My ISP wouldn’t accept e-mail from my machine either, so I had to perform the steps in the update section of his post. For completeness this is:

Adding this to /etc/postfix/main.cf:

smtp_generic_maps = hash:/etc/postfix/generic

and creating a /etc/postfix/generic with this in it:

@ubuntu_server ubuntu_server@jfamiglietti.com

Interestingly enough, the domain name actually needed to exist for my ISP’s mail server to accept it, so I used my own. (My server’s name is not actually ubuntu_server, it’s just an example)

… and yes, don’t forget:

sudo postmap /etc/postfix/generic

Anyway, back to my simulated failure. All I had to do was set my e-mail address in the MAILADDR field of my /etc/mdadm/mdadm.conf.

This was enough to kill my setup:

sudo mdadm --manage /dev/md0 --fail /dev/sdb1

Almost immediately, I got an e-mail from “mdadm monitoring” informing me of the failure. I removed the “bad” drive from the array:

sudo mdadm --manage /dev/md0 --remove /dev/sdb1

Since there is really nothing wrong with it and it’s already partitioned correctly, I just added it back and let it sync up.

sudo mdadm --add /dev/md0 /dev/sdb1

I did need to reinstall grub because when I disconnected /dev/sda, it booted to the grub rescue prompt

sudo grub-install /dev/sdb

When I attempted to boot it again with /dev/sda missing, I got an e-mail. Like everything else I’ve attempted with this Linux server so far, it worked perfectly!

Ok, I’ll let you in on a little secret. I didn’t do that on my actual server, I tested it in my VirtualBox machine. On my actual server, I performed the same setup for Postfix, then just issued this command to ensure the e-mail was working:

sudo mdadm --monitor --scan --test

After sending the test message, mdadm continued monitoring the array, so I had to stop it with a control-C. Successfully getting the test message was good enough for me, I really just wanted to know mdadm could get messages out when necessary.

Posted in Linux | Tagged , | Comments Off on Testing a failure on my RAID1 array

Migrating Perforce from Windows to Linux

I had Perforce running on my server when it was a Windows machine. I like Perforce, but I’m liking Git even more right now. I can’t just ditch Perforce, though, my project histories are in there and I’d rather not throw that away.

Before shutting Windows down for good, I carefully followed steps 1-9 outlined in this article. Step 10 is a very important one, read the linked document carefully to understand the case-related problems. I found it surprising that Windows Perforce servers only uses lowercase names in the revision archives. This makes p4migrate necessary and important.  Honestly, I can’t break down the process any better than Perforce, just follow the steps and you’ll be fine.

After letting p4migrate produce a new, modified checkpoint and letting it rename my version archives, I did the line-ending conversion in step 11. Then, I was able to run the restore process and fire up the server.

I should also mention that I made sure to download the same version of the Linux Perforce server as was previously running on Windows.

I also want to mention that I still like Perforce; I’m switching because I think Git will suit me better. Perforce Software is a top-notch company with fantastic support and a great product. I’ve been using their free 2-user server for almost 6 years and I expect I will continue using it at my day job (where we have a fully-licensed server) for the foreseeable future.

Posted in Linux, Perforce | Tagged , , | Comments Off on Migrating Perforce from Windows to Linux

Setting up SMB on Ubuntu is pretty easy

I switched my old Shuttle box from Windows Server 2003 to Ubuntu Linux 10.10. The server’s main purpose is to serve files, so SMB is a necessity.

Just as I did when I setup the RAID, I perfected the procedure on a VirtualBox virtual machine before attempting it on my shiny new Ubuntu install.

While connected to the Internet, get SMB by simply issuing this command:

sudo apt-get install samba smbfs

Edit smb.conf…

sudo cp /etc/samba/smb.conf /etc/samba/smb.master.conf
sudo nano /etc/samba/smb.master.conf

adding this…

[global]
workgroup = your_workgroup
security = user
[shared]
comment = Test shared samba folder
path = /smbshares/shared
writable = yes
create mask = 0660
directory mode = 0770
force group = smbusers
locking = yes
hide unreadable = yes

Apparently, the best way to produce a real smb.conf is with testparm. I ran it in my home directory:

testparm -s /etc/samba/smb.master.conf smb.conf

After reviewing the resulting smb.conf, I copied it to /etc/samba.

Also, I needed to add this to /etc/security/limits.conf

* - nofile 16384

In order to remove this warning:

rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)

I added myself as an SMB user:

sudo smbpasswd -a john

Also, I created an smbusers group and added myself to it

sudo addgroup smbusers
sudo usermod -a -G smbusers john

Since all files added through the SMB share will have the smbusers group and the permissions mask will permit full access to that group, I will simply add other users that group.

Make sure to chown the group owner of the shared folder to smbusers and chmod it 775.

Finally, I restarted the service…

sudo service smbd restart

.. and put a test file in my test shared folder. It works!

Not only does it work, but it’s really fast.

Nice!

Posted in Linux | Tagged , , | Comments Off on Setting up SMB on Ubuntu is pretty easy

Booting Ubuntu 10.10 Server from software RAID

I recently switched my home server from Windows Server 2003 to Ubuntu 10.10. The machine is an older Shuttle box I’ve had tucked away in various places over the past few years.

The plan was to disable the BIOS “fakeRAID”, install Ubuntu on one of the drives, copy my data over to it and then have the other disk join the new Linux software RAID array.  I figured out the procedure on a VirtualBox before attempting it on my actual machine.

Install the server with NODMRAID and partition the drive with no LVM, that is partition with “Guided – use entire disk”. We can’t have devicemapper getting in the way.

Install on first hard disk (/dev/sda).  If there’s any data you need off the other disk, now’s the time to mount it and copy it over.

To start, we need the mdadm package.

sudo apt-get install mdadm

You need two modules to be loaded at boot-time, raid1 and md.  In the kernel included with Ubuntu 10.10, md was compiled in, so I didn’t need to worry about loading it as a module.

I verified this by checking the kernel’s config:

fgrep CONFIG_MD /boot/config-$(uname -r)

Add the module raid1 to the /etc/raid1

sudo nano /etc/modules

Let’s load the raid1 module

sudo modprobe raid1

To ensure it is loaded:

lsmod | grep raid1

So, it seems we’re ready for prepare our other disk. A neat little trick is to use sfdisk to dump the partition table of one disk to configure another.

sudo sfdisk -d /dev/sda > sda.out
sudo sfdisk /dev/sdb < sda.out

but sfdisk responds with “I don’t like these partitions – nothing changed.”  Well, excuse me, sfdisk, but I don’t like your attitude. (Yes, I’m arguing with a disk utility now) So, I added the –force flag.  It grudgingly copied the partition table for me.  I verified it by comparing the output of sfdisk -l /dev/sda and sfdisk -l /dev/sdb.

Change the partition type of the Linux partition(s) to “Linux raid autodetect”

sudo sfdisk --change-id /dev/sdb 1 fd

We’re ready to create the array. We specify a RAID 1 array with 2 devices. The first is missing and the second is /dev/sdb1:

sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1

Now, we need an mdadm.conf. It seems like the way to do this is with

sudo cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.oldconf
sudo cp /etc/mdadm/mdadm.conf mdadm.conf
mdadm --detail --scan >> mdadm.conf

It will put in a parameter metadata=00.90 that will cause warnings later. Apparently, this is a bug and it is safe to remove it.  After editing it, I copied back to where it belongs.

sudo cp mdadm.conf /etc/mdadm/mdadm.conf

Now, we format the raid volume

mkfs -t ext4 /dev/md0

Find out the UUID of the array

sudo blkid

Make a copy of /etc/fstab in your home directory and change root to mount to the UUID of the array.  Don’t change the real /etc/fstab quite yet.

Add a custom setup in GRUB2, I’m going to edit a copy of this file in my home directory too.

cp /etc/grub.d/40_custom 09_swraid1_setup
nano 09_swraid1_setup

Details here, but here’s what I added to my file:

menuentry 'Ubuntu, with Linux 2.6.35-22-server' --class ubuntu --class gnu-linux --class gnu --class os {
        recordfail
        insmod raid
        insmod mdraid
        insmod ext2
        set root='(md0)'
        linux   /boot/vmlinuz-2.6.35-22-server root=/dev/md0 ro   quiet
        initrd  /boot/initrd.img-2.6.35-22-server
}

This differs from the linked article in that ‘2.6.35-22-server’ is my kernel release version (the one that ships with Ubuntu server) and I’m booting from md0.

Back to the physical console.

sudo telinit 1

Copy the above temp files (fstab and 09_swraid1_setup) to their actual locations

update-grub

Adjust ramdisk

update-initramfs -u

Ensure GRUB2 is on /dev/sdb and sda

grub-install /dev/sdb
grub-install /dev/sda

Mount the array on /tmparray

mount /dev/md0 /tmparray
rsync -aqxP / /tmparray

Restart and we have now booted off the array!

Change the partition type of sda now

sudo sfdisk --change-id /dev/sda 1 fd

Add it to the array:

mdadm --add /dev/md0 /dev/sda1

Welcome to the party, /dev/sda! Let’s watch it sync:

watch cat /proc/mdstat

Our special GRUB entry is no longer needed

rm -f /etc/grub.d/09_swraid1_setup
update-grub
update-initramfs -u

Done.

I worked out the kinks in the virtual machine and documented it in a draft of this post.  I used it as my guide when performing the install on the actual machine. It worked perfectly.

Update, Feb 25, 2011: Clarification in response to comments.

Posted in Linux | Tagged , , | Comments Off on Booting Ubuntu 10.10 Server from software RAID

Creeping up an unfortunate list

The Mets are much higher on this list of MLB franchises with the longest current World Series crown drought than I would have guessed. I guess 1986 is getting to be a relatively long time ago. I can’t believe is 2011.

At least I can still remember what it was like. Sorry Cub fans.

Posted in Baseball, Mets | Tagged , | Comments Off on Creeping up an unfortunate list