Linux qemu-nbd mount qemu disk image

Linux qemu-nbd mount qemu disk image

 

复制代码
deepin@deepin:~$ 
deepin@deepin:~$ qemu-nbd --help
Usage: qemu-nbd [OPTIONS] FILE
QEMU Disk Network Block Device Server

  -h, --help                display this help and exit
  -V, --version             output version information and exit

Connection properties:
  -p, --port=PORT           port to listen on (default `10809')
  -b, --bind=IFACE          interface to bind to (default `0.0.0.0')
  -k, --socket=PATH         path to the unix socket
                            (default '/var/lock/qemu-nbd-DEVICE')
  -e, --shared=NUM          device can be shared by NUM clients (default '1')
  -t, --persistent          don't exit on the last connection
  -v, --verbose             display extra debugging information
  -x, --export-name=NAME    expose export by name
  -D, --description=TEXT    with -x, also export a human-readable description

Exposing part of the image:
  -o, --offset=OFFSET       offset into the image
  -P, --partition=NUM       only expose partition NUM

General purpose options:
  --object type,id=ID,...   define an object such as 'secret' for providing
                            passwords and/or encryption keys
  -T, --trace [[enable=]<pattern>][,events=<file>][,file=<file>]
                            specify tracing options
  --fork                    fork off the server process and exit the parent
                            once the server is running
Kernel NBD client support:
  -c, --connect=DEV         connect FILE to the local NBD device DEV
  -d, --disconnect          disconnect the specified device


Block device options:
  -f, --format=FORMAT       set image format (raw, qcow2, ...)
  -r, --read-only           export read-only
  -s, --snapshot            use FILE as an external snapshot, create a temporary
                            file with backing_file=FILE, redirect the write to
                            the temporary one
  -l, --load-snapshot=SNAPSHOT_PARAM
                            load an internal snapshot inside FILE and export it
                            as an read-only device, SNAPSHOT_PARAM format is
                            'snapshot.id=[ID],snapshot.name=[NAME]', or
                            '[ID_OR_NAME]'
  -n, --nocache             disable host cache
      --cache=MODE          set cache mode (none, writeback, ...)
      --aio=MODE            set AIO mode (native or threads)
      --discard=MODE        set discard mode (ignore, unmap)
      --detect-zeroes=MODE  set detect-zeroes mode (off, on, unmap)
      --image-opts          treat FILE as a full set of image options

See <http://qemu.org/contribute/report-a-bug> for how to report bugs.
More information on the QEMU project at <http://qemu.org>.
deepin@deepin:~$ 
deepin@deepin:~$ 
deepin@deepin:~$ grep NBD /boot/config-4.4.102-deepin-server 
CONFIG_BLK_DEV_NBD=m
deepin@deepin:~$ 
deepin@deepin:~$ modinfo nbd
filename:       /lib/modules/4.4.102-deepin-server/kernel/drivers/block/nbd.ko
license:        GPL
description:    Network Block Device
depends:        
intree:         Y
vermagic:       4.4.102-deepin-server SMP mod_unload modversions aarch64
parm:           nbds_max:number of network block devices to initialize (default: 16) (int)
parm:           max_part:number of partitions per device (default: 0) (int)
deepin@deepin:~$ 
deepin@deepin:~$ sudo modprobe nbd max_part=16
deepin@deepin:~$ 
deepin@deepin:~$ sudo ls -al /dev/nbd*
brw-rw---- 1 root disk 43,  0 2月  18 18:33 /dev/nbd0
brw-rw---- 1 root disk 43,  1 2月  18 18:33 /dev/nbd1
brw-rw---- 1 root disk 43, 10 2月  18 18:33 /dev/nbd10
brw-rw---- 1 root disk 43, 11 2月  18 18:33 /dev/nbd11
brw-rw---- 1 root disk 43, 12 2月  18 18:33 /dev/nbd12
brw-rw---- 1 root disk 43, 13 2月  18 18:33 /dev/nbd13
brw-rw---- 1 root disk 43, 14 2月  18 18:33 /dev/nbd14
brw-rw---- 1 root disk 43, 15 2月  18 18:33 /dev/nbd15
brw-rw---- 1 root disk 43,  2 2月  18 18:33 /dev/nbd2
brw-rw---- 1 root disk 43,  3 2月  18 18:33 /dev/nbd3
brw-rw---- 1 root disk 43,  4 2月  18 18:33 /dev/nbd4
brw-rw---- 1 root disk 43,  5 2月  18 18:33 /dev/nbd5
brw-rw---- 1 root disk 43,  6 2月  18 18:33 /dev/nbd6
brw-rw---- 1 root disk 43,  7 2月  18 18:33 /dev/nbd7
brw-rw---- 1 root disk 43,  8 2月  18 18:33 /dev/nbd8
brw-rw---- 1 root disk 43,  9 2月  18 18:33 /dev/nbd9
deepin@deepin:~$ 
deepin@deepin:~$ sudo qemu-nbd --connect=/dev/nbd0 ./vans-kvm.qcow2 --nocache
deepin@deepin:~$ sudo fdisk -l /dev/nbd0
deepin@deepin:~$ sudo ls -l /dev/nbd0*
deepin@deepin:~$ 
deepin@deepin:~$ sudo mkdir -p /mnt/bsd_system
deepin@deepin:~$ sudo chmod 777 /mnt/bsd_system
deepin@deepin:~$ sudo mount -t ufs -o ro,ufstype=44bsd /dev/nbd0p5 /mnt/bsd_system
deepin@deepin:~$ 
deepin@deepin:~$ sudo mkdir -p /mnt/bsd_data
deepin@deepin:~$ sudo chmod 777 /mnt/bsd_data
deepin@deepin:~$ sudo mount -t ufs -o ro,ufstype=44bsd /dev/nbd0p7 /mnt/bsd_data
deepin@deepin:~$ 
deepin@deepin:~$ sudo mkdir -p /mnt/fat_dos
deepin@deepin:~$ sudo chmod 777 /mnt/fat_dos
deepin@deepin:~$ sudo mount -t vfat -o ro,umask=000,noatime,async,codepage=936,iocharset=gb2312 /dev/nbd0p2 /mnt/fat_dos
deepin@deepin:~$ 
deepin@deepin:~$ sudo umount /mnt/bsd_system
deepin@deepin:~$ sudo umount /mnt/bsd_data
deepin@deepin:~$ sudo umount /mnt/fat_dos
deepin@deepin:~$ sudo qemu-nbd --disconnect /dev/nbd0
deepin@deepin:~$ 
复制代码

 

============ End

 

posted @   lsgxeva  阅读(956)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
历史上的今天:
2018-02-19 net user命令集合详解
2018-02-19 metasploit下Windows下多种提权方式
点击右上角即可分享
微信分享提示