Menu
His Majesty The King
  • Home
  • Forum
  • Contact Me
  • Advertise
  • About Me
His Majesty The King

HOWTO: Replacing a Failing Drive on a FreeBSD System

Posted on January 29, 2009July 5, 2019 by The King
The other evening I found myself in the horrible position of seeing my server spit out disk errors like there was no tomorrow. Not willing to risk the machine going down when I would not be around I took a quick trip to the office supply store and picked up a new SATA drive.

The server I am using is new and I added a second drive to it before I brought it online. My feeling was that the /home partition would likely grow very large so why not beef it up by giving it its very own drive? It was a good idea and how was I to know that the drive I purchased would begin to fail in less than 30 days?

The first step in replacing a drive gone bad is to purchase a new drive. Drives are very cheap these days so I always look at the performance rather than the storage capacity. Even though this drive is going into a web server I know that I do not need 1TB of storage.

I settled on a 500GB Seagate drive with a 16MB cache that runs at 7200RPM. This drive set me back about $100 and would have been cheaper if I purchased it online but, I was under pressure so I paid extra for the convenience.

When you have a bad drive it is important to replace it as soon as you can. As long as the drive can be read most of your data should be recoverable. In my case the errors I was getting had to do with writing to the drive not with reading from it.

One of the first things I did was run fsck to check both drives. While the primary drive checked out fine the drive I used for /home was full of errors.

With drive in hand I opened up the case on my server after shutting it down. I pulled the old drive out and mounted the new one in its place.

After rebooting I went into single user mode and ran fdisk to get the disk ready. I set it to use the entire disk and created one slice on it. After fdisk I ran disklabel and set it to be used as /home. I then proceeded to shutdown the server so that I could reconnect the old /home drive.

After rebooting I once again entered single user mode and mounted the old drive as /oldhome. From here it was a simple matter of issuing the following cp command:

cp -r -p /oldhome/* /home

We use -r so that cp will copy directories and we use -p to insure all the permissions and ownerships stay the same. If I had not used -p all the copied files would have become owned by whatever account I used to copy them with. Since I was logged in as root all of those files would have become owned by root. On a webserver this would prevent all those files from being readable by apache, mail, mysql, etc...

After all the files were copied I rebooted the server and made sure everything came up. With everything working I then quickly took the server down to remove the bad drive.

I have had no problems since. Facebooktwitterredditpinterestlinkedinmail
  • Server
  • Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    *

    code

    Tags

    Advertising Apple Blogging Board Games Campaign Card Games Cats D&D Digg DS Fail Fallout Fallout 3 Family Fiction FWE Google Heroes Humor Make Money Online Movies News Nintendo Opinion PC Pokemon Politics PS3 Review Rockwars Role Playing Games RPG Server Social Media Star Wars Stocks Story The Dice Tower Tom Vasel TV Video Games Weird Wii Wordpress xBox 360
    January 2021
    S M T W T F S
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  
    « Sep    

    Popular Posts

    • Building a town with MySims

      I have been spending the last week or two with EA's new MySims game for th...

    • Wii Sports Golf: Tips and Tricks

      So, you think you know how to play golf? You think you can just grab that...

    • .
      Dungeons and Dragons 5E Cantrips – Fire Bolt

      Now that I have returned to the realm of Dungeons and Dragons I find mysel...

    • Warhammer 40K: Lt. Varas

      I've been working on painting the miniatures that came with the WarHammer...

    • .
      Painting the UltraMarines

      I've been working on painting the miniatures that came with the WarHammer...

    • .
      Pokemon Ranger: Manaphy Egg?

      The Feb 2007 issue of Nintendo Power magazine mentions a special Egg you c...

    • .
      Dungeons and Dragons 5E Cantrips – Dancing Lights

      Dancing Lights is very useful when cast as a tactical spell. While it can n...

    • Wii Fit: The Unboxing

      As I mentioned in my earlier post today my copy of Wii fit arrived via UPS...

    • Pokémon Trading Card Game (TCG): Rumble

      On December 2, 2009 Pokemon International released the Pokémon Trading Car...

    • The Wii goes NASCAR

      No your eyes are not deceiving you that is indeed a NASCAR car with the Wi...

    Recent Posts

    • Papers Please!
    • Dungeons and Dragons 5E Cantrips – Dancing Lights
    • Can’t Run an App in Windows 10? Try System File Checker
    • The Beefed Up Gunners Project
    • Fallout 4 – Evan, part 1
    ©2021 His Majesty The King | Powered by WordPress & Superb Themes