Gentoo Archives: gentoo-user

From: Joseph <syscon780@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] duplicate HD drives
Date: Sat, 13 Sep 2014 16:31:52
Message-Id: 20140913163157.GD13628@syscon7
In Reply to: Re: [gentoo-user] duplicate HD drives by Kerin Millar
1 On 09/13/14 08:07, Kerin Millar wrote:
2 >On 13/09/2014 04:17, Joseph wrote:
3 >> On 09/12/14 23:52, Neil Bothwick wrote:
4 >>> On Fri, 12 Sep 2014 15:53:19 -0600, Joseph wrote:
5 >>>
6 >>>> I have two identical HD in a box and want to duplicate sda to sdb
7 >>>> I want sdb to be bootable just in case something happens to sda so I
8 >>>> can swap the drives and boot.
9 >>>>
10 >>>> Do I boot from USB and run:
11 >>>> dd if=/dev/sda of=/dev/sdb bs=512 count=1
12 >>>
13 >>> If you remove the cunt argument as already mentioned, this will copy the
14 >>> whole drive, but it will be incredibly slow unless you add bs=4k. It also
15 >>> only copies it once, as soon as you start using sda, sdb will be out of
16 >>> date. Set up a RAID-1 array with the two drives, then install GRUB to the
17 >>> boot sector of each drive, using grub2-install and you will always be
18 >>> able to boot in the event of a failure of either drive.
19 >>>
20 >>>
21 >>> --
22 >>> Neil Bothwick
23 >>
24 >> I'll be interested in setting up RAID-1. Is it hard?
25 >> I've never done it and I know there is plenty of information on line
26 >> about RAID-1
27 >>
28 >> I'm not going to grub2 anytime soon. This machine has BIOS and the HD
29 >> has MBR partition.
30 >> With recent problem I had with my other older box (that has BIOS) and
31 >> grub2 I'm not going to play with it.
32 >>
33 >> Is it hard to set it UP RAID-1
34 >
35 >No, it is not. However, to keep things simple, observe the following:
36 >
37 > * create the array with the --metadata=0 option (using mdadm)
38 > * mark the partitions belonging to the array as type FD
39 > * enable CONFIG_MD_AUTODETECT in the kernel
40 >
41 >Doing so will ensure two things. Firstly, that the legacy version of
42 >grub is able to read the kernel. Unlike grub2, it does not intrinsically
43 >understand RAID. Using the original metadata format prevents that from
44 >being an issue; grub can be pointed to just one of the two partitions
45 >belonging to a RAID-1 array and read its filesystem.
46 >
47 >Secondly, using the original metadata format means that, once the kernel
48 >has loaded, it is able to assemble the array by itself. Therefore, you
49 >may have your root filesystem on the array and mount it without having
50 >to use an initramfs.
51 >
52 >In terms of partitioning, you could just create one big partition on
53 >each drive, join them into an array, and make that the basis of a root
54 >filesystem. As much as Gentoo has enshrined the concept, a dedicated
55 >boot filesystem is simply not necessary and swap can be created as a
56 >file. Alternatively, you could follow the handbook style and create
57 >three arrays for boot, swap and root.
58 >
59 >There is a trick to achieving bootloader redundancy. Let's say that you
60 >have set up array /dev/md0, with /dev/sda1 and /dev/sdb1 as its members,
61 >and that /dev/md0 contains a singular root filesystem. In the grub
62 >shell, one would run these commands:
63 >
64 > grub> device (hd0) /dev/sda
65 > grub> root (hd0,0)
66 > grub> setup (hd0)
67 > grub> device (hd0) /dev/sdb
68 > grub> root (hd0,0)
69 > grub> setup (hd0)
70 >
71 >The magic here is that the bootloader will still be able to function,
72 >even if a disk is removed or broken.
73 >
74 >Finally, even though your disks are not exactly the same size, it does
75 >not matter. If there is a discrepancy among the devices that mdadm is
76 >given to create an array with, it will size the array according to the
77 >lowest common denominator. If you prefer, you can manually ensure that
78 >the partitions are the exact same size on both disks.
79 >
80 >--Kerin
81
82 If I do:
83 fdisk /dev/sda
84 t 1 fd
85
86 Won't it destroy data on /dev/sda?
87
88 --
89 Joseph

Replies

Subject Author
Re: [gentoo-user] duplicate HD drives Alan McKinnon <alan.mckinnon@×××××.com>