This is only indirectly Drupal. Its a server I host some of my Drupal sites on.
I have a dedicated server whose hard drive is failing. The host has installed a new one for me to clone my old drive onto. Now I am not a Linux Ninja, and a mistake here could wipe my server, so I want to verify my process before I start.
What I want to do is Clone the existing drive onto the new one (same size) and then reboot. I am looking to do an exact copy so hopefully nothing else would have to change when I am done. So first a bit of info and some then some questions. 'hda' is the old disk and 'hdc' is the new one.
First if anyone has a better procedure (or can point to a website/page that has one) I'd appreciate it.
-
if I do a full physical disk copy will that bring over the partition definitions also? or do I have to do that manually first?
-
First, will the command dd if=/dev/hda of=/dev/hdc conv=noerror,sync do that full physical disk cloning?
-- I believe that the noerror option will keep the command running even if there are errors, but will this still attempt to retry or will it just skip immediately if an error is encountered? Right now it appears to succeed if it retries the I/O so I would prefer that, but of course I don't want it to give up :-)
fdisk -l
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 267 2040255 82 Linux swap / Solaris
/dev/hda3 268 14593 115073595 83 Linux
Disk /dev/hdc: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/hdc doesn't contain a valid partition table
Comments
I would use # dd if=/dev/hda
I would use
# dd if=/dev/hda of=/dev/hdc bs=4096 conv=notrunc,noerrorand next time you wish to backup the partition schema use# sfdisk -d /dev/hda >hdaand to restore you can usecat hda | sfdisk /dev/hdaand or to copy from hda to hdc you can use# sfdisk -d /dev/hda | sfdisk /dev/hdcbut the bigger question and giant request is that you upgrade that kernel to use libata which will give you /dev/sda versus /dev/hda which is highly DEPRECATED in linux.Good luck.
bending technology to fit businesses.
Thanks for the info. Yes this
Thanks for the info. Yes this server is an old one that has needed a major upgrade for a while. Originally it was supposed to get phased out when an old site that needed that environment got upgraded or replaced, and the other sites on it got moved to a newer server. But being a small non-profit they could never make the commitment to get off this old site/server.
This potential mess has given me the way to nudge them into making that decision, or taking over the box for themselves (and there is no way they want to do that). One way or the other, after fixing the hard-drive problem this will either get upgraded or replaced.
I think I will be going with the disk to disk option
but want to a bit more reading on this variation while my last big backup downloads.
Thanks again for your help
Before I did anything...
I'd backup the sites (probably /var/www) and databases (mysqldump or the backup and migrate module) and download them locally. I'd probably also grab /etc as well. This way, worst case scenario, you can reinstall linux onto the new drive and get your sites back up and running.
Thanks for the reminder about
Thanks for the reminder about ' plan B' :-) It's always a god idea to have a 'Plan B'
Thats what I have been doing while I researched my primary option (clone the disk). I've been backing up the critical items and downloading to my local system (just in case). It's not a great option(since rebuilding would take a while), but it does let me recover if something goes totally wrong with the clone/drive
Double Post...
n/t
It looks like there may be
It looks like there may be more to this than I had hoped. So hopefully you can help with a few more questions please.
I did the copy of the partition definition and then the drive itself. Things there seemed to work OK. But upon booting unexpected things began to happen.
[root@zzzzzz]# /sbin/sfdisk -d /dev/hda | /sbin/sfdisk /dev/hdc
Checking that no-one is using this disk right now ...
OK
Disk /dev/hdc: 14593 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/hdc: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/hdc1 * 63 208844 208782 83 Linux
/dev/hdc2 208845 4289354 4080510 82 Linux swap / Solaris
/dev/hdc3 4289355 234436544 230147190 83 Linux
/dev/hdc4 0 - 0 0 Empty
Successfully wrote the new partition table
Re-reading the partition table ...
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
[root@zzzzzz]# dd if=/dev/hda of=/dev/hdc bs=4096 conv=notrunc,noerror
29305206+0 records in
29305206+0 records out
120034123776 bytes (120 GB) copied, 5572.12 seconds, 21.5 MB/s
[root@zzzzzz]#
After reboot off the new drive it would appear that BOTH drives are being referenced as part of Boot process.
Obviously I am missing something someplace. Does linux assume that hda is the default source for fils/partitions if not explicitly pointed elsewhere? If so can I either put the new drive in the hda spot, or what files should I update to point things to hdc?
I've been digging but surprisingly haven't found any doc on how to clone an existing boot drive(failing in my case) to a new physical drive and then switch to that new drive for future boot and operations. While we all hope it doesn't happen that often, being as important as it is, I'm surprised I haven't found anything on the procedure. If you have any pointers to any doc on this is would be appreciated.
As for symptoms:
- I can''t access some sites while others are fine
- can't reach Control panel at https://panel.example.com:8443/ but http://panel.example.com/ gets me the Control panels default no site page
- /etc/fstab does still refer to "LABEL=SWAP-hda2 swap". I'm thinking that there may be more
- probably more
[root@zzzzzz]# /sbin/fdisk -l
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 267 2040255 82 Linux swap / Solaris
/dev/hda3 268 14593 115073595 83 Linux
Disk /dev/hdc: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 * 1 13 104391 83 Linux
/dev/hdc2 14 267 2040255 82 Linux swap / Solaris
/dev/hdc3 268 14593 115073595 83 Linux
disk labels - learning
I'm learning more all the time. Centos(which I am running) appears to use labels to access the disks and got confused by having the same label on both drives. I changed the label on the old drive and rebooted, and it seems that things may be working correctly now. I haven't checked everything yet, but so far it looks good. A whole bunch of items that had failed previously are now working :-)
The command I used
e2label /dev/hdc1 ''(that is two single quote marks, not one double quote mark)