非vdfuse的方法:如何将vmdk或vdi映像文件以块设备的形式挂载到CentOS/Ubuntu系统
因vdfuse只支持virtualbox4.x,目前已经在新版ubuntu或centos中取消,换个思路,可以使用qemu+nbd的方法挂载vmdk,vdi,vhd,vhdx等格式的磁盘。
以下方法在centos7上实现。
1、编译内核,编译nbd为模块。
1
2
3
4
5
6
7
|
yum groupinstall "DevelopmentTools"
yum install
gcc ncurses ncurses-devel bc
yum update wget https: //www .kernel.org /pub/linux/kernel/v4 .x /linux-4 .0. tar .xz
tar
-xf linux-4.0. tar .xz -C /usr/src/
cd
/usr/src/linux-4 .0/
make
menuconfig
|
在配置界面,进入菜单
Device Drivers → Block devices
选中:
<M> Network block device support
保存,退出:
< Save >
< Exit >
大致如下图:
.config - Linux/x86 4.0.0 Kernel Configuration
→ Device Drivers → Block devices ─────────────────────────────────────────────
┌───────────────────────────── Block devices ─────────────────────────────┐
│ Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty │
│ submenus ----). Highlighted letters are hotkeys. Pressing <Y> │
│ includes, <N> excludes, <M> modularizes features. Press <Esc><Esc> to │
│ exit, <?> for Help, </> for Search. Legend: [*] built-in [ ] │
│ ┌────↑(-)─────────────────────────────────────────────────────────────┐ │
│ │ [*] Compressed RAM block device debug support │ │
│ │ < > Compaq Smart Array 5xxx support │ │
│ │ < > Mylex DAC960/DAC1100 PCI RAID Controller support │ │
│ │ < > Micro Memory MM5415 Battery Backed RAM support │ │
│ │ <M> Loopback device support │ │
│ │ (0) Number of loop devices to pre-create at init time │ │
│ │ < > Cryptoloop Support │ │
│ │ < > DRBD Distributed Replicated Block Device support │ │
│ │ <M> Network block device support │ │
│ │ <M> NVM Express block device │ │
│ └────↓(+)─────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > < Save > < Load > │
└─────────────────────────────────────────────────────────────────────────┘