Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

16.4. Guestmet 쉘

Guest fish는 명령줄 또는 쉘 스크립트에서 게스트 가상 머신 파일 시스템에 액세스하는 데 사용할 수 있는 대화형 쉘입니다. libguestfs API의 모든 기능은 쉘에서 사용할 수 있습니다.
가상 머신 디스크 이미지 보기 또는 편집을 시작하려면 다음 명령을 실행하여 원하는 디스크 이미지의 경로를 대체합니다.
guestfish --ro -a /path/to/disk/image
--ro 는 디스크 이미지가 읽기 전용으로 열려 있음을 의미합니다. 이 모드는 항상 안전하지만 쓰기 액세스 허용은 허용하지 않습니다. 게스트 가상 머신이 실행되고 있지 않거나 디스크 이미지가 라이브 게스트 가상 머신에 연결되지 않은 경우에만 이 옵션을 생략합니다. libguestfs 를 사용하여 라이브 게스트 가상 머신을 편집할 수 없으며 시도하면 되돌릴 수 없는 디스크 손상이 발생합니다.
/path/to/disk/image 는 디스크의 경로입니다. 이 파일은 호스트 물리적 머신 논리 볼륨(예: /dev/VG/LV), 호스트 물리적 머신 장치(/dev/cdrom) 또는 SAN LUN(/dev/sdf3)일 수 있습니다.
참고
libguestfs 및fish는 루트 권한이 필요하지 않습니다. 액세스 중인 디스크 이미지에 root가 읽기 또는 쓰기 또는 둘 다 필요한 경우에만 root로 실행하면 됩니다.
interactivelylyian을 시작하면 다음과 같은 프롬프트가 표시됩니다.
 guestfish --ro -a /path/to/disk/image

Welcome to guestfish, the libguestfs filesystem interactive shell for editing virtual machine filesystems.

 Type: 'help' for help on commands
       'man' to read the manual
       'quit' to quit the shell

><fs>
프롬프트에서 run 을 입력하여 라이브러리를 시작하고 디스크 이미지를 연결합니다. 처음 수행할 때 최대 30초가 걸릴 수 있습니다. 후속 시작은 훨씬 더 빨리 완료됩니다.
참고
libguestfs는 KVM(사용 가능한 경우)과 같은 하드웨어 가상화 가속을 사용하여 이 프로세스를 가속화합니다.
run 명령을 입력한 후 다음 섹션에서 설명하는 다른 명령을 사용할 수 있습니다.

16.4.1. fish로 파일 시스템 보기

이 섹션에서는fish로 파일을 보는 방법에 대해 설명합니다.

16.4.1.1. 수동 목록 및 보기

list-filesystems 명령은 libguestfs에서 찾은 파일 시스템을 나열합니다. 이 출력은 Red Hat Enterprise Linux 4 디스크 이미지를 보여줍니다.
><fs> run
><fs> list-filesystems
/dev/vda1: ext3
/dev/VolGroup00/LogVol00: ext3
/dev/VolGroup00/LogVol01: swap
이 출력에는 Windows 디스크 이미지가 표시됩니다.
><fs> run
><fs> list-filesystems
/dev/vda1: ntfs
/dev/vda2: ntfs
기타 유용한 명령은 목록 장치,list-partitions,lvs,pvs,vfs-type파일 입니다. 다음 출력에 표시된 대로 help 명령을 입력하여 모든 명령에 대한 자세한 정보와 도움말 을 얻을 수 있습니다.
><fs> help vfs-type
 NAME
    vfs-type - get the Linux VFS type corresponding to a mounted device

 SYNOPSIS
     vfs-type device

 DESCRIPTION
    This command gets the file system type corresponding to the file system on
    "device".

    For most file systems, the result is the name of the Linux VFS module
    which would be used to mount this file system if you mounted it without
    specifying the file system type. For example a string such as "ext3" or
    "ntfs".
파일 시스템의 실제 내용을 보려면 먼저 마운트해야 합니다. 이 예에서는 이전 출력(/dev/vda2)에 표시된 Windows 파티션 중 하나를 사용합니다. 이 경우 C:\ 드라이브에 해당하는 것으로 알려져 있습니다.
><fs> mount-ro /dev/vda2 /
><fs> ll /
total 1834753
 drwxrwxrwx  1 root root       4096 Nov  1 11:40 .
 drwxr-xr-x 21 root root       4096 Nov 16 21:45 ..
 lrwxrwxrwx  2 root root         60 Jul 14  2009 Documents and Settings
 drwxrwxrwx  1 root root       4096 Nov 15 18:00 Program Files
 drwxrwxrwx  1 root root       4096 Sep 19 10:34 Users
 drwxrwxrwx  1 root root      16384 Sep 19 10:34 Windows
ls,ll,cat,more,downloadtar-out 과 같은fish 명령을 사용하여 파일과 디렉토리를 보고 다운로드할 수 있습니다.
참고
이 쉘에는 현재 작업 중인 디렉터리의 개념이 없습니다. 일반 쉘과 달리 cd 명령을 사용하여 디렉터리를 변경할 수 없습니다. 모든 경로는 슬래시(/) 문자로 시작하여 정상으로 정규화된이어야 합니다. 경로를 완료하려면 Tab 키를 사용합니다.
fish 쉘을 종료하려면 exit 를 입력하거나 Ctrl+d 를 입력합니다.

16.4.1.2. inspection 사용

파일 시스템을 나열 및 마운트하는 대신,fish 자체에서 이미지를 검사하고 게스트 가상 머신에 있는 것처럼 파일 시스템을 마운트하도록 할 수 있습니다. 이렇게 하려면 명령줄에 -i 옵션을 추가합니다.
guestfish --ro -a /path/to/disk/image -i

Welcome to guestfish, the libguestfs filesystem interactive shell for
 editing virtual machine filesystems.

 Type: 'help' for help on commands
       'man' to read the manual
       'quit' to quit the shell

 Operating system: Red Hat Enterprise Linux AS release 4 (Nahant Update 8)
 /dev/VolGroup00/LogVol00 mounted on /
 /dev/vda1 mounted on /boot

 ><fs> ll /
 total 210
 drwxr-xr-x. 24 root root  4096 Oct 28 09:09 .
 drwxr-xr-x  21 root root  4096 Nov 17 15:10 ..
 drwxr-xr-x.  2 root root  4096 Oct 27 22:37 bin
 drwxr-xr-x.  4 root root  1024 Oct 27 21:52 boot
 drwxr-xr-x.  4 root root  4096 Oct 27 21:21 dev
 drwxr-xr-x. 86 root root 12288 Oct 28 09:09 etc
 [etc]
inspection 및 mount를 수행하려면 libguestfs 백엔드를 시작해야 하므로 -i 옵션을 사용할 때 run 명령이 필요하지 않습니다. i 옵션은 일반적인 Linux 및 Windows 게스트 가상 머신에서 작동합니다.

16.4.1.3. 이름으로 게스트 가상 머신에 액세스

libvirt에 알려진 이름을 지정할 때 명령줄에서 게스트 가상 시스템에 액세스할 수 있습니다(즉, virsh list --all). d 옵션을 사용하여 - i 옵션을 사용하거나 사용하지 않고 이름으로 게스트 가상 머신에 액세스합니다.
guestfish --ro -d GuestName -i