Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] duplicate HD drives Kerin Millar <kerframil@×××××××××××.uk>