Entries Tagged as 'Linux'

Backing up your MBR

MBR stands for Master Boot Record. It is the part of your hard drive that tells where the partitions on that drive are located. It is also the part of your drive that becomes worthless if you try to install Windows on your hard drive after Linux. Of course, i have never done this … more than twice.

So i came across a poor soul that had done this and wished he had kept a backup of his MBR and it got me thinking “i could automate that,” because I hate to do something like this more than once. So I wrote a quick bash script to handle the issue.

#!/bin/sh

SAVETO=”/etc”

# Do ATA drives
for DRIVE in `ls -l /dev/hd* 2>/dev/null | grep -v [0-9]$ | grep disk | cut -d”/” -f3`
do
dd if=/dev/$DRIVE of=$SAVETO/mbr-$DRIVE bs=512 count=1
done

# Do SCSI drives
for DRIVE in `ls -l /dev/sd* 2>/dev/null | grep -v [0-9]$ | grep disk | cut -d”/” -f3`
do
dd if=/dev/$DRIVE of=$SAVETO/mbr-$DRIVE bs=512 count=1
done

Obviously, there is a whole lot that could be done to improve the script (error checking, user notification, overkill), but if you aren’t already backing up your MBR, start here. Throw it into a cronjob and forget it – cron.monthly not cron.hourly.

Download it here.

  • Share/Bookmark

(un)Necessary Chatter

Why in the world do I need a blog? There are millions of them out there, some of them are even good. So why do I need a blog?

Like everyone else, I have something to say. At this point I’m not sure what that “something” is though.

And like everyone else, what I have to say is different, even in the most miniscule way, from what everybody else is saying.

So, I expect that I will post on here programs and scripts that I create, usually for Linux, though I have one of those boxes here too. I expect that I will post my views on society, which I have found rapidly changing lately. I’m positive that I will post my views on God and religion (they aren’t the same you know) as well.

I’m also hoping that my wife will post her thoughts and pictures here as well.

If that interests you, check back and comment. If not, that’s OK too.

  • Share/Bookmark