操作虚拟磁盘文件(virtual disk)的工具。 目前支持的虚拟磁盘文件规范如下表:
spec type support vhd fixed yes vhd dynamic yes vhd differencing no vdi fixed no (coming soon) vdi dynamic no (coming soon) vmdk fixed no vmdk dynamic no
npm install -g vdisk
# 将 boot.bin 程序写入 disk.vhd 文件的启动扇区
vdisk write disk.vhd boot.bin
# 从虚拟磁盘 disk.vhd 的第100扇区(以0开头)开始,写入 data.bin 文件内容
vdisk write disk.vhd data.bin -s 100
# 从虚拟磁盘 disk.vhd 的第100扇区(以0开头)处开始,读取2个扇区的内容
vdisk read disk.vhd -s 100 -c 2
vdisk inspect disk.vhd
vdisk clear disk.vhd
vdisk graph disk.vhd
vdisk --help
# 输出
Usage: vdisk [options] [command]
Options:
-v, --version output the current version
-h, --help display help for command
Commands:
inspect <vhd> inspect virtual disk file structure
read [options] <vhd> read sector data from virtual disk file
write [options] <vhd> <bin> write special binary file to virtual disk file
clear <vhd> clear virtual disk file content
help [command] display help for command
- Virtual Hard Disk Image Format Specification(2006)
- Virtual Hard Disk v2 (VHDX) File Format
- All about VDIs
- VDI Storage's Source
- VDI's Kaitai Struct
最近在B站上看了几个计算机原理方面的视频,突然就来了兴趣,从三极管开始,搭建与/或/非/异或/同或等基本门电路,实现8位全加器等等,一发不可收拾,于是又买了《X86汇编语言:实模式到保护模式》系列课程,开始重新学习x86汇编。
这个课程需要用到作者写的一个FixVhdWr.exe
的工具,用来将汇编写的引导程序写入虚拟磁盘文件的MBR,从而在虚拟机上启动来查看效果,然而这个工具只有Windows版本,我身边又没有Windows操作系统,因此,就搜了一下vhd
文件的格式规范,用nodejs
重新实现了相关功能。
作者为了教学目的只实现了Fixed VHD
文件的写入,课程中所有的汇编程序都是写入到Fixed VHD
磁盘上面的,我为了学习目的,自己实现了Fixed
和Dynamic
两种格式的VHD
文件,并且写了read/write/clear/inspect
等多个命令,算是实现了一个较完整的操作虚拟磁盘文件的工具。