2020年11月2日 星期一

ipxe example

#!ipxe

#set QCTFILENAME http://10.5.15.10/test/echo.ipxe

#set bdf 0000:3d:00.3

#set QCTBDF 0000:00:08.0

#set QCTMAC 08:00:27:6b:53:eb

#set QCTMAC 08:00:27:89:ea:ad

set QCTIP 10.102.14.110

set QCTNETMASK 255.255.255.0

set QCTGATEWAY 10.102.14.1

set QCTFILENAME file:/utils/rhel8.2.ipxe

set QCTDNS 8.8.8.8


========================================================================

 #!ipxe

imgfree

set base-url http://10.7.21.51/adt

initrd ${base-url}/rhel8.2/isolinux/initrd.img

chain ${base-url}/rhel8.2/isolinux/vmlinuz initrd=initrd.img ro fips=1 inst.sshd inst.ks=${base-url}/rhel8.php inst.stage2=${base-url}/rhel8.2/ ip=${ip}::${gateway}:${netmask}:::none::${mac}

2020年11月1日 星期日

ipxe script example for nic selection

 #!ipxe

#set bdf 0000:3d:00.3

#set QCTBDF 0000:00:08.0

#set QCTMAC 08:00:27:6b:53:eb

#set QCTMAC 08:00:27:89:ea:ad

#set QCTIP 10.5.12.120

#set QCTNETMASK 255.255.255.0

#set QCTGATEWAY 10.5.12.1

#set QCTFILENAME http://10.5.15.10/test/bdf.ipxe

#set QCTDNS 8.8.8.8


chain file:/utils/QCT.ipxe ||

console


isset ${QCTFILENAME} && set filename ${QCTFILENAME} ||

isset ${QCTBDF} && goto boot_via_bdf ||

isset ${QCTMAC} && goto boot_via_mac ||

goto default_boot

exit


:exit_ipxe

exit


:boot_via_bdf

echo BOOT via BDF

set idx:int32 0

set loop_count:int32 1

:loop_bdf isset ${net${idx}/mac} || goto exit_ipxe

  echo net${idx} is a ${net${idx}/chip} with MAC ${net${idx}/mac}  bdf ${net${idx}/busloc:busdevfn}

  iseq ${net${idx}/busloc:busdevfn} ${QCTBDF} && set target_dev net${idx} ||

  isset ${target_dev} && goto configure_ip ||

  inc idx && goto loop_bdf

#:loop_done

exit



:boot_via_mac

echo BOOT via MAC

set idx:int32 0

set loop_count:int32 1

:loop_mac isset ${net${idx}/mac} || goto exit_ipxe

  #echo net${idx} is a ${net${idx}/chip} with MAC ${net${idx}/mac} bdf ${net${idx}/busloc:busdevfn}

  iseq ${net${idx}/mac} ${QCTMAC} && set target_dev net${idx} ||

  isset ${target_dev} && goto configure_ip ||

  inc idx && goto loop_mac

#:loop_done

exit



:configure_ip

  echo Configure IP address for ${target_dev}

  isset ${QCTDNS} && set ${target_dev}/dns ${QCTDNS} ||

  isset ${QCTIP} || goto use_dhcp

  i ||sset ${QCTNETMASK} || goto use_dhcp

  isset ${QCTGATEWAY} || goto use_dhcp

  goto use_static_ip

exit


:use_dhcp

  echo use dhcp

  dhcp ${target_dev} || goto default_boot

  isset ${QCTDNS} && set ${target_dev}/dns ${QCTDNS} ||

  isset ${QCTFILENAME} && set filename ${QCTFILENAME} ||

  chain -r -a ${filename} ||

exit


:use_static_ip

  echo use static ip

  echo set ${target_dev}/ip ${QCTIP}

  set ${target_dev}/ip ${QCTIP}

  echo set ${target_dev}/netmask ${QCTNETMASK}

  set ${target_dev}/netmask ${QCTNETMASK}

  echo set ${target_dev}/gateway ${QCTGATEWAY}

  set ${target_dev}/gateway ${QCTGATEWAY}

  echo set ${filename}

  chain -r -a ${filename} ||

exit


:default_boot

  clear target_dev

  isset ${QCTIP} || goto default_dhcp

  isset ${QCTNETMASK} || goto default_dhcp

  isset ${QCTGATEWAY} || goto default_dhcp

  goto default_static_ip

exit


:default_dhcp

  echo Default DHCP

  set idx:int32 0

  set loop_count:int32 1

  :loop_dhcp isset ${net${idx}/mac} || goto exit_ipxe

   ifopen net${idx}

   echo Connectivity check for net${idx}

   dhcp && goto chain_boot ||

   ifclose net${idx}

   inc idx

   goto loop_dhcp

  shell

exit


:default_static_ip

  echo Default Static

  set idx:int32 0

  set loop_count:int32 1

  :loop_static isset ${net${idx}/mac} || goto exit_ipxe

   ifopen net${idx}

   echo set net${idx}/ip ${QCTIP}

   set net${idx}/ip ${QCTIP}

   echo set net${idx}/netmask ${QCTNETMASK}

   set net${idx}/netmask ${QCTNETMASK}

   echo set net${idx}/gateway ${QCTGATEWAY}

   set net${idx}/gateway ${QCTGATEWAY}

   echo Connectivity check for net${idx}

   ping -c 2 -q ${QCTGATEWAY} && goto chain_boot ||

   ifclose net${idx}

   inc idx

   goto loop_static

  shell

exit


:chain_boot

echo QCT Chain Boot

sleep 2

chain -r -a ${filename}

shell

exit


2019年1月2日 星期三

ipxe for legacy and efi

make bin/undionly.kpxe  EMBED=legacy.ipxe
make bin-x86_64-efi/ipxe.efi EMBED=efi.ipxe

#!ipxe
set user-class QCT-UEFI
dhcp && goto chainloading || echo
dhcp && goto chainloading || echo
dhcp && goto chainloading || echo
exit
:chainloading
#echo chainload1
isset ${filename} && chain ${filename} || dhcp
#echo chainload2
isset ${filename} && chain ${filename} || dhcp
#echo chainload3
isset ${filename} && chain ${filename}
exit

dhcp configuration

subnet 10.102.99.0 netmask 255.255.255.0 {
  pool {
    allow members of "allocation-class-1";
    range dynamic-bootp 10.102.99.150 10.102.99.199;
    next-server 10.102.99.30;

     if exists user-class {
         if option user-class = "QCT-LEGACY" {
           filename "http://10.102.99.30/ks.html";
         } elsif option user-class = "QCT-UEFI" {
           filename "http://10.102.99.30/ks.html";
         }
     } else {
         if substring(hardware,1,3) = 08:00:27 or  substring(hardware,1,3) = 08:00:26 {
           filename "http://10.102.99.30/ks.html";
         } else {
           if substring(option vendor-class-identifier, 0, 20) = "PXEClient:Arch:00000" {
             filename "undionly.kpxe";
           } elsif substring(option vendor-class-identifier, 0, 20) = "PXEClient:Arch:00007" {
             filename "ipxe.efi";
           }
         }
     }
  }


chainload - please note, initrd value needs to match the one listed in kernel parameter.
#!ipxe
initrd http://172.16.1.1/initrd.img
chain http://172.16.1.1/vmlinuz initrd=initrd.img root=live:http://172.16.1.1/rootfs.img ro readonlyroot rd.net.timeout.dhcp=45 rd.writable.fsimg rd.live.dir=../../../tmp/curl_fetch_url0/ console=tty0 console=ttyS1,115200n8


2018年12月12日 星期三

boot on squashfs

mksquashfs archive

when squashfs image file is placed on hdd, boot parameter should look like below
rd.live.squashimg=xxx.img
rd.writable.fsimg

rd.writable.fsimg -> copy image file to ram. need to work with rd.live.squashimg if filename of image is not squashfs.img
readonlyroot -> for fstab

rd.live.dir -> if folder structure is not /LiveOS

losetup -a to check loop device mount status

grub2 for uefi

shim
grub2-efi

yum (re)install shim grub2-efi --installroot=/
remove all files underneath / exclude everything underneath ./boot/efi/EFI

rename ./boot/efi/EFI/redhat to ./boot/efi/EFI/QCT
patch ./boot/efi/EFI/QCT/*.CSV

Generate grub.cfg

for UEFI
rm -rf /dev/shm/firmware/*
mkdir -p /dev/shm/firmware/efi
mount -o bind /dev/shm/firmware /sys/firmware
grub2-mkconfig -o ./boot/efi/EFI/QCT/grub.cfg
umount  /sys/firmware

for Legacy
rm -rf /dev/shm/firmware/*
mkdir -p /dev/shm/firmware/
mount -o bind /dev/shm/firmware /sys/firmware
grub2-mkconfig -o ./boot/grub2/grub.cfg
umount  /sys/firmware

customize menuentry
/etc/os-release

2018年11月23日 星期五

Ceph OSD classification.

ceph osd crush rm-device-class 36 37 38 39 40 41 42 43 44
ceph osd crush set-device-class ssd 36 37 38 39 40 41 42 43 44

ceph osd crush class ls

ceph osd crush rule create-replicated ssd  default host ssd
ceph osd crush rule create-replicated hdd  default host hdd

ceph osd pool set default.rgw.meta crush_rule ssd

rados ls -p cephfs_metadata
ceph osd map cephfs_metadata 100.00000000.inode
for obj in $(rados ls -p cephfs_metadata);do echo ceph osd map cephfs_metadata $obj;done

2018年10月17日 星期三

using s3 as backend storage for docker registry

setenforce 0
systemctl stop firewalld

docker run -d -p 5000:5000 --restart=always --name registry -v /root/config.yml:/etc/docker/registry/config.yml -v /etc/hosts:/etc/hosts registry:2

docker exec -it 0ba1bdfc1491 cat /etc/docker/registry/config.yml

docker pull ubuntu:16.04
docker tag ubuntu:16.04 localhost:5000/my-ubuntu
docker push localhost:5000/my-ubuntu
docker image remove ubuntu:16.04
docker image remove localhost:5000/my-ubuntu
docker pull localhost:5000/my-ubuntu
docker container stop registry && docker container rm -v registry

config.yml

version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  s3:
    accesskey: GWHHQI5NSYBV1A756W32
    secretkey: TzDlHsn66miM9TddT85DoLqUuBBmJSzxbtTxW6sO
    region: default
    regionendpoint: http://docker.qct.io
    bucket: registry
    secure: false
    v4auth: true
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]
health:
  storagedriver:
    enabled: true
    interval: 30s
    threshold: 1