December 2005 / February 2006 / March 2006 / April 2006 / May 2006 / June 2006 / July 2006 / August 2006 / October 2006 / November 2006 / December 2006 / January 2007 / February 2007 / March 2007 / April 2007 / May 2007 / June 2007 / July 2007 / August 2007 / September 2007 / October 2007 / November 2007 / December 2007 / January 2008 / February 2008 / March 2008 / April 2008 / June 2008 / August 2008 / September 2008 / October 2008 / November 2008 / December 2008 / February 2009 / March 2009 / April 2009 / May 2009 /
Saturday, December 22, 2007
mdadm: /dev/hdb1 is too small: 0K
I finally added a second disk to grumpy so that I can complete the raid1 setup for my mythtv media archive.

I partitioned the disk to match exactly the first disk. On the first pass, the big media partition ended up a few blocks short, even though the disks have exactly the same number of blocks. I specified everything in cylinders, so that should have come up with exactly the same result. When I wiped the partition table and tried again, I adjusted the partition types only after creating all the partitions and verifying that they all line up. Then I changed the partition types for the raid partitions to fd and it all was correct. I have screwed up something the first time around, or changing the partition type to fd does something to the amount of available blocks on the disk. Anyways...

Next, I added the new media partition to the existing half of the array and let it rip.


mdadm --add /dev/md0 /dev/sdb6


Took three hours and completed just fine.

Next I want to make the root partition a raid1, too. The process should be rather simple:

I ran into problems with the first step already. First, I interpreted the parameters to the --create option of mdadm wrong, and got an error message that there are not enough devices specified, even though I listed "/dev/hdb1" and "missing". The trick is --auto=yes still needs a md device name pattern (you need --auto to create the md device node in udev), like so:

grumpy:~# mdadm --create --auto=yes /dev/md1 -l 1 --raid-devices 2 -v /dev/hdb1 missing
mdadm: /dev/hdb1 is too small: 0K
mdadm: create aborted

Now, what is that?

I'm following the man page, it matches various examples what people do I found on the Internet. But no dice. Finally, this blog set me on the right track. I wrote the partition table, but the kernel didn't properly update it in memory, so I'm in this strange halfway state. It works for using hdb6 as mirror, but not for creating a new mirror on hdb1. fdisk confirms the problem:

grumpy:~# fdisk /dev/hdb

The number of cylinders for this disk is set to 60801.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/hdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 1 851 6835626 fd Linux raid autodetect
/dev/hdb2 852 60801 481548375 5 Extended
/dev/hdb5 852 1032 1453851 82 Linux swap / Solaris
/dev/hdb6 1033 60801 480094461 fd Linux raid autodetect

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

Alright. Reboot coming up right when the kids are done watching "Der rosarote Panther".

After the reboot I get:

grumpy:~# mdadm --create --auto=yes /dev/md1 -l 1 --raid-devices 2 -v /dev/hdb1 missing
mdadm: size set to 6835520K
mdadm: array /dev/md1 started.
grumpy:~# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hdb1[0]
6835520 blocks [2/1] [U_]

md0 : active raid1 hda6[0] hdb6[1]
480094336 blocks [2/2] [UU]

unused devices:

Sweet! Works like a charm.
 
Comments:
You saved my array! Thank you so much!
 
If you want to avoid the reboot, just run "partprobe". (Check the man page before running commands given by Internet Strangers!) This resyncs the kernel's idea of what the partition sizes are with what they really are. No, I don't know why "fdisk" won't automagically do this for you every time.
 
cool, thanks. Good to know.
 
Post a Comment

Links to this post:

Create a Link



<< Home
Lostentry
Bernhards random ramblings about anything...


Powered by Blogger