| 71 | |
| 72 | == packages == |
| 73 | * sudo aptitude install -R mdadm |
| 74 | * -R が無いと postfix を同時インストールされる |
| 75 | * sudo aptitude install lvm2 |
| 76 | * sudo aptitude install drbd8-utils -R |
| 77 | * -R が無いと build-essential 等を同時インストールされる |
| 78 | |
| 79 | == setup block devices == |
| 80 | |
| 81 | === fdisk === |
| 82 | * mitty@ubuntu-haa:~$ ls -l /dev/sd? |
| 83 | {{{ |
| 84 | brw-rw---- 1 root disk 8, 0 2011-03-24 17:20 /dev/sda |
| 85 | brw-rw---- 1 root disk 8, 16 2011-03-24 17:20 /dev/sdb |
| 86 | brw-rw---- 1 root disk 8, 32 2011-03-24 17:20 /dev/sdc |
| 87 | }}} |
| 88 | |
| 89 | * mitty@ubuntu-haa:~$ sudo fdisk -u /dev/sdb |
| 90 | {{{ |
| 91 | |
| 92 | Command (m for help): n |
| 93 | Command action |
| 94 | e extended |
| 95 | p primary partition (1-4) |
| 96 | p |
| 97 | Partition number (1-4): 1 |
| 98 | First sector (63-4194303, default 63): |
| 99 | Using default value 63 |
| 100 | Last sector, +sectors or +size{K,M,G} (63-4194303, default 4194303): +2000M |
| 101 | |
| 102 | Command (m for help): t |
| 103 | Selected partition 1 |
| 104 | Hex code (type L to list codes): fd |
| 105 | Changed system type of partition 1 to fd (Linux raid autodetect) |
| 106 | |
| 107 | Command (m for help): p |
| 108 | |
| 109 | Disk /dev/sdb: 2147 MB, 2147483648 bytes |
| 110 | 255 heads, 63 sectors/track, 261 cylinders, total 4194304 sectors |
| 111 | Units = sectors of 1 * 512 = 512 bytes |
| 112 | Sector size (logical/physical): 512 bytes / 512 bytes |
| 113 | I/O size (minimum/optimal): 512 bytes / 512 bytes |
| 114 | Disk identifier: 0x7faa0456 |
| 115 | |
| 116 | Device Boot Start End Blocks Id System |
| 117 | /dev/sdb1 63 4096063 2048000+ fd Linux raid autodetect |
| 118 | Partition 1 does not end on cylinder boundary. |
| 119 | |
| 120 | Command (m for help): w |
| 121 | The partition table has been altered! |
| 122 | |
| 123 | Calling ioctl() to re-read partition table. |
| 124 | Syncing disks. |
| 125 | }}} |
| 126 | * 同じ容量のHDDでも、メーカによって微妙にサイズが異なることがあるので、交換する際のことを考えるとディスク全体をパーティションに割り当てない方が良い |
| 127 | * mitty@ubuntu-haa:~$ sudo fdisk -u /dev/sdb |
| 128 | {{{ |
| 129 | Disk identifier: 0x509a8b0b |
| 130 | |
| 131 | Device Boot Start End Blocks Id System |
| 132 | /dev/sdc1 63 4096063 2048000+ fd Linux raid autodetect |
| 133 | Partition 1 does not end on cylinder boundary. |
| 134 | }}} |
| 135 | |
| 136 | === mdadm === |
| 137 | * mitty@ubuntu-haa:~$ sudo mdadm --create /dev/md0 -l1 -n2 /dev/sd[bc]1 |
| 138 | {{{ |
| 139 | mdadm: array /dev/md0 started. |
| 140 | }}} |
| 141 | |
| 142 | * mitty@ubuntu-haa:~$ cat /proc/mdstat |
| 143 | {{{ |
| 144 | Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] |
| 145 | md0 : active raid1 sdc1[1] sdb1[0] |
| 146 | 2047936 blocks [2/2] [UU] |
| 147 | [>....................] resync = 0.2% (4160/2047936) finish=8.1min speed=4160K/sec |
| 148 | |
| 149 | unused devices: <none> |
| 150 | }}} |
| 151 | |
| 152 | * mitty@ubuntu-haa:~$ sudo mdadm -D /dev/md0 |
| 153 | * see [./log#mdadm-Ddevmd0] |
| 154 | |
| 155 | * mitty@ubuntu-haa:~$ sudo mdadm -Es |
| 156 | {{{ |
| 157 | ARRAY /dev/md0 level=raid1 num-devices=2 UUID=32578407:6f33f50b:893cf340:745f5dce |
| 158 | }}} |
| 159 | * mitty@ubuntu-haa:~$ sudo sh -c "mdadm -Es >> /etc/mdadm/mdadm.conf" |
| 160 | |
| 161 | * mitty@ubuntu-haa:~$ sudo dpkg-reconfigure mdadm |
| 162 | {{{ |
| 163 | ┌──────────────────────────┤ Configuring mdadm ├─ |
| 164 | |
| 165 | (snip) |
| 166 | }}} |
| 167 | * see [./log#dpkg-reconfiguremdadm] |
| 168 | * see also wiki:TipAndDoc/RAID#dpkg-reconfiguremdadm |
| 169 | * command result |
| 170 | {{{ |
| 171 | * Stopping MD monitoring service mdadm --monitor [ OK ] |
| 172 | Generating array device nodes... /var/lib/dpkg/info/mdadm.postinst: line 27: /dev/MAKEDEV: No such file or directory |
| 173 | failed. |
| 174 | Removing any system startup links for /etc/init.d/mdadm-raid ... |
| 175 | update-initramfs: Generating /boot/initrd.img-2.6.32-30-generic-pae |
| 176 | update-rc.d: warning: mdadm start runlevel arguments (2 3 4 5) do not match LSB Default-Start values (S) |
| 177 | update-rc.d: warning: mdadm stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (0 6) |
| 178 | * Starting MD monitoring service mdadm --monitor [ OK ] |
| 179 | }}} |