Home System Tutorial LINUX How to mount VHD and other virtual disk files in linux

How to mount VHD and other virtual disk files in linux

Jan 09, 2024 am 10:17 AM
Disk mount

1. RAW format virtual disk

Under Linux, virtual disk image files in raw format can be directly mounted.

For example, here first use the dd command to create a file, then format it into ext4 format (only one partition), and then mount it to the /mnt directory.

The raw.img disk image file below is only one partition, so offset= is not used to specify the offset. If there are multiple partitions, they can be mounted by specifying offsets. For specific information, please refer to the relevant parameter information of the mount command.

> dd if=/dev/zero of=raw.img bs=1M count=512

Recorded the read of 512 0

Recorded the writing of 512 0

536870912 bytes (537 MB, 512 MiB) copied, 0.207045 s, 2.6 GB/s

/home/o [o@o-pc] [10:29]

> mkfs.ext4 -q raw.img

/home/o [o@o-pc] [10:30]

> sudo mount -o loop raw.img /mnt

/home/o [o@o-pc] [10:30]

> df -h

How to mount VHD and other virtual disk files in linux

2. VHD/VHDX disk file mounting

Linux cannot directly support mounting VHD disk image files. It can be mounted through tools such as vmware's vmware-mount. VMware does not provide this tool directly, but it is available in vmware player and vmware workstation. But that's not the way to go here.

Qemu-nbd is used here to mount the disk image file.

a) Install qemu

First of all, you need to install qemu-kvm. I am using Fedora 25 here. The installation command is as follows

sudo dnf install qemu-kvm

If you are using debian/ubuntu, etc., you can use sudo apt-get install qemu-kvm to install.

archlinux can be installed using sudo pacman -S qemu.

b) Load nbd driver

NBD (Network Block Device) is the abbreviation of Network Block Device. This module can use the disk space of a remote host (different from mounting nfs) as a local block device.

NBD is a kernel module. Most Linux distributions already include it. There is no need to install it here.

Use modprobe to load nbd driver

/media/o/data [o@o-pc] [11:04]

> sudo modprobe nbd max_part=8

After loading is complete, you can use the modinfo command to view module information

/media/o/data [o@o-pc] [11:05]

> modinfo nbd

filename: /lib/modules/4.9.6-200.fc25.x86_64/kernel/drivers/block/nbd.ko.xz

license: GPL

description: Network Block Device

depends:    

intree: Y

vermagic: 4.9.6-200.fc25.x86_64 SMP mod_unload

signat: PKCS#7

signer:      

sig_key:  

sig_hashalgo: md4

parm: nbds_max:number of network block devices to initialize (default: 16) (int)

parm: max_part:number of partitions per device (default: 0) (int)

The above information says that the number of initialized network block devices is 16, indicating that it creates 16 nbd devices under /dev/.

/media/o/data [o@o-pc] [11:05]

> ls /dev/nbd*

/dev/nbd0 /dev/nbd0p1 /dev/nbd1 /dev/nbd10 /dev/nbd11 /dev/nbd12 /dev/nbd13 /dev/nbd14 /dev/nbd15 /dev/nbd2 /dev/nbd3 /dev/ nbd4 /dev/nbd5 /dev/nbd6 /dev/nbd7 /dev/nbd8 /dev/nbd9

c) Connect vhdx file to nbd device

Use qemu-nbd here to connect (use the -c parameter to connect, use the -d parameter to disconnect)

/media/o/data [o@o-pc] [11:05]

> sudo qemu-nbd -c /dev/nbd0 VS2017RC-offline.vhdx

After connecting, use fdisk to check the device information.

/media/o/data [o@o-pc] [11:05]

> sudo fdisk -l /dev/nbd0

Disk /dev/nbd0: 100 GiB, 107374182400 bytes, 209715200 sectors

Unit: sector / 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0xa373e501

How to mount VHD and other virtual disk files in linux

In fact, the disk has only one partition, the partition format is exFAT, and the disk size grows dynamically.

d)Mount partition

Just use the mount command to mount nbd0p1

/media/o/data [o@o-pc] [11:36]

> sudo mount -t exfat -o rw /dev/nbd0p1 /mnt

[sudo] Password for o:

FUSE exfat 1.0.1

/media/o/data [o@o-pc] [12:05]

> ls /mnt/

'$RECYCLE.BIN' 'System Volume Information' vs2017rc Installation Instructions.txt

Install exFAT support

Because the partition is in exFAT format, it cannot be mounted directly.

First install fuse-exfat and exfat-utils.

Let’s briefly talk about the specific installation process

First download two rpm source packages.

wget http://download1.rpmfusion.org/free/el/updates/6/SRPMS/exfat-utils-1.0.1-2.el6.src.rpm

wget http://download1.rpmfusion.org/free/el/updates/6/SRPMS/exfat-utils-1.0.1-2.el6.src.rpm

Then install fuse-devel and rpmbuild, and decompress the src.rpm package.

sudo dnf install fuse-devel rpmbuild

sudo dnf install scons #Required to build exfat-utils

rpm -ivh exfat-utils-1.0.1-2.el6.src.rpm exfat-utils-1.0.1-2.el6.src.rpm

After decompression is completed, you can see the rpmbuild directory in the current user's home directory and enter the SPECS directory under this directory.

Then use rpmbuild to build the rpm package.

rpmbuild -ba exfat-utils.spec

rpmbuild -ba fuse-exfat.spec

After the build is completed, enter the rpmbuild/RPMS/x86_64 directory (x86_64 here is related to your system architecture) and install the generated rpm package.

/home/o/rpmbuild/RPMS/x86_64 [o@o-pc] [12:04]

> sudo rpm -ivh exfat-utils-1.0.1-2.fc25.x86_64.rpm fuse-exfat-1.0.1-1.fc25.x86_64.rpm

Preparing...                                                                                                                                                                                                                            

#[100%]

Upgrading/installing...

###1:fuse-exfat-1.0.1-1.fc25 ################################ [ 50%]### ###2:exfat-utils-1.0.1-2.fc25 ################################ [ 100%]### ###On ubuntu, you can directly use apt to install sudo apt install exfat-utils exfat-fuse### ###3. Mounting of other virtual disk files### ###I won’t say anything else anymore. It is the same as the VHD mounting above, provided that it is a supported disk image format. ###

The above is the detailed content of How to mount VHD and other virtual disk files in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How To Count Files And Directories In Linux: A Beginner's Guide How To Count Files And Directories In Linux: A Beginner's Guide Mar 19, 2025 am 10:48 AM

Efficiently Counting Files and Folders in Linux: A Comprehensive Guide Knowing how to quickly count files and directories in Linux is crucial for system administrators and anyone managing large datasets. This guide demonstrates using simple command-l

How To Add A User To Multiple Groups In Linux How To Add A User To Multiple Groups In Linux Mar 18, 2025 am 11:44 AM

Efficiently managing user accounts and group memberships is crucial for Linux/Unix system administration. This ensures proper resource and data access control. This tutorial details how to add a user to multiple groups in Linux and Unix systems. We

How To Easily Configure Flatpak Apps Permissions With Flatseal How To Easily Configure Flatpak Apps Permissions With Flatseal Mar 22, 2025 am 09:21 AM

Flatpak application permission management tool: Flatseal User Guide Flatpak is a tool designed to simplify Linux software distribution and use. It safely encapsulates applications in a virtual sandbox, allowing users to run applications without root permissions without affecting system security. Because Flatpak applications are located in this sandbox environment, they must request permissions to access other parts of the operating system, hardware devices (such as Bluetooth, network, etc.) and sockets (such as pulseaudio, ssh-auth, cups, etc.). This guide will guide you on how to easily configure Flatpak with Flatseal on Linux

How To List Or Check All Installed Linux Kernels From Commandline How To List Or Check All Installed Linux Kernels From Commandline Mar 23, 2025 am 10:43 AM

Linux Kernel is the core component of a GNU/Linux operating system. Developed by Linus Torvalds in 1991, it is a free, open-source, monolithic, modular, and multitasking Unix-like kernel. In Linux, it is possible to install multiple kernels on a sing

How To Type Indian Rupee Symbol In Ubuntu Linux How To Type Indian Rupee Symbol In Ubuntu Linux Mar 22, 2025 am 10:39 AM

This brief guide explains how to type Indian Rupee symbol in Linux operating systems. The other day, I wanted to type "Indian Rupee Symbol (₹)" in a word document. My keyboard has a rupee symbol on it, but I don't know how to type it. After

What is the Linux best used for? What is the Linux best used for? Apr 03, 2025 am 12:11 AM

Linux is best used as server management, embedded systems and desktop environments. 1) In server management, Linux is used to host websites, databases, and applications, providing stability and reliability. 2) In embedded systems, Linux is widely used in smart home and automotive electronic systems because of its flexibility and stability. 3) In the desktop environment, Linux provides rich applications and efficient performance.

Linux Kernel 6.14 RC6 Released Linux Kernel 6.14 RC6 Released Mar 24, 2025 am 10:21 AM

Linus Torvalds has released Linux Kernel 6.14 Release Candidate 6 (RC6), reporting no significant issues and keeping the release on track. The most notable change in this update addresses an AMD microcode signing issue, while the rest of the updates

Yt-dlp Commands: The Complete Tutorial For Beginners (2025) Yt-dlp Commands: The Complete Tutorial For Beginners (2025) Mar 21, 2025 am 11:00 AM

Have you ever wanted to save your favorite videos from the internet? Whether it's a funny cat video or a tutorial you want to watch later, Yt-dlp is here to help! In this comprehensive yt-dlp tutorial, we will explain what yt-dlp is, how to install i

See all articles