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)