2016年3月21日 星期一

scsi_wait_scan not found

kernel 3.10.x已移除scsi_wait_scan module但預設的系統卻會包含此module的probe
進而造成kernel panic issue
simply remove scsi_wait_scan module probe from init to get it fixed. 

2016年3月15日 星期二

build iso image

 mkisofs  -P "Kido Yen" -V "Redhat 6.x/7.x boot disk" -o ../file.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T ./


with efi support
mkisofs -b isolinux/isolinux.bin -c boot.cat -no-emul-boot  -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -R -J 

2016年2月14日 星期日

grub tips

grub install for specific drive without BIOS drive name mapping grub --device-map=/dev/null
grub> device (hd0) /dev/sda

2016年2月4日 星期四

CentOS/RHEL rootfs on tmpfs

1: remember to disable selinux first
2: update mount process in /usr/share/dracut/modules.d/95rootfs-block/mount-root.sh

            mkdir /mytmpfs
            mount -t "$rootfs" -o "$rflags","$rootopts" \
                "${root#block:}" "/mytmpfs" 2>&1 | vinfo
            mount -t tmpfs -o size=100% none "$NEWROOT"
            cp -rfa /mytmpfs/* "$NEWROOT"
            sed -i '/\/boot\ /d' "$NEWROOT/etc/fstab"
            sed -i '/\/boot\t/d' "$NEWROOT/etc/fstab"
            sed -i '/\/ /d' "$NEWROOT/etc/fstab"
            sed -i '/\/\t/d' "$NEWROOT/etc/fstab"
            cat /dev/null > "$NEWROOT/root/.bash_history"
            umount /mytmpfs

3: create new initrd
4: update grub boot menu
5: boot parameter parsing
imgfile=$(getarg imgfile=)
[ -f "$imgfile" ] && tar zxvf $imgfile -C $NEWROOT

http://linux.die.net/man/1/bash
Conditional Expressions boot process stage https://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html#stages

2015年11月19日 星期四

hexdump - format output

hexdump -s 0x2f -n 7 -e '7 1 "%c" ' 1 7  repeat 7 times 1  each time for 1 byte

2015年10月13日 星期二

Linux C dev tips

errno.h strerror (errno) dlfcn.h void *handle; handle = dlopen("libkido.so", RTLD_LAZY); if (!handle) { fprintf(stderr, "%s \n", dlerror()); exit(EXIT_FAILURE); } int (*test)() = dlsym (handle,"test3"); if (!test) { fprintf(stderr, "%s \n", dlerror()); exit(EXIT_FAILURE); } int a; a=(*test)();

Linux C program tips

compile object files gcc -c 1.c --> automatically generate 1.o file link object files and generate binary file gcc -o app 1.o 2.o main.o build archives -- static library ar cr libkido.a 1.o 2.o main.o gcc -L . -lkido -o app build shared library gcc -c -fPIC 1.c --> automatically generate 1.o file gcc -shared -fPIC -o libkido.so main.o 1.o 2.o gcc -o app -L . -lkido -Wl,-rpath,./ <-- if rpath is not defined, LD_LIBRARY_PATH need to be defined in environment variable to have the binary locate library file