HostOnNet Blog

Mount VM filesystem with guestmount

guestmount is used to mount virtual machine images.

To mount a file system image, use

guestmount -a image.qcow2 -m <device> /path/to/mount/point

Example

[root@et-03-01-srv-001 ~]# wget http://ftp.riken.jp/Linux/fedora/releases/25/CloudImages/x86_64/images/Fedora-Cloud-Base-25-1.3.x86_64.qcow2
--2017-09-02 22:35:16--  http://ftp.riken.jp/Linux/fedora/releases/25/CloudImages/x86_64/images/Fedora-Cloud-Base-25-1.3.x86_64.qcow2
Resolving ftp.riken.jp... 134.160.38.1
Connecting to ftp.riken.jp|134.160.38.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 196662784 (188M) [application/x-troff-man]
Saving to: `Fedora-Cloud-Base-25-1.3.x86_64.qcow2'

100%[=================================================================================================================================================================>] 19,66,62,784 25.9M/s   in 9.1s    

2017-09-02 22:35:26 (20.5 MB/s) - `Fedora-Cloud-Base-25-1.3.x86_64.qcow2' saved [196662784/196662784]

[root@et-03-01-srv-001 ~]# guestmount -a Fedora-Cloud-Base-25-1.3.x86_64.qcow2 /mnt -i
[root@et-03-01-srv-001 ~]# ls -l /mnt
total 76
lrwxrwxrwx.  1 root root     7 Feb  3  2016 bin -> usr/bin
dr-xr-xr-x.  4 root root  4096 Nov 15  2016 boot
drwxr-xr-x.  2 root root  4096 Nov 15  2016 dev
drwxr-xr-x. 67 root root  4096 Nov 15  2016 etc
drwxr-xr-x.  2 root root  4096 Nov 15  2016 home
lrwxrwxrwx.  1 root root     7 Feb  3  2016 lib -> usr/lib
lrwxrwxrwx.  1 root root     9 Feb  3  2016 lib64 -> usr/lib64
drwx------.  2 root root 16384 Nov 15  2016 lost+found
drwxr-xr-x.  2 root root  4096 Feb  3  2016 media
drwxr-xr-x.  2 root root  4096 Feb  3  2016 mnt
drwxr-xr-x.  2 root root  4096 Feb  3  2016 opt
drwxr-xr-x.  2 root root  4096 Nov 15  2016 proc
dr-xr-x---.  2 root root  4096 Nov 15  2016 root
drwxr-xr-x.  2 root root  4096 Nov 15  2016 run
lrwxrwxrwx.  1 root root     8 Feb  3  2016 sbin -> usr/sbin
drwxr-xr-x.  2 root root  4096 Feb  3  2016 srv
drwxr-xr-x.  2 root root  4096 Nov 15  2016 sys
drwxrwxrwt.  7 root root  4096 Nov 15  2016 tmp
drwxr-xr-x. 12 root root  4096 Nov 15  2016 usr
drwxr-xr-x. 19 root root  4096 Nov 15  2016 var
[root@et-03-01-srv-001 ~]# cat  /mnt/etc/*release
Fedora release 25 (Twenty Five)
NAME=Fedora
VERSION="25 (Cloud Edition)"
ID=fedora
VERSION_ID=25
PRETTY_NAME="Fedora 25 (Cloud Edition)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:25"
HOME_URL="https://fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=25
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=25
PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy
VARIANT="Cloud Edition"
VARIANT_ID=cloud
Fedora release 25 (Twenty Five)
Fedora release 25 (Twenty Five)
[root@et-03-01-srv-001 ~]# 

Posted in Linux