Forum Moderators: bakedjake
My first foray into linux is about to begin. I'm going to pick up two 250gig hd's and install them in my older pc. I want to turn it into a file/print server with linux, and have one drive mirror the other.
Can anyone recommend a linux install that would be able to handle that? I don't want to setup a raid array necessairly, just have the main hard drive cloned onto the extra hard drive automatically (or as automated as possible).
If anyone is doing this already, let me know!
#!/bin/bash
cd /
if [! -e "/mirror/etc" ]; then
echo "/mirror does not seem to be mounted."
exit 1
fi
cd /
rsync --archive --verbose --perms --delete --hard-links \
--exclude=/mirror \
--exclude=/media \
--exclude=/mnt \
--exclude=/dev \
--exclude=/proc \
--exclude=/sys \
--exclude=/misc \
--exclude=/net \
--exclude=/var/named/chroot/proc \
--exclude=/var/lib/nfs/rpc_pipefs \
. /mirror
There are problems with raid like this though (you can end up with two copies of bad data). If that's your concern, then rsync as noted above is the way to go. Set up correctly, rsync will copy all files over during the first copy, then only changed files after that. You can set it up as a cron job once a day or a couple of times a day, and exclude files like log files.
I do both. Raid locally (mostly just because I can) and then I pretty much clone my entire drive offset every night. It's the offsite clone and archives that allow me to sleep at night.
It's all good and well mirroring a disk via rsync but what if the master disk fails? Can you just remove it, move the second disk to be the master and add a brand new disk as the new mirror?
This is something I have not found out how to do. With windows I run ghost every week to duplicate disks. If the main disk fails I just remove it and boot from the ghosted disk.
I cheated by cloning it like this:
Install Linux on the primary drive
Mirror the partition table and boot loader like this for IDE drives:
dd if=/dev/hda of=/dev/hdb bs=1k count=10
Or like this for SCSI or SATA drives:
dd if=/dev/sda of=/dev/sdb bs=1k count=10
Reboot
Format the partitions on the secondary drive
I ended up installing ClarkConnect, which is working great. The only thing is that instead of showing two seperate hard drives, it shows one large volume (as in both drives together).
I don't know much about partitioning and just left the defaults in.
Is it possible to seperate the drives without having to re-install linux?
The only thing is that instead of showing two seperate hard drives, it shows one large volume (as in both drives together)
What is the size of the one volume? Is it the size of the two drives combined, or the size of only one drive?
With RAID mirroring you are NOT going to see two seperate volumes in the OS.
If the size of the volume is the size of both drives combined, sounds like you installed with RAID 0 (striping). You wanted RAID 1 (mirroring). In that case, you'll have to start over.
Raid 0 is basically concatenation of drives - making a bunch of disjoint drives into one large drive. That's what you've done. It increases your disk size at the expense of probability of failure (your entire data is now dependent on two drives probability of failing instead of just one).
Raid 1 is effectively mirroring of two drives. If you have two 100 gig hard drives, your total space ends up being 100 gigs. Everything is written to both drives at the same time. The intention is that if one drive dies, the second drive will continue to work, you can pull the bad drive, stick in a new one, the good drive will replicate to the new drive and you're going again. How well this works in reality is debatable.
I would not use raid as a backup or archive practice. It's OK for mission critical servers across many drives but do not use raid as your primary backup method.
To prevent downtime and to secure your data from loss, you should use both RAID (software RAID 1, mirroring, is fine) and backup your data to something external to the server, preferrably offsite. If you can't back it up offsite, then onsite is better than nothing. RAID 1 with two internal drives, and a single USB drive with a cronjob setup to copy data, is usually sufficient.