Wednesday, February 16, 2011

replacing a space with a newline

contents of file.txt:

abc def ghi

cat file.txt | tr ' ' '\012'

abc
def
ghi


I originally tried this with

cat file.txt | sed 's/ /\n/g'

and it didn't work. I am told that '\n' isn't always recognised as a newline

Wednesday, February 02, 2011

Migrating (expanding) an existing array from RAID 1 to RAID 10 on HP SmartArray 400i

I added a couple of 72GB drives to an existing 2-drive array on an HP DL360 G5, which has a SmartArray P400i controller. The driver was the HP cciss driver, and the server was running CentOS 5.5 x86_64.

The expansion of the array can be done while the server is online, over ssh using hpacucli. While the underlying drive can be expanded, I have not yet found a way to notify the kernel about the changed drive size, so it appears a reboot is still required (or reloading the cciss driver, which in most cases means a reboot).

Using hpacucli:


=> controller all show

Smart Array P400i in Slot 0 (Embedded) (sn: PH81MQ6085 )

=> ctrl slot=0 show config

Smart Array P400i in Slot 0 (Embedded) (sn: PH81MQ6085 )

array A (SAS, Unused Space: 0 MB)


logicaldrive 1 (68.3 GB, RAID 1, OK)

physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS, 72 GB, OK)
physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SAS, 72 GB, OK)

unassigned

physicaldrive 1I:1:3 (port 1I:box 1:bay 3, SAS, 72 GB, OK)
physicaldrive 1I:1:4 (port 1I:box 1:bay 4, SAS, 72 GB, OK)

=> controller slot=0 logicaldrive 1 add drives=1I:1:3,1I:1:4
=> ctrl slot=0 show config

Smart Array P400i in Slot 0 (Embedded) (sn: PH81MQ6085 )

array A (SAS, Unused Space: 139953 MB)


logicaldrive 1 (68.3 GB, RAID 1+0, Transforming, 0% complete)

physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS, 72 GB, OK)
physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SAS, 72 GB, OK)
physicaldrive 1I:1:3 (port 1I:box 1:bay 3, SAS, 72 GB, OK)
physicaldrive 1I:1:4 (port 1I:box 1:bay 4, SAS, 72 GB, OK)

=>

Then you need to expand the logical drive into this space:

=> controller slot=0 show config

Smart Array P400i in Slot 0 (Embedded) (sn: PH81MQ6085 )

array A (SAS, Unused Space: 139953 MB)


logicaldrive 1 (68.3 GB, RAID 1+0, OK)

physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS, 72 GB, OK)
physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SAS, 72 GB, OK)
physicaldrive 1I:1:3 (port 1I:box 1:bay 3, SAS, 72 GB, OK)
physicaldrive 1I:1:4 (port 1I:box 1:bay 4, SAS, 72 GB, OK)

=>
=> controller slot=0 logicaldrive 1 modify size=max

Warning: Extension may not be supported on certain operating systems.
Performing extension on these operating systems can cause data to
become inaccessible. See ACU documentation for details. Continue?
(y/n) y

=> controller slot=0 show config

Smart Array P400i in Slot 0 (Embedded) (sn: PH81MQ6085 )

array A (SAS, Unused Space: 0 MB)


logicaldrive 1 (136.7 GB, RAID 1+0, OK)

physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS, 72 GB, OK)
physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SAS, 72 GB, OK)
physicaldrive 1I:1:3 (port 1I:box 1:bay 3, SAS, 72 GB, OK)
physicaldrive 1I:1:4 (port 1I:box 1:bay 4, SAS, 72 GB, OK)

=>

The size is correctly reported in /sys:

# cat /sys/block/cciss\!c0d0/size
286611840
#

However, fdisk does not see it, even after a partprobe, and I could find no way of re-scanning in /proc or /sys to get it to see the increased size.

One suggestion I haven't tried is to use 'sfdisk -R'

So for now a reboot, then resize partitions via resize2fs.