|
I had a spare 40GB 2.5" laptop hard disk hanging around, so I decided to use it in conjunction with a USB cradle as a backup device for my laptop. This is an elegant solution I think, for a few reasons:
- The USB cable powers the hard disk. One may need to connect both ends of the provided Y split cable to separate USB ports to double the available power to nominally 1A. However for my laptop and hard drive combination at least, a single USB port suffices.
- The laptop hard disk in the device while generally not having the storage capacity of desktop or server (3.5") hard disks, will be more resilient to movement and power loss.
- In the near future internal laptop "hard disks" will be based on flash technology, and the generally larger/cheaper traditional laptop (2.5") hard disks will be even more suited to backup.
$ sudo /sbin/hdparm -t /dev/sdb /dev/sdb: Timing buffered disk reads: 64 MB in 3.03 seconds = 21.10 MB/secUnlike my previous laptop which only supported USB 1.1:
$ sudo /sbin/hdparm -t /dev/sda /dev/sda: Timing buffered disk reads: 4 MB in 4.18 seconds = 980.52 kB/secIn addition to backup I would also like to allow using this device as a handy way of transporting data between systems. I primarily use linux, but I didn't want to preclude the option of using this device with windows systems. Therefore I put a single VFAT or FAT32 partition on the hard disk, which both windows and linux can write to. Note Microsoft artificially limit the size of a FAT32 partition one can create on windows systems to 32GB, to "encourage" people to move to NTFS. On linux though you can create a VFAT partition (with mkfs.vfat -F 32 /dev/sdb1) as large as you like (up to the 40GB capacity of my hard disk in this case) which windows can use fine. Note also that Macintosh Operating System 10.3.x or earlier will only recognize FAT32 partitions that are smaller than 128GB. 10.4.x or later recognize larger partitions.
A fundamental limit of VFAT which one can't work around is the maximum file size of 4GB. My backup script below handles this by splitting the data into multiple files. It also encrypts the data before writing to disk.
#!/bin/sh dir=/media/disk/laptop_backup base=laptop.tar.gpg. mkdir -p $dir if [ ! -d "$dir" ]; then echo "Error: couldn't initialise $dir" >&2 exit 1 fi tar c /home /root /etc 2>/dev/null | # Note gpg compresses internally gpg -c | ( cd $dir && { rm -f $base* split --bytes=4095m - $base #vfat limit } )The corresponding script to restore to the current directory is:
#!/bin/sh dir=/media/disk/laptop_backup base=laptop.tar.gpg. cat $dir/$base* | gpg --decrypt | tar xNote before unplugging the cradle from the linux computer one should of course unmount it. In addition I also issue a "stop" command to the drive using sdparm, so that it does a controlled head park with power still applied. Otherwise a capacitor or spring internal to the drive is used to perform an emergency head park, which will increase the ware on the drive. Good quality laptop hard disks are rated for 20,000 emergency unloads and around 600,000 normal unloads, while desktop and server hard disks generally are rated for much less than this. Both these operations are shown in the following simple script.
#!/bin/sh umount /dev/sdb1 sdparm --readonly --command=stop /dev/sdb && sleep 5 #disk needs time to spin down
© May 31 2006