Iustin Pop: 3ware raid resize via pivot_root
How
pivot_root won against a stupid RAID controller
This post is brought to you by a very stupid 3ware 9650SE RAID
controller, which doesn't understand the concept of growing a RAID
array after all disks have been replaced by bigger ones. Or, well, it
can, but the procedure, involving sending array dumps to the technical
support, then receiving a program to run under DOS (!), doesn't
inspire me with confidence. Furthermore, this stupid RAID card doesn't
allow easy reordering (if it's possible, and I just missed it, please
let me know) of the RAID arrays at runtime, only from the BIOS screen,
and I didn't have access to that (only poor man's serial console under
Linux).
So, after buying new harddrives, and replacing the
original ones in the RAID1 array with double the capacity, I realised
I have to do a manual conversion. Basically, go into single-user mode,
remount all read-only, split the RAID1 array into its (identical)
components, change root directory to the second disk, re-partition the
first disk, copy the data from the 2nd to the 1st disk, then re-add
the 2nd disk to the 1st one (repartitioned) to re-establish the RAID1.
All this, on a headless (no keyboard, no VGA) machine, just with a
serial console. Of course, if this is just your local machine, you can
easily reboot from an external media, and do all this easily from a
full user-space. In any case, I'm writing this down, as there seem
to be no easily findable guides on how to do the resize on a 3ware
with its restrictions.
Procedure
Disclaimer: you might lose data via this, there are no
guarantees. Have up-to-date backups.
First, make sure you have power control (you can power-cycle the box
if needed) and the serial console works.
Also, make absolutely sure that the RAID array is fully
consistent, and that you don't have any bad sectors on the drives, as
you will lose redundancy during the operation.
If /usr is not on your root file-system, then you need to copy
/usr/sbin/chroot to somewhere on it. Also, if you have tools for the
array that are not on your root file-system, you should copy them
there now. In my case, that was tw_cli.
First reboot
Reboot into init=/bin/sh.
Note: I've tried to simply go into single-user mode, or to reboot with
emergency, but this doesn't work, because in both modes, beside the
init process with PID 1 and your shell, there's another init
process (the parent of the shell), and I didn't know how to tell it to
re-execute itself. To the main init process it's easy, you just run
telinit u, but that child keeps the old root directory mounted. If
it's possible to re-exec that child too, then this step can be
skipped please let me know how!
Changing the root mount
Make sure everything is mounted read-only (should be), then split the
raid array into its component drives, using whatever tool the card
needs. For me, it was:
# tw_cli /c0/u0 migrate type=single
The second drive now should be visible e.g. as /dev/sdc, so mount it
somewhere, and pivot_root to it:
# mount -o ro /dev/sdcX /mnt
# cd /mnt/
# pivot_root . mnt/
# exec chroot .
At this point, the new root (on some partition on /dev/sdc) is mount
at the root, and the exec call replaced the current shell with
another one that has the right root directory.
So nothing should keep the old root directory (at /dev/sdaX) in use,
and umount /mnt (or umount /dev/sdaX) should succeed now.
Recreate the first raid array
Now, since it's no longer in use, you can delete and recreate the
first raid array.
Once it's available, you have two choices:
- either do a bit-for-bit copy, using dd, from
/dev/sdcto/dev/sda, then runsfdisk -R /dev/sdato re-read the changed partition table on the target drive - or repartition
/dev/sdaif you also want to change the partition layout
fdisk -cu /dev/sda, and created partitions accordingly- then re-did my physical volume for LVM, but with
--dataalignment 1024k, to have the same megabyte alignment (yes, I went a little overboard)
pvmove from the old to the new disk, etc.
Switch back the root mount
At this point, /dev/sdc is no longer used, and you can again change
the root directory. This is similar to the first pivot_root, but now
using /dev/sda as a target. All the instructions are the same.
Convert back to RAID1
Now, since (in our example) /dev/sdc is no longer in-use, you can
delete that drive and rejoin it to the first drive, recreating the
RAID1 array. In my case:
# tw_cli
/> /c0/u2 delete
blah blah [y/n] y
/> /c0/u0 migrate type=raid1 disk=X
At this point, the machine is again redundant (or will be once the
resync finishes), but it still needs one more step or it won't boot
correctly.
Reinstall the boot-loader
Now, for reinstall the boot loader, you'll probably need to mount
/boot (and mount it read-write), and do whatever you need. In my
case, I re-ran lilo, but grub-install /dev/sda should also work.
Final reboot
And now, you only need to reboot into the normal, resized
system. Since you can't easily use shutdown when booted with
/bin/sh as init, just use /proc/sysrq-trigger to
sync/unmount/reboot.
Thoughts
While I use a hardware RAID controller for the battery backup it
offers, I have never thought it cannot do such a simple operation
(compare with mdadm --grow /dev/mdX --size=max).
Second, I knew about pivot_root but have not used it before. It's a
very very nice thing, and the only downside is that you can't really
use it with more than a few processes, since it's hard/impossible to
change a random process' root directory. But anyway, it works, and
it's damn handy for doing things to the root file-system or in general
to the root drive (e.g. just repartitioning it) when you can't boot
from another media (e.g. remote machine).
Now that the root DNS servers are
In the spur of the moment, I cycled over to
Watching the Star Wars Trilogies (both old and new) has finally closed one of the major (in at least some of my collegues' view) holes in my cinematographic education. (I've seen some of the new trilogy when it came out, but not all.) Oh well ... while it's quite enjoyable to watch, it's probably at least as important to have seen them just to spot the references all over the place.
Backlight control is one of those things that you'd think would be simple, but ha ha this is computing so of course it's an utter disaster and everything is a huge mess. There's three main classes of backlight control in the x86 world, all of which have drawbacks:
PS This post also gives me a chance to comment
on a so called
Facebook is not very popular among free software hackers. When I announced my Facebook page on identi.ca (see 
I'm swinging on the front porch shade, with happy wifi bars lit up on my
laptop. A good network makes for a happy home, isn't that how the saying goes?
(Maybe not yet.)
Typically that's easy to achieve -- here it wasn't. The house is solar powered,
the only connection to the outside is a phone line. So I needed a computer
that would work in that environment, using minimal (12 volt) power, and
getting the most out of the limited bandwidth while providing those
happy wifi bars.
At DebConf we learned that the name for these little home servers we have been
building for years is "
I finally finished
Really, I should have known better than to buy myself a rather 'bleeding-edge' laptop. I suppose I've been lucky with my last couple of laptops and was thinking that pretty much everything works on Linux. Or maybe I'm being picky, because in fact pretty much everything does work on my new Dell Studio.
I bought this laptop mainly because it has a 1920x1080 screen, without being a 17" monster. I had such a monster about four laptops ago (an enormous Sony Vaio weighing in at around 5kg and with a 1hr battery life) and it was an disaster: lots of weird proprietary stuff that never worked, like the external speakers in the docking station. But I loved that screen right up until the day Fraser threw a pair of scissors into it.
With the advent of mass-market 1920x1080 screens I've been waiting for them to arrive in laptops at a reasonable price, and the availability of this screen in a few possible laptops seemed to me to be that point.
It's a Dell Studio 15, and as well as the nice screen, it comes with a new Intel i7 Quad Core CPU, 6G RAM, 640G hard drive and a Blu-ray drive. While there are a few similar models around this one seemed to have the best mix of features-for-weight-and-price, so I bought my first Dell.
I built a USB key with the latest Debian Installer from Squeeze and installed that and everything came up pretty well. I had to use the broadcom-sta driver for the wireless, since the BCM 43224 is not (yet) supported by the free b43 driver (though from looking the mailing list people seem to be working on it, and it looks like it might not be too far away).
Everything seemed good. X came up on the (georgeous) screen. I don't care too much about 3D performance, but it was nice to note that the ATI 5000 series is expected to have full support as soon as it's integrated into the right places - it seems the code is written, and public, it just isn't incorporated into the 'radeon' driver quite yet. The fact that ATI is nowadays a free-software friendly company was one of the reasons for choosing this, in preference to an NVidia-based laptop.
But it seems that it isn't all roses. The fan in the laptop seems permanently on, and not on, in a quiet-just-barely-audible way, but ON, in an 'IN UR LAPTOPZ KOOLIN UR P0RCESSAZ' kind of a way. Too damn noisy for me to concentrate in a quiet room.
I've investigated what's going on, and it seems likely there are some ACPI misunderstandings happening. Some googling and some pecking around in /sys makes me wonder if the laptop expects some kind of configuration choice between favouring Active cooling and Passive cooling, and it's defaulted to the first one. Perhaps you get better benchmarks that way.
Linux ACPI also seems to only half understand it, it has two thermal zones, and one of them always appears with 0 temperature. I can see set points for the fans, but have no control over them. In particular this got me out reading the ACPI 4.0 specification, and it explicitly mentions this choice of favouring 'Active' vs 'Passive' as being done by configuring the passive trip point setting to a higher value than the low & high active trip points.
In the ACPI 4 spec (page 409) it says: