Online Book Reader

Home Category

Managing RAID on Linux - Derek Vadala [46]

By Root 1363 0
in use. So if you have a dormant disk in your system and it used to be part of an array, but hasn't been used for some time, there will still be a RAID superblock on it.

mdadm will warn you if potential member disks already contain RAID superblocks, and you will have to assert that you want to create the array:

# mdadm -C -n2 -l0 /dev/md3 /dev/sd{d,e}1

mdadm: /dev/sde1 appear to be part of a raid array:

level=1 disks=2 ctime=Wed Mar 20 23:17:38 2002

Continue creating array? y

mdadm: array /dev/md3 started.

mkraid also generates a warning when you try to include disks that already have a RAID superblock in a new array, but its safeguards are slightly more obtuse. In the following example, I've created a simple /etc/raidtab that defines an array including member disks that I know were part of an array that's no longer active:

# mkraid /dev/md1

handling MD device /dev/md1

analyzing super-block

disk 0: /dev/sdb1, 17920476kB, raid superblock at 17920384kB

/dev/sdb1 appears to be already part of a raid array -- use -f to

force the destruction of the old superblock

mkraid: aborted.

(In addition to the above messages, see the syslog and /proc/mdstat

as well for potential clues.)

Because the loss of data is such a drastic error, even using mkraid --force will return a warning. Using mkraid --really-force is the only way to successfully reuse partitions that already contain data and array superblocks. Even after the second warning, a countdown allowing five additional seconds to cancel the order is displayed.

# mkraid --really-force /dev/md1

DESTROYING the contents of /dev/md0 in 5 seconds, Ctrl-C if unsure!

handling MD device /dev/md0

analyzing super-block

disk 0: /dev/sdb1, 17920476kB, raid superblock at 17920384kB

disk 1: /dev/sdc1, 17920476kB, raid superblock at 17920384kB

disk 2: /dev/sdd1, 17920476kB, raid superblock at 17920384kB

Unfortunately, the extra checks that mdadm and, to a greater degree, mkraid, perform can become tedious when you're experimenting with various array configurations—especially when you're forced to wait five seconds each time you reuse disks.

The dd command is useful for erasing the RAID superblock from previously used partitions. To erase the RAID superblock, you will need to know where it's located.

disk 0: /dev/sdb1, 17920476kB, raid superblock at 17920384kB

disk 1: /dev/sdc1, 17920476kB, raid superblock at 17920384kB

disk 2: /dev/sdd1, 17920476kB, raid superblock at 17920384kB

The previous output is generated by mkraid when a new array is constructed. In this case, the superblock was written to each disk at block 17920384. The md driver uses a 4 KB block size. Don't worry about recording the location of the RAID superblock, because each time an array changes status, this information is reported via syslogd. That means the superblock location is recorded each time an array is started, stopped, or encounters an error. Look for a syslog entry similar to this one (kern.info):

Apr 25 11:54:59 jaded kernel: md: sdd1 [events: 00000001]<6>(write) sdd1's sb /

offset: 17920384

Apr 25 11:54:59 jaded kernel: md: sdc1 [events: 00000001]<6>(write) sdc1's sb /

offset: 17920384

Apr 25 11:54:59 jaded kernel: md: sdb1 [events: 00000001]<6>(write) sdb1's sb /

offset: 17920384

Use dd to zero the superblock of each member disk you wish to reuse:

# dd if=/dev/zero of=/dev/sdb1 bs=1k seek=17920384 count=4

* * *

Warning

Be extremely careful when using dd to erase RAID superblocks or to modify any information on hard disks. If you accidentally specify the wrong device or make a mistake on the command line, you could destroy all data on the disk. When working with dd, if= specifies the input file to use. Data from the input file is written to the output file, specified by of=. In this example, we take input from /dev/zero (a character special file that generates zeros) and write it to /dev/sdb1, which means zeros are written to the output file. bs=1k specifies a block size of 1 KB. That means 1 KB worth of zeros is read from /dev/zero and then written to /dev/sdb1 at a time. seek=

Return Main Page Previous Page Next Page

®Online Book Reader