On 13/09/2014 04:17, Joseph wrote:
On 09/12/14 23:52, Neil Bothwick wrote:
On Fri, 12 Sep 2014 15:53:19 -0600, Joseph wrote:

I have two identical HD in a box and want to duplicate sda to sdb
I want sdb to be bootable just in case something happens to sda so I
can swap the drives and boot.

Do I boot from USB and run:
dd if=/dev/sda of=/dev/sdb bs=512 count=1

If you remove the cunt argument as already mentioned, this will copy the
whole drive, but it will be incredibly slow unless you add bs=4k. It also
only copies it once, as soon as you start using sda, sdb will be out of
date. Set up a RAID-1 array with the two drives, then install GRUB to the
boot sector of each drive, using grub2-install and you will always be
able to boot in the event of a failure of either drive.


--
Neil Bothwick

I'll be interested in setting up RAID-1. Is it hard?
I've never done it and I know there is plenty of information on line
about RAID-1

I'm not going to grub2 anytime soon.  This machine has BIOS and the HD
has MBR partition.
With recent problem I had with my other older box (that has BIOS) and
grub2 I'm not going to play with it.

Is it hard to set it UP RAID-1

No, it is not. However, to keep things simple, observe the following:

  * create the array with the --metadata=0 option (using mdadm)
  * mark the partitions belonging to the array as type FD
  * enable CONFIG_MD_AUTODETECT in the kernel

Doing so will ensure two things. Firstly, that the legacy version of grub is able to read the kernel. Unlike grub2, it does not intrinsically understand RAID. Using the original metadata format prevents that from being an issue; grub can be pointed to just one of the two partitions belonging to a RAID-1 array and read its filesystem.

Secondly, using the original metadata format means that, once the kernel has loaded, it is able to assemble the array by itself. Therefore, you may have your root filesystem on the array and mount it without having to use an initramfs.

In terms of partitioning, you could just create one big partition on each drive, join them into an array, and make that the basis of a root filesystem. As much as Gentoo has enshrined the concept, a dedicated boot filesystem is simply not necessary and swap can be created as a file. Alternatively, you could follow the handbook style and create three arrays for boot, swap and root.

There is a trick to achieving bootloader redundancy. Let's say that you have set up array /dev/md0, with /dev/sda1 and /dev/sdb1 as its members, and that /dev/md0 contains a singular root filesystem. In the grub shell, one would run these commands:

  grub> device (hd0) /dev/sda
  grub> root (hd0,0)
  grub> setup (hd0)
  grub> device (hd0) /dev/sdb
  grub> root (hd0,0)
  grub> setup (hd0)

The magic here is that the bootloader will still be able to function, even if a disk is removed or broken.

Finally, even though your disks are not exactly the same size, it does not matter. If there is a discrepancy among the devices that mdadm is given to create an array with, it will size the array according to the lowest common denominator. If you prefer, you can manually ensure that the partitions are the exact same size on both disks.

--Kerin

Reply via email to