官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 水城县| 凤翔县| 体育| 稻城县| 宁都县| 海原县| 文成县| 南江县| 岗巴县| 包头市| 泰州市| 庐江县| 新安县| 潜江市| 长沙县| 卢氏县| 黎川县| 灌云县| 宁城县| 和平区| 大名县| 宁城县| 雷山县| 新津县| 汝州市| 临西县| 施秉县| 上高县| 无为县| 萝北县| 乌拉特后旗| 蒙阴县| 赤壁市| 色达县| 门头沟区| 张家川| 蓬溪县| 广宗县| 桂阳县| 镇巴县| 漠河县|