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/