메뉴 닫기

가상화 이미지 수정 – guestfish, guestmount

3543625990_dqhR5vij_libguest

 

 

 

참고 http://docs.openstack.org/image-guide/content/ch_modifying_images.html

필자의 경우 경우 가상화 이미지 수정하는데  Loop devices, kpartx, network block devices 방식 사용을 많이 하였는데 OpenStack 에서는 guestfish 와 guestmount 를 이용해서 수정하는 방법을 우선적으로 소개하고 있습니다.
그래서 해당 사용법에 대해서 안내해드립니다.
 
OS : Ubuntu 14.04.2 LTS X86_64 
테스트환경 OS는 Ubuntu 였으나 RedHat 계열도 방법은 동일합니다.
 
guestfish 
The guestfish program is a tool from the libguestfs project that allows you to modify the files inside of a virtual machine image.
 
root@controller:~# apt-get install libguestfs-tools
 
:: 테스트를 위해 Ubuntu 싸이트에서 제공하는 가상화 이미지를 다운로드
root@controller:~# wget http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
root@controller:~# guestfish –rw -a trusty-server-cloudimg-amd64-disk1.img
 
Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
 
Type: ‘help’ for help on commands
      ‘man’ to read the manual
      ‘quit’ to quit the shell
 
 
> run
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
> list-filesystems
/dev/sda1: ext4
> list-filesystems
/dev/sda1: ext4
> mount /dev/sda1 /
> edit /etc/network/interfaces.d/eth0.cfg
> exit
 
 
※ Trouble – Err Message 
root@controller:~# guestfish –rw -a trusty-server-cloudimg-amd64-disk1.img
 
Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
 
Type: ‘help’ for help on commands
      ‘man’ to read the manual
      ‘quit’ to quit the shell
 
> run
libguestfs: error: /usr/bin/supermin-helper exited with error status 1.
To see full error messages you may need to enable debugging.
See http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
 
아래 명령어로 의존성 트리 업데이트
# update-guestfs-appliance
supermin -v -o supermin.d –names bsdmainutils btrfs-tools cryptsetup e2fsprogs extlinux genisoimage gfs-tools gfs2-tools grub-pc hfsplus iproute libaugeas0 libcap2 libhivex0 libpcre3 libyajl2 linux-image mtools nilfs-tools ntfs-3g openssh-client reiserfsprogs sysvinit ufsutils vim-tiny xz-utils zfs-fuse acl attr bash binutils bzip2 coreutils cpio diffutils dosfstools file findutils gawk gdisk grep gzip jfsutils kmod less libxml2 lsof lsscsi lvm2 lzop mdadm parted procps procps-ng psmisc rsync scrub sed strace syslinux tar udev util-linux util-linux-ng zerofree –exclude ^perl –exclude ^python –exclude ^plymouth –exclude ^linux-firmware –exclude ^kbd-misc –exclude ^file-rc
supermin 4.1.6
selected package handler: debian
packages already present: 
……………..
……………..
unpacking /tmp/supermin3b2944ff20af759693dcec5b7cb8f424.tmp/zlib1g_1%3a1.2.8.dfsg-1ubuntu1_amd64.deb …
9082 files and directories
writing supermin.d/base.img …
writing supermin.d/hostfiles …
 
 
guestmount
root@controller:~# guestmount -a trusty-server-cloudimg-amd64-disk1.img -m /dev/sda1 –rw /mnt
root@controller:~# df |grep  mnt
/dev/fuse        1386360    783360    514528  61% /mnt
 
마운트 포인트를 모른다면 -i(inspect) 으로…
root@controller:~# guestmount -a trusty-server-cloudimg-amd64-disk1.img -i –rw /mnt
/dev/fuse        1386360    783360    514528  61% /mnt
 
example)
:: 해당 이미지내에 RPM 설치유무 체크
root@controller:~# rpm -qa –dbpath /mnt/var/lib/${rpm_package}
root@controller:~# umount  /mnt
 
 [polldaddy rating=”7739789″]  
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x