Tuesday, April 3rd, 2007
sfdisk is quite handy
So today I had to basically clone a hard disk from a failing disk, to a new disk Sun had sent for one of the v20z’s at work… Haven’t not had to mess about with partition tables and other such things outside of the installer in linux for some time (last time I did this kind of messing about was with freebsd which uses slices->partitions, unlike linux and it’s mad idea of partitions and extended partitions), so I had to take stock for a short while while I figured out the best way to go ahead. Here’s what I started with :
/dev/sda - main scsi hard disk at scsi id 0
/dev/sdb - new replacement disk at scsi id 1
Saving and restorring the partition table to the sdb was as easy as:
sfdisk -d /dev/sda > /tmp/sda-parttable.out
and then:
cat /tmp/sda-parttable.out | sdisk /dev/sdb
I’d never realised sfdisk could do easy things like that, which saved me some time having to input partition boundries by hand
What next was a bit of a pain was getting files over to the new filesystems (obviously once I had created new filesystems on them and mounted them somewhere easy to use - /mnt/newroot). I had looked at possibly using cpio to do this, and considered dd.
It seemed the best in the end, to create tar archives of the data, so that if I made a mess of the new disk I could at least quickly extract the backups again without too much faff, to do this I simply archived up each partition using something along the lines of:
tar --preserve --one-file-system -vcf /mnt/newroot/root.tar /
this archived the root into /mnt/newroot/root.tar, but diddn’t traverse into new directories, –one-file-system is a pretty handy feature of tar and I’m sure it’ll come in useful again sometime in the future. Tomorrow I’ll update with how easy it was to install the new mbr to sdb and how removing the origional disk and moving sdb to sda’s slot, goes ![]()