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

2018年10月5日 星期五

software raid on RHEL7.5

review disk layout
parted /dev/sdx u s p

raid creation process
1: create 2x type code 0xfd partitions

2: set raid flag to all partitions
parted /dev/sdx set 1 raid on

3: set boot flag to partition which serves for grub configuration files
parted /dev/sdx set 1 boot on

4: zero out superblock
mdadm --zero-superblock /dev/sdx[1-9]

5: create raid
mdadm --create /dev/md0 --name=root -n2 -l1 /dev/sda1 /dev/sdb1
mdadm --create /dev/md0 --name=root -n2 -l1 /dev/sda2 /dev/sdb2

6: delete raid
mdadm --delete /dev/md0
mdadm --zero-superblock /dev/sdx[1-9]
mdadm --stop /dev/md0

6: repair raid
mdadm --add /dev/md0 /dev/sda1

7:scan available md
mdadm --examine --scan
mdadm --examine /dev/sdx[1-9]

8: raid uuid - this information need to be included in /etc/default/grub
mdadm --detail /dev/md0|grep UUID
rd.md.uuid=xxxx

9: activate software raid
mdadm -A -R /dev/md0 /dev/sda1 /dev/sdb1

others:
don't forget to creating new initramfs
dracut -f --mdadmconf

to install grub2 on a drive. mdadm package needs to be installed first and grub needs to be installed to whole disk drive instead of partition. grub needs to be installed on both drives
grub2-install --no-floppy --boot-directory=/boot /dev/sda

2018年4月1日 星期日

point rhel7 installation source to hdd

boot option
  inst.stage2=hd:sda1:/
  inst.ks=hd:sda1:/path/xxx.ks

inside kickstart file
   no need to specify installation source since inst.stage2 had been added to boot option

inst.dd -- driver package. can supply multiple driver package to boot option

please note, when booting with inst.ks and inst.dd options supplied at the same time, inst.ks could behave not as expected.

mount qcow2 from rhel7


method 1 
install packages
  yum install libguestfs-tools

start libvirtd service
  systemctl start libvirtd

find device name presented in qcow2 image
  guestmount -a rhel-server-7.4-x86_64-kvm.qcow2 -m /dev/xxxxxx --ro /mnt/test/

======================================================
guestfsd: main_loop: proc 272 (part_to_dev) took 0.00 seconds
guestfsd: main_loop: new request, len 0x38
commandrvf: stdout=y stderr=y flags=0x0
commandrvf: blkid -c /dev/null -o value -s TYPE /dev/sda1
guestfsd: main_loop: proc 198 (vfs_type) took 0.08 seconds
guestfsd: main_loop: new request, len 0x28
commandrvf: stdout=y stderr=y flags=0x0
commandrvf: lvm lvs --help
  Invalid units specification
guestfsd: error: lvm lvs --help:   Invalid units specification
guestfsd: main_loop: proc 11 (lvs) took 0.09 seconds
libguestfs: error: lvs: lvm lvs --help:   Invalid units specification
libguestfs: closing guestfs handle 0x7fc753c248e0 (state 2)
guestfsd: main_loop: new request, len 0x28
======================================================

mount image
  guestmount -a rhel-server-7.4-x86_64-kvm.qcow2 -m /dev/sda1 --ro /mnt/test/

method 2
install packages
  yum install libguestfs-tools

convert qcow2 image to raw disk format
  qemu-img convert xxx.qcow2 xxx.raw

list partition layout
  fdisk -l xxx.raw

mount drive
  mount -o offset=$((BLOCK_SIZE * START_BLOCK)) xxx.raw /MNT_POINT

ex:
  mount -o offset=$((512 * 2048)) xxx.raw /mnt/