- KVM Virtualization Cookbook
- Konstantin Ivanov
- 198字
- 2021-07-02 22:07:05
How it works...
We take advantage of the functionality that the nbd kernel module provides by allowing us to associate a raw image file to a block device using the qemu-nbd utility. To get more information about the kernel module run the following code:
root@kvm:~# modinfo nbd
filename: /lib/modules/4.4.0-62-generic/kernel/drivers/block/nbd.ko
license: GPL
description: Network Block Device
srcversion: C67096AF2AE3C738DBE0B7E
depends:
intree: Y
vermagic: 4.4.0-62-generic SMP mod_unload modversions
parm: nbds_max:number of network block devices to initialize (default: 16) (int)
parm: max_part:number of partitions per device (default: 0) (int)
root@kvm:~#
We can examine the block device metadata created in step 2 by running the following command:
root@kvm:~# file -s /dev/nbd0
/dev/nbd0: x86 boot sector
root@kvm:~#
After creating the two new partitions in step 3, the type of the image file has changed. Let's examine it again:
root@kvm:~# file -s debian.img
debian.img: x86 boot sector
root@kvm:~#
We chose to use the sfdisk utility to create the partitions, but you can use the fdisk utility interactively instead if you prefer. The end result will be the same.
Now that we have an image file that contains two partitions and a filesystem, we can proceed with installing the guest OS in the next recipe.
推薦閱讀
- Learning Python Web Penetration Testing
- Python量化投資指南:基礎、數據與實戰
- LabVIEW入門與實戰開發100例
- PHP 7底層設計與源碼實現
- Python網絡爬蟲從入門到實踐(第2版)
- 高級C/C++編譯技術(典藏版)
- PHP+MySQL+Dreamweaver動態網站開發實例教程
- RabbitMQ Cookbook
- iOS開發實戰:從入門到上架App Store(第2版) (移動開發叢書)
- 從零開始學Linux編程
- 深入實踐Kotlin元編程
- Android Development Tools for Eclipse
- Flask Web開發:基于Python的Web應用開發實戰(第2版)
- H5+移動營銷設計寶典
- SQL Server實例教程(2008版)