Hot Swapping a SATA Disk

On my server, I use a SATA hard drive for backup. This drive is mounted in a bay that allows the raw disk to be plugged into the front of the server. Pressing a button allows the drive to be removed so that it can be taken offsite and another drive put into place. However, it is a bad idea to remove a drive that is in active use; corruption ensues. I created some scripts to allow the drive to be spun down and taken offline, and taken back online.

First create two little text files. I store these in a directory called c:\scripts.

The first file is named offline.diskpart and contains this:

select disk=1
offline disk

The second is named online.diskpart and contains this:

select disk=1
online disk

You may need to change the disk number in these scripts to match your disk. See the diskpart documentation for more info.

Then I create two shortcuts on the desktop with these properties:

Offline Backup

Target: C:\Windows\System32\cmd.exe /k C:\Windows\System32\diskpart.exe /s c:\scripts\offline.diskpart
Start In: C:\scripts

Online Backup

Target: C:\Windows\System32\cmd.exe /k C:\Windows\System32\diskpart.exe /s c:\scripts\online.diskpart
Start In: C:\scripts

When I want to take a disk offline, I click the Offline Backup shortcut. When it reports that the drive is offline, I can remove the drive from the caddy. Clicking the other shortcut puts the disk back online.

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.