2013. szeptember 9., hétfő

How to create a new software RAID drive without rebooting

Say you have two drives with existing software raid partitions and some s free spaces on them. They are sda and sdc.

 ~#fdisk /dev/sda
p (to double-check)
n (type the last, not-existing-yet partition number)
t (type the last, half-existing-already partition number)
fd
w

Repeat it with sdc. Then...
:~# mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/sda4 /dev/sdc4
mdadm: Cannot open /dev/sda4: No such file or directory
mdadm: Cannot open /dev/sdc4: No such file or directory

Whoops. No need to reboot tho.

 ~#apt-get install parted
 ~#partprobe /dev/sda4

Error: Could not stat device /dev/sda4 - No such file or directory.

Errmmm.

 ~#partprobe /dev/sda
 ~#partprobe /dev/sdc

 ~#ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sda4  /dev/sdb  /dev/sdb1  /dev/sdc  /dev/sdc1  /dev/sdc2  /dev/sdc3 /dev/sdc4
~# mdadm -Cv /dev/md3 -l1 -n2 /dev/sd{a,c}4
mdadm: size set to 175815296K
mdadm: array /dev/md3 started.

Nice.

 ~# cat /proc/mdstat
Personalities : [raid1]
md3 : active (auto-read-only) raid1 sdc4[1] sda4[0]
      175815296 blocks [2/2] [UU]
        resync=PENDING


No worries about PENDING, just get to start writing onto it.

~# mkfs.ext4 /dev/md3
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
10993664 inodes, 43953824 blocks
2197691 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
1342 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables:


Okay, let's see that again.

:~# cat /proc/mdstat
Personalities : [raid1]
md3 : active raid1 sdc4[1] sda4[0]
      175815296 blocks [2/2] [UU]
      [==>..................]  resync = 12.5% (21977472/175815296) finish=37.5min speed=68259K/sec


Wait till resync finishes and mount. Tadam.

Nincsenek megjegyzések:

Megjegyzés küldése