Search This Blog

Saturday, 5 December 2015

megacli key commands in linux

List physical devices
megacli -PDlist -a1 |grep "Enclosure Device ID\|Slot Number\|Firmware state"

Assuming 6 spare PDs on Enclosure ID 32 with Slot nos 6-11:

Create RAID 6 array
megacli -CfgLdAdd -r6 [32:6,32:7,32:8,32:9,32:10,32:11] -a0

Create RAID 10 array
megacli -CfgSpanAdd -r10 -Array0[32:6,32:7] -Array1[32:8,32:9] -Array2[32:10,32:11] -a0
 

Check array status 
megacli -LDInfo -LAll -a0 

Delete array no. 2 (-Force may be required)
megacli -CfgLdDel -L2 -Force -a0

Extending an existing RAID array with a new disk
.megacli -LDRecon -Start -r5 -Add -PhysDrv[32:3] -L0 -a0

Creating a global hot spare
megacli -PDHSP -Set -PhysDrv [0:2] -a0

Show background initialization progress
MegaCli64 -LDBI -ShowProg -Lall -a0

Monday, 2 November 2015

Avoiding 'The resulting partition is not properly aligned for best performance' in parted

There are various posts with mathematical ways to do this which don't always work, eg if optimal_io_size is zero.
With newer versions of parted, just use -a (alignment type)
parted -a optimal <device>
Then in parted use % to allocate eg
(parted) mkpart <name> 0% 50%
Bingo- it now does it for you. You can check what it's done by setting units to sectors eg
(parted)unit s
(parted)p
Model: ATA WDC WD4001FAEX-0 (scsi)
Disk /dev/sdb: 7814037168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End          Size         File system  Name  Flags
 1      2048s  7814035455s  7814033408s              P1

Thursday, 22 October 2015

Exporting nfs version 3 through a firewall

nfs v4 uses only 1 port - 2049. Open that to tcp & udp in your firewall and you're good.
nfs v3 and before are a bit more complicated. As well as the main nfs port 2049, you need to allow access to the portmapper (fixed on port 111), mountd, lockd & statd ports- and possibly also the rquotad port- and apart from portmapper they aren't fixed by default. To fix them, so you can create appropriate firewall rules, edit (in RHEL/CentOS/ScientficLinux) /etc/sysconfig/nfs and add/modify these lines. The actual ports you use are pretty arbitrary:
RQUOTAD_PORT=762
LOCKD_TCPPORT=890
LOCKD_UDPPORT=890
MOUNTD_PORT=892
STATD_PORT=891

Restart nfs & nfslock, set up your firewall rules (for both tcp & udp as either can work on all protocols) and that should be that - except that lockd is implemented as a kernel thread. The LOCKD variables above cause writes to /proc/sys/fs/nfs/nlm_tcpport & /proc/sys/fs/nfs/nlm_udpport in /etc/init.d/nfs and /etc/init.d/nfslock but these don't seem to have any effect.

Alternatively, the debian handbook https://debian-handbook.info/browse/stable/sect.nfs-file-server.html suggests creating a modprobe file:
Example 11.24: The /etc/modprobe.d/lockd file
options lockd nlm_udpport=2045 nlm_tcpport=2045

Either way it seems you basically need to reboot to get it to work.
You can check your nfsports with rpcinfo -p which will also tell you which NFS versions and which IP protocols they are using. You can also run rpcinfo for a remote server to check that's all working - rpcinfo -p  <servername>.