2017年3月29日 星期三

kickstart pre-install script example

KS parameters defined here will be overwritten if parameter is defined in the global section.
Allow to separate parameter setup to different include files.

Development flow:
  Boot from CD-ROM and add ks=xxx to the boot option.
  After entering KS stage, hit Ctrl + Alt + F2 to enter shell for debugging
  Pre-install script will be placed at /tmp/ks-script-xxxxx


%pre --log=/tmp/pre.log
#!/bin/sh
for hdd in $(ls /sys/class/block/*/device/model 2>/dev/null);do
  hdd_model=$(cat $hdd|sed 's/ //g')
  echo "#Path: $hdd     Model: [$hdd_model]" >> /tmp/part-include

  if [ "$hdd_model" = "GGInInDer" ];then
      echo "#HDD model $hdd_model" > /tmp/part-include
      echo ignoredisk --only-use=$(echo $hdd|cut -d'/' -f5) >> /tmp/part-include
      echo "url --url=\"ftp://10.5.15.10/rhel71\"" >> /tmp/url-include
  fi
done
%end
%include /tmp/part-include
%include /tmp/url-include

2016年10月10日 星期一

boot RHEL7.2 on ceph RBD

experiment: Environment: Ceph : Monitor + OSD on the same node, SSD:HDD=1:4 Ceph HW configuration : QuantaGrid D51PH-1ULH x 3 , 12 x ST6000NM0034, 3 x INTEL SSDSC2BA20, Dual port intel 82599ES 10-Gigabit NIC client : QuantaPlex T41S-2U, intel 82599ES 10-Gigabit NIC Network : Quanta Fibre switch
boot RHEL7.2 on ceph RBD
R/W speed
Next: boot on RBD through PXE

2016年10月2日 星期日

arguments hiding from ps command

http://netsplit.com/hiding-arguments-from-ps

2016年10月1日 星期六

setuid in c

#include unistd.h
#include sys/types.h
 int main () {
  int real = getuid();
  int euid = geteuid();
  printf("The REAL UID =: %d\n", real);
  printf("The EFFECTIVE UID =: %d\n", euid);
  printf("setuid%d\n",setuid(euid));
  system("cat /etc/shadow");
}

chmod u+s binary

2016年9月13日 星期二

encode binary in script

base64 -d <-- base64 encoded content
EOF

2016年9月5日 星期一

disk fast clone on rhel7

create partition and format them first
mkdir /dev/shm/source /dev/shm/destination
mount /dev/src_rootfs /dev/shm/source
mount /dev/src_boot_part /dev/shm/source/boot
mount /dev/src_rootfs /dev/shm/destination
mkdir /dev/shm/destination/boot
mount /dev/dst_rootfs /dev/shm/destination/
mount /dev/dst_boot_part /dev/shm/destination/boot

cd /dev/shm/source
tar cf - * | ( cd /dev/shm/destination/; tar xfp -)

update fstab and grub.cfg

mount -o bind /proc /dev/shm/destination/proc
mount -o bind /sys /dev/shm/destination/sys
mount -o bind /dev /dev/shm/destination/dev

chroot /dev/shm/destination grub2-install /dev/dst_dsk (Please note, you must specify the whole disk instead of partition)
touch /dev/shm/destination/.autorelabel (run this only when you desire to enable selinux)

2016年8月28日 星期日

ceph-ansible stuck at "collect admin and bootstrap keys"

ceph 1.3.2 + ansible 2.1.1.0
root cause: mon was not properly launched
resolution: simply create a empty file, sysvinit to /var/lib/ceph/mon/{cluster}-{host}/sysvinit and then manually restart ceph mon service