2013. szeptember 9., hétfő

How to create a new software RAID drive without rebooting

Say you have two drives with existing software raid partitions and some s free spaces on them. They are sda and sdc.

 ~#fdisk /dev/sda
p (to double-check)
n (type the last, not-existing-yet partition number)
t (type the last, half-existing-already partition number)
fd
w

Repeat it with sdc. Then...
:~# mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/sda4 /dev/sdc4
mdadm: Cannot open /dev/sda4: No such file or directory
mdadm: Cannot open /dev/sdc4: No such file or directory

Whoops. No need to reboot tho.

 ~#apt-get install parted
 ~#partprobe /dev/sda4

Error: Could not stat device /dev/sda4 - No such file or directory.

Errmmm.

 ~#partprobe /dev/sda
 ~#partprobe /dev/sdc

 ~#ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sda4  /dev/sdb  /dev/sdb1  /dev/sdc  /dev/sdc1  /dev/sdc2  /dev/sdc3 /dev/sdc4
~# mdadm -Cv /dev/md3 -l1 -n2 /dev/sd{a,c}4
mdadm: size set to 175815296K
mdadm: array /dev/md3 started.

Nice.

 ~# cat /proc/mdstat
Personalities : [raid1]
md3 : active (auto-read-only) raid1 sdc4[1] sda4[0]
      175815296 blocks [2/2] [UU]
        resync=PENDING


No worries about PENDING, just get to start writing onto it.

~# mkfs.ext4 /dev/md3
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
10993664 inodes, 43953824 blocks
2197691 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
1342 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables:


Okay, let's see that again.

:~# cat /proc/mdstat
Personalities : [raid1]
md3 : active raid1 sdc4[1] sda4[0]
      175815296 blocks [2/2] [UU]
      [==>..................]  resync = 12.5% (21977472/175815296) finish=37.5min speed=68259K/sec


Wait till resync finishes and mount. Tadam.

2013. szeptember 4., szerda

VMware Tools annoyance install troube

Ever faced the problem that you are unable to install a simple VMwaretools package on your newly installed nice Linux? (In this example: 13.04 Ubuntu)
Mount the cd, copy and unpack the tar, start the install script... and so on, you know the order. And be surprised with the message:

Searching for a valid kernel header path... The path "" is not valid. Would you like to change it?[yes]
This looks serious but can be easily solved by:
apt-get install build-essential linux-headers-$(uname -r)
and then
ln -s /usr/src/linux-headers-$(uname -r)/include/generated/uapi/linux/version.h /usr/src/linux-headers-$(uname -r)/include/linux/version.h

We happy Vincent?
Unfortunately we not.
WMvare tools reinstalling process the tells us some sad words:

[...]
Detected the kernel headers at "/lib/modules/3.8.0-19-generic/build/include".
The path "/lib/modules/3.8.0-19-generic/build/include" appears to be a valid
path to the 3.8.0-19-generic kernel headers.
Would you like to change it? [no]

Using 2.6.x kernel build system.
make: Entering directory `/tmp/modconfig-8gevFc/vmci-only'
/usr/bin/make -C /lib/modules/3.8.0-19-generic/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
          MODULEBUILDDIR= modules
make[1]: Entering directory `/usr/src/linux-headers-3.8.0-19-generic'
  CC [M]  /tmp/modconfig-8gevFc/vmci-only/linux/driver.o
/tmp/modconfig-8gevFc/vmci-only/linux/driver.c:127:4: error: implicit declaration of function ‘__devexit_p’ [-Werror=implicit-function-declaration]
/tmp/modconfig-8gevFc/vmci-only/linux/driver.c:127:4: error: initializer element is not constant
/tmp/modconfig-8gevFc/vmci-only/linux/driver.c:127:4: error: (near initialization for ‘vmci_driver.remove’)
/tmp/modconfig-8gevFc/vmci-only/linux/driver.c:1754:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘vmci_probe_device’
/tmp/modconfig-8gevFc/vmci-only/linux/driver.c:1982:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘vmci_remove_device’
/tmp/modconfig-8gevFc/vmci-only/linux/driver.c:119:12: warning: ‘vmci_probe_device’ used but never defined [enabled by default]
/tmp/modconfig-8gevFc/vmci-only/linux/driver.c:121:13: warning: ‘vmci_remove_device’ used but never defined [enabled by default]
/tmp/modconfig-8gevFc/vmci-only/linux/driver.c:2063:1: warning: ‘vmci_interrupt’ defined but not used [-Wunused-function]
/tmp/modconfig-8gevFc/vmci-only/linux/driver.c:2137:1: warning: ‘vmci_interrupt_bm’ defined but not used [-Wunused-function]
/tmp/modconfig-8gevFc/vmci-only/linux/driver.c:1717:1: warning: ‘vmci_enable_msix’ defined but not used [-Wunused-function]
cc1: some warnings being treated as errors
make[2]: *** [/tmp/modconfig-8gevFc/vmci-only/linux/driver.o] Error 1
make[1]: *** [_module_/tmp/modconfig-8gevFc/vmci-only] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.8.0-19-generic'
make: *** [vmci.ko] Error 2
make: Leaving directory `/tmp/modconfig-8gevFc/vmci-only'
&@#&@##&@&@@@@
Keep calm. Say you unpacked the tools to /usr/
So:
cd /usr/vmware-tools-distrib/
wget http://blog.gnu-designs.com/downloads/vmware-tools-linux-kernel-3.8_vmci_pci_hotplug_struct.patch
tar -xvf lib/modules/source/vmci.tar


Now, your directory looks like:

b# ls -l
drwxr-xr-x  2 root root   4096 jul   14  2012 bin
drwxr-xr-x  2 root root   4096 jul   14  2012 doc
drwxr-xr-x  4 root root   4096 jul   14  2012 etc
-rw-r--r--  1 root root 251898 jul   14  2012 FILES
lrwxrwxrwx  1 root root     13 jul   14  2012 INSTALL -> ./doc/INSTALL
drwxr-xr-x  2 root root   4096 jul   14  2012 installer
drwxr-xr-x 14 root root   4096 jul   14  2012 lib
drwxr-xr-x  5 root root   4096 jul   14  2012 vmci-only
lrwxrwxrwx  1 root root     31 jul   14  2012 vmware-install.pl -> ./bin/vmware-uninstall-tools.pl
-rw-r--r--  1 root root   1285 aug   23 00:10 vmware-tools-linux-kernel-3.8_vmci_pci_hotplug_struct.patch

Patch that driver:

root@server:/usr/vmware-tools-distrib# patch -p0 < /usr/vmware-tools-distrib/vmware-tools-linux-kernel-3.8_vmci_pci_hotplug_struct.patch
patching file vmci-only/linux/driver.c
Repack it.
root@server:/usr/vmware-tools-distrib# tar -cf vmci.tar vmci-only/
Overwrite the original bad one.
root@server:/usr/vmware-tools-distrib# cp vmci.tar lib/modules/source/

One more try! Reinstall now says:

---
Detected the kernel headers at "/lib/modules/3.8.0-19-generic/build/include".
The path "/lib/modules/3.8.0-19-generic/build/include" appears to be a valid
path to the 3.8.0-19-generic kernel headers.
Would you like to change it? [no]

Using 2.6.x kernel build system.
make: Entering directory `/tmp/modconfig-PYbj5R/vmci-only'
/usr/bin/make -C /lib/modules/3.8.0-19-generic/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
          MODULEBUILDDIR= modules
make[1]: Entering directory `/usr/src/linux-headers-3.8.0-19-generic'
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/linux/driver.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/linux/vmciKernelIf.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/common/vmciContext.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/common/vmciDatagram.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/common/vmciDoorbell.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/common/vmciDriver.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/common/vmciEvent.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/common/vmciHashtable.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/common/vmciQPair.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/common/vmciQueuePair.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/common/vmciResource.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/common/vmciRoute.o
  CC [M]  /tmp/modconfig-PYbj5R/vmci-only/driverLog.o
  LD [M]  /tmp/modconfig-PYbj5R/vmci-only/vmci.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /tmp/modconfig-PYbj5R/vmci-only/vmci.mod.o
  LD [M]  /tmp/modconfig-PYbj5R/vmci-only/vmci.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.8.0-19-generic'
/usr/bin/make -C $PWD SRCROOT=$PWD/. \
          MODULEBUILDDIR= postbuild
make[1]: Entering directory `/tmp/modconfig-PYbj5R/vmci-only'
make[1]: `postbuild' is up to date.
make[1]: Leaving directory `/tmp/modconfig-PYbj5R/vmci-only'
cp -f vmci.ko ./../vmci.o
make: Leaving directory `/tmp/modconfig-PYbj5R/vmci-only'

Using 2.6.x kernel build system.
make: Entering directory `/tmp/modconfig-uWidjn/vmci-only'
/usr/bin/make -C /lib/modules/3.8.0-19-generic/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
          MODULEBUILDDIR= modules
make[1]: Entering directory `/usr/src/linux-headers-3.8.0-19-generic'
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/linux/driver.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/linux/vmciKernelIf.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/common/vmciContext.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/common/vmciDatagram.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/common/vmciDoorbell.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/common/vmciDriver.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/common/vmciEvent.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/common/vmciHashtable.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/common/vmciQPair.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/common/vmciQueuePair.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/common/vmciResource.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/common/vmciRoute.o
  CC [M]  /tmp/modconfig-uWidjn/vmci-only/driverLog.o
  LD [M]  /tmp/modconfig-uWidjn/vmci-only/vmci.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /tmp/modconfig-uWidjn/vmci-only/vmci.mod.o
  LD [M]  /tmp/modconfig-uWidjn/vmci-only/vmci.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.8.0-19-generic'
/usr/bin/make -C $PWD SRCROOT=$PWD/. \
          MODULEBUILDDIR= postbuild
make[1]: Entering directory `/tmp/modconfig-uWidjn/vmci-only'
make[1]: `postbuild' is up to date.
make[1]: Leaving directory `/tmp/modconfig-uWidjn/vmci-only'
cp -f vmci.ko ./../vmci.o
make: Leaving directory `/tmp/modconfig-uWidjn/vmci-only'
Using 2.6.x kernel build system.
make: Entering directory `/tmp/modconfig-uWidjn/vsock-only'
/usr/bin/make -C /lib/modules/3.8.0-19-generic/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
          MODULEBUILDDIR= modules
make[1]: Entering directory `/usr/src/linux-headers-3.8.0-19-generic'
  CC [M]  /tmp/modconfig-uWidjn/vsock-only/linux/af_vsock.o
  CC [M]  /tmp/modconfig-uWidjn/vsock-only/linux/notify.o
  CC [M]  /tmp/modconfig-uWidjn/vsock-only/linux/notifyQState.o
  CC [M]  /tmp/modconfig-uWidjn/vsock-only/linux/stats.o
  CC [M]  /tmp/modconfig-uWidjn/vsock-only/linux/util.o
  CC [M]  /tmp/modconfig-uWidjn/vsock-only/linux/vsockAddr.o
  CC [M]  /tmp/modconfig-uWidjn/vsock-only/driverLog.o
  LD [M]  /tmp/modconfig-uWidjn/vsock-only/vsock.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /tmp/modconfig-uWidjn/vsock-only/vsock.mod.o
  LD [M]  /tmp/modconfig-uWidjn/vsock-only/vsock.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.8.0-19-generic'
/usr/bin/make -C $PWD SRCROOT=$PWD/. \
          MODULEBUILDDIR= postbuild
make[1]: Entering directory `/tmp/modconfig-uWidjn/vsock-only'
make[1]: `postbuild' is up to date.
make[1]: Leaving directory `/tmp/modconfig-uWidjn/vsock-only'
cp -f vsock.ko ./../vsock.o
make: Leaving directory `/tmp/modconfig-uWidjn/vsock-only'

 [....]

Whooohooooo, bingo!