内核实验(四):Qemu调试Linux内核,实现NFS挂载

这篇具有很好参考价值的文章主要介绍了内核实验(四):Qemu调试Linux内核,实现NFS挂载。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一、篇头

在文章《内核实验(三)……》中,通过挂载虚拟分区,解决了Host和虚拟机文件交换的问题,但依旧比较麻烦。为了提升效率,必须解决NFS挂载共享文件夹的问题。如能实现,则直接在虚拟机上挂载服务端的NFS目录,即可实时交换文件,大大提升效率!

二、服务端配置

关于Qemu虚拟机挂载NFS分区,网上的文章,搜了一大圈,都有问题。一时运气好,偶尔配通了,最后复合步骤,发现更本就不需要做那些动作,这难道就是用新版本的好处?不用再去搞什么虚拟网卡、网桥,以及netplan那一堆配置,够恶心的……,就了个测试,实在不想花那么多时间去,去学那么多一年355天都没用的东西……

2.1 运行环境

  • 服务器:Ubuntu 22.04 + QEMU emulator version 6.2.0
  • rootfs:Linux version 5.15.102 + Busybox 1.36-stable
  • 比起网上的Qemu NFS挂载的繁琐方法,本文运气好,使用下面的软件版本,不需要走那么多弯路!
2.1.1 Qemu 版本
szhou@bc01:~$  qemu-system-arm --version
QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.6)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
szhou@bc01:~$ 
2.1.2 rootfs 版本
~ # cat /proc/version 
Linux version 5.15.102 (szhou@bc01) (arm-linux-gnueabi-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #12 SMP Fri Mar 17 19:32:42 CST 2023
~ # 
2.1.3 Buysbox 版本
* f15dfd86c - (origin/1_36_stable, 1_36_stable) ed: don't use memcpy with overlapping memory regions (2 months ago) <Sören Tempel>
2.1.4 避开: 不用安装
  • 网上的其他教程,在服务端和客户端,都得安装下面的两个工具,一个是虚拟网卡,一个是网桥
# tunctl
szhou@bc01:~/works/qemu_linux/busybox$ sudo apt install uml-utilities

# brctl
szhou@bc01:~/works/qemu_linux/busybox$ sudo apt install bridge-utils

2.2 服务端

2.2.1 安装NFS server
sudo apt-get install nfs-kernel-server
2.2.2 配置NFS server
# (1)编辑 /etc/exports  
szhou@bc01:~/works/qemu_linux/linux-stable$ sudo vim /etc/exports  

 # (2)在 /etc/exports 中添加共享文件夹的和属性, 如下所示
szhou@bc01:~/works/qemu_linux/busybox$ cat  /etc/exports 
# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/home/szhou/works/nfs_share *(rw,sync,no_root_squash,no_subtree_check,insecure)
szhou@bc01:~/works/qemu_linux/busybox$ 

2.2.3 启动NFS server
szhou@bc01:~/works/qemu_linux/busybox$ sudo service nfs-kernel-server restart
[sudo] password for szhou: 
szhou@bc01:~/works/qemu_linux/busybox$ sudo exportfs
/home/szhou/works/nfs_share
                <world>
szhou@bc01:~/works/qemu_linux/busybox$ 

三、客户端配置

本节给qemu虚拟机添加一个dhcp的脚本,用于获取IP地址,同时在开机的时候启动eth0网卡获取IP。获取之后,即可ping测试,挂载NFS分区。

3.1 添加 dhcp client

# (1)进入busybox 源码目录
cd ~/works/qemu_linux/busybox/

# (2)进入busybox 目录下,之前make install ,生成的制作rootfs的文件目录
cd _install_ARM32_vexpress/

# (3)复制 dhcp 脚本工具,用于执行dhcp client动作
mkdir -p usr/share/udhcpc
cp  examples/udhcp/simple.script usr/share/udhcpc/default.script

3.2 修改开机脚本


# (4)编辑 etc/init.d/rcS, 添加第17行和第18行,对网卡做初始化动作,并dhcp获取ip
# szhou@bc01:~/works/qemu_linux/busybox/_install_ARM32_vexpress$ vim etc/init.d/rcS 
# 内容如下所示:

#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
LD_LIBRARY_PATH=/lib
export PATH LD_LIBRARY_PATH

mount -a
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
mkdir -p /var/lock
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
echo -e "Remounting the root filesystem"
mount  -o  remount,rw  /
ifconfig eth0 0.0.0.0 up
udhcpc -i eth0
echo "----------------------------------------"
echo -e "Welcome to szhou's tiny Linux"

3.3 重新制作 rootfs

# (5)重新打包制作rootfs.ext4.img.gz 文件
szhou@bc01:~/works/qemu_linux/busybox$ dd if=/dev/zero of=./rootfs.ext4 bs=1M count=32
32+0 records in
32+0 records out
33554432 bytes (34 MB, 32 MiB) copied, 0.106609 s, 315 MB/s
szhou@bc01:~/works/qemu_linux/busybox$ mkfs.ext4 rootfs.ext4 
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done                            
Creating filesystem with 8192 4k blocks and 8192 inodes

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

szhou@bc01:~/works/qemu_linux/busybox$ mkdir fs_ext4
szhou@bc01:~/works/qemu_linux/busybox$ sudo mount -o loop rootfs.ext4 fs_ext4
[sudo] password for szhou: 
szhou@bc01:~/works/qemu_linux/busybox$ sudo cp -rf _install_ARM32_vexpress/* fs_ext4/
szhou@bc01:~/works/qemu_linux/busybox$ sudo umount fs_ext4 
szhou@bc01:~/works/qemu_linux/busybox$ gzip --best -c rootfs.ext4  > rootfs.ext4.img.gz
szhou@bc01:~/works/qemu_linux/busybox$ 

四、测试

4.1 服务端操作

szhou@bc01:~$ sudo service nfs-kernel-server restart
[sudo] password for szhou: 
szhou@bc01:~$ sudo exportfs
/home/szhou/works/nfs_share
                <world>
szhou@bc01:~$ 

4.2 Qemu 客户端操作

4.2.1 启动 Qemu
szhou@bc01:~/works/qemu_linux/linux-stable$  qemu-system-arm   -nographic  -M vexpress-a9 -m 1024M -kernel arch/arm/boot/zImage   -initrd ../busybox/rootfs.ext4.img.gz    -dtb arch/arm/boot/dts/vexpress-v2p-ca9.dtb
4.2.2 挂载NFS
#(1) 等待进入系统
----------------------------------------
Welcome to szhou's tiny Linux
----------------------------------------

Please press Enter to activate this console. 

#(2) 使用ping测试与服务器的连通性,服务器IP=192.168.3.67,可见是连通的,以此为基础,才可以进行NFS挂载
~ # ping 192.168.3.67
PING 192.168.3.67 (192.168.3.67): 56 data bytes
64 bytes from 192.168.3.67: seq=0 ttl=255 time=36.569 ms
64 bytes from 192.168.3.67: seq=1 ttl=255 time=21.056 ms
^C
--- 192.168.3.67 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 21.056/28.812/36.569 ms

#(3)挂载NFS服务端
~ # 
~ #  mount -t nfs -o nolock 192.168.3.67:/home/szhou/works/nfs_share /mnt

#(4)查看NFS目录情况,符合预期,操作成功
~ # ls -l /mnt/
total 0
-rw-rw-rw-    1 0        0                0 Mar 17 16:35 abc_client
~ # 
4.2.3 完整打印
szhou@bc01:~/works/qemu_linux/linux-stable$ qemu-system-arm   -nographic  -M vexpress-a9 -m 1024M -kernel arch/arm/boot/zImage   -initrd ../busybox/rootfs.ext4.img.gz    -dtb arch/arm/boot/dts/vexpress-v2p-ca9.dtb
xcb_connection_has_error() returned true
pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument
Booting Linux on physical CPU 0x0
Linux version 5.15.102 (szhou@bc01) (arm-linux-gnueabi-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #12 SMP Fri Mar 17 19:32:42 CST 2023
CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
OF: fdt: Machine model: V2P-CA9
Memory policy: Data cache writeback
Reserved memory: created DMA memory pool at 0x4c000000, size 8 MiB
OF: reserved mem: initialized node vram@4c000000, compatible id shared-dma-pool
cma: Reserved 16 MiB at 0x9f000000
Zone ranges:
  Normal   [mem 0x0000000060000000-0x000000009fffffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x0000000060000000-0x000000009fffffff]
Initmem setup node 0 [mem 0x0000000060000000-0x000000009fffffff]
CPU: All CPU(s) started in SVC mode.
percpu: Embedded 15 pages/cpu s30220 r8192 d23028 u61440
Built 1 zonelists, mobility grouping on.  Total pages: 260096
Kernel command line: console=ttyAMA0
printk: log_buf_len individual max cpu contribution: 4096 bytes
printk: log_buf_len total cpu_extra contributions: 12288 bytes
printk: log_buf_len min size: 16384 bytes
printk: log_buf_len: 32768 bytes
printk: early log buf free: 14988(91%)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
mem auto-init: stack:off, heap alloc:off, heap free:off
Memory: 1009508K/1048576K available (8192K kernel code, 591K rwdata, 1780K rodata, 1024K init, 147K bss, 22684K reserved, 16384K cma-reserved)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
trace event string verifier disabled
rcu: Hierarchical RCU implementation.
rcu:    RCU event tracing is enabled.
rcu:    RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
GIC CPU mask not found - kernel will fail to boot.
GIC CPU mask not found - kernel will fail to boot.
L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 dynamic clock gating disabled, standby mode disabled
L2C-310 cache controller enabled, 8 ways, 128 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
smp_twd: clock not found -2
Console: colour dummy device 80x30
Calibrating local timer... 94.06MHz.
Calibrating delay loop... 571.80 BogoMIPS (lpj=2859008)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
CPU: Testing write buffer coherency: ok
CPU0: Spectre v2: using BPIALL workaround
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x60100000 - 0x60100060
rcu: Hierarchical SRCU implementation.
smp: Bringing up secondary CPUs ...
smp: Brought up 1 node, 1 CPU
SMP: Total of 1 processors activated (571.80 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 0
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
NET: Registered PF_NETLINK/PF_ROUTE protocol family
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
hw-breakpoint: debug architecture 0x4 unsupported.
Serial: AMBA PL011 UART driver
irq: type mismatch, failed to map hwirq-75 for interrupt-controller@1e001000!
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm,sp804
NET: Registered PF_INET protocol family
IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)
TCP bind hash table entries: 8192 (order: 4, 65536 bytes, linear)
TCP: Hash tables configured (established 8192 bind 8192)
UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
NET: Registered PF_UNIX/PF_LOCAL protocol family
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs...
rootfs image is not initramfs (no cpio magic); looks like an initrd
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 5 counters available
workingset: timestamp_bits=30 max_order=18 bucket_order=0
Freeing initrd memory: 1188K
squashfs: version 4.0 (2009/01/31) Phillip Lougher
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
9p: Installing v9fs 9p2000 file system support
io scheduler mq-deadline registered
io scheduler kyber registered
sii902x 0-0060: supply iovcc not found, using dummy regulator
sii902x 0-0060: supply cvcc12 not found, using dummy regulator
brd: module loaded
physmap-flash 40000000.flash: physmap platform flash device: [mem 0x40000000-0x43ffffff]
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
physmap-flash 40000000.flash: physmap platform flash device: [mem 0x44000000-0x47ffffff]
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
Concatenating MTD devices:
(0): "40000000.flash"
(1): "40000000.flash"
into device "40000000.flash"
physmap-flash 48000000.psram: physmap platform flash device: [mem 0x48000000-0x49ffffff]
smsc911x 4e000000.ethernet eth0: MAC Address: 52:54:00:12:34:56
isp1760 4f000000.usb: isp1760 bus width: 32, oc: digital
isp1760 4f000000.usb: NXP ISP1760 USB Host Controller
isp1760 4f000000.usb: new USB bus registered, assigned bus number 1
isp1760 4f000000.usb: Scratch test failed. 0x00000000
isp1760 4f000000.usb: can't setup: -19
isp1760 4f000000.usb: USB bus 1 deregistered
usbcore: registered new interface driver usb-storage
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
NET: Registered PF_PACKET protocol family
9pnet: Installing 9P2000 support
Registering SWP/SWPB emulation handler
aaci-pl041 10004000.aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 32
aaci-pl041 10004000.aaci: FIFO 512 entries
mmci-pl18x 10005000.mmci: Got CD GPIO
mmci-pl18x 10005000.mmci: Got WP GPIO
mmci-pl18x 10005000.mmci: mmc0: PL181 manf 41 rev0 at 0x10005000 irq 33,34 (pio)
10009000.uart: ttyAMA0 at MMIO 0x10009000 (irq = 37, base_baud = 0) is a PL011 rev1
printk: console [ttyAMA0] enabled
1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = 38, base_baud = 0) is a PL011 rev1
1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = 39, base_baud = 0) is a PL011 rev1
1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = 40, base_baud = 0) is a PL011 rev1
rtc-pl031 10017000.rtc: registered as rtc0
rtc-pl031 10017000.rtc: setting system clock to 2023-03-17T17:48:08 UTC (1679075288)
amba 10020000.clcd: Fixing up cyclic dependency with 0-0039
drm-clcd-pl111 10020000.clcd: DVI muxed to daughterboard 1 (core tile) CLCD
input: AT Raw Set 2 keyboard as /devices/platform/bus@40000000/bus@40000000:motherboard-bus@40000000/bus@40000000:motherboard-bus@40000000:iofpga@7,00000000/10006000.kmi/serio0/input/input0
drm-clcd-pl111 10020000.clcd: initializing Versatile Express PL111
sii902x 0-0039: supply iovcc not found, using dummy regulator
sii902x 0-0039: supply cvcc12 not found, using dummy regulator
i2c i2c-0: Added multiplexed i2c bus 2
drm-clcd-pl111 1001f000.clcd: assigned reserved memory node vram@4c000000
drm-clcd-pl111 1001f000.clcd: using device-specific reserved memory
drm-clcd-pl111 1001f000.clcd: core tile graphics present
drm-clcd-pl111 1001f000.clcd: this device will be deactivated
drm-clcd-pl111 1001f000.clcd: Versatile Express init failed - -19
drm-clcd-pl111 10020000.clcd: DVI muxed to daughterboard 1 (core tile) CLCD
drm-clcd-pl111 10020000.clcd: initializing Versatile Express PL111
drm-clcd-pl111 10020000.clcd: found bridge on endpoint 0
drm-clcd-pl111 10020000.clcd: Using non-panel bridge
[drm] Initialized pl111 1.0.0 20170317 for 10020000.clcd on minor 0
Console: switching to colour frame buffer device 128x48
drm-clcd-pl111 10020000.clcd: [drm] fb0: pl111drmfb frame buffer device
ALSA device list:
  #0: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 32
input: ImExPS/2 Generic Explorer Mouse as /devices/platform/bus@40000000/bus@40000000:motherboard-bus@40000000/bus@40000000:motherboard-bus@40000000:iofpga@7,00000000/10007000.kmi/serio1/input/input2
RAMDISK: gzip image found at block 0
using deprecated initrd support, will be removed in 2021.
EXT4-fs (ram0): mounted filesystem with ordered data mode. Opts: (null). Quota mode: disabled.
VFS: Mounted root (ext4 filesystem) on device 1:0.
mount: mounting debugfs on /sys/kernel/debug failed: No such file or directory
Remounting the root filesystem
EXT4-fs (ram0): re-mounted. Opts: (null). Quota mode: disabled.
Generic PHY 4e000000.ethernet-ffffffff:01: attached PHY driver (mii_bus:phy_addr=4e000000.ethernet-ffffffff:01, irq=POLL)
smsc911x 4e000000.ethernet eth0: SMSC911x/921x identified at 0xc0940000, IRQ: 30
udhcpc: started, v1.36.0
Clearing IP addresses on eth0, upping it
udhcpc: broadcasting discover
udhcpc: broadcasting select for 10.0.2.15, server 10.0.2.2
udhcpc: lease of 10.0.2.15 obtained from 10.0.2.2, lease time 86400
Setting IP address 10.0.2.15 on eth0
Deleting routers
route: SIOCDELRT: No such process
Adding router 10.0.2.2
Recreating /etc/resolv.conf
 Adding DNS server 10.0.2.3
----------------------------------------
Welcome to szhou's tiny Linux
----------------------------------------

Please press Enter to activate this console. 
~ # ping 192.168.3.67
PING 192.168.3.67 (192.168.3.67): 56 data bytes
64 bytes from 192.168.3.67: seq=0 ttl=255 time=36.569 ms
64 bytes from 192.168.3.67: seq=1 ttl=255 time=21.056 ms
^C
--- 192.168.3.67 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 21.056/28.812/36.569 ms
~ # 
~ #  mount -t nfs -o nolock 192.168.3.67:/home/szhou/works/nfs_share /mnt
~ # ls -al
total 52
drwxr-xr-x   13 0        0             4096 Mar 17 17:48 .
drwxr-xr-x   13 0        0             4096 Mar 17 17:48 ..
-rw-------    1 0        0               95 Mar 17 17:48 .ash_history
drwxr-xr-x    2 0        0             4096 Mar 17 17:44 bin
drwxrwxrwt    6 0        0             3100 Mar 17 17:48 dev
drwx------    3 0        0             4096 Mar 17 17:48 etc
lrwxrwxrwx    1 0        0               11 Mar 17 17:44 linuxrc -> bin/busybox
drwx------    2 0        0            16384 Mar 17 17:43 lost+found
drwxrwxr-x    2 1000     1000          4096 Mar 17 16:35 mnt
dr-xr-xr-x  111 0        0                0 Mar 17 17:48 proc
drwxr-xr-x    2 0        0             4096 Mar 17 17:44 sbin
dr-xr-xr-x   12 0        0                0 Mar 17 17:48 sys
drwxrwxrwt    2 0        0               40 Mar 17 17:48 tmp
drwxr-xr-x    5 0        0             4096 Mar 17 17:44 usr
drwxr-xr-x    3 0        0             4096 Mar 17 17:48 var
~ # ls -l /mnt/
total 0
-rw-rw-rw-    1 0        0                0 Mar 17 16:35 abc_client
~ # 
4.2.4 快速测试Qemu客户端的方法(可选)
~ #ifconfig eth0 0.0.0.0 up
~ #udhcpc -i eth0
~ # ping 192.168.3.67
PING 192.168.3.67 (192.168.3.67): 56 data bytes
64 bytes from 192.168.3.67: seq=0 ttl=255 time=36.569 ms
64 bytes from 192.168.3.67: seq=1 ttl=255 time=21.056 ms
^C
--- 192.168.3.67 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 21.056/28.812/36.569 ms
~ # 
~ #  mount -t nfs -o nolock 192.168.3.67:/home/szhou/works/nfs_share /mnt

4.3 NFS成功的画面

不知什么时候开始,非得加个图片,就秀下成功画面吧……
qemu解除nfs挂载,Linux内核学习,linux,Linux内核调试,Qemu,驱动开发文章来源地址https://www.toymoban.com/news/detail-785559.html

五、错误处理

5.1 nfs客户端挂载失败

5.1.1 错误现象:
~ # mount -t nfs -o nolock 192.168.3.67:/home/szhou/works/nfs_share /mnt
mount: mounting 192.168.3.67:/home/szhou/works/nfs_share on /mnt failed: Permission denied
~ # 
5.1.2 查看服务端日志
  • 错误提示:illegal port 46824
szhou@bc01:~/works/qemu_linux/linux-stable$ tail /var/log/syslog
Mar 18 00:20:50 bc01 rpc.mountd[250822]: refused mount request from 192.168.3.67 for / (/): not exported
Mar 18 00:20:50 bc01 rpc.mountd[250822]: refused mount request from 192.168.3.67 for / (/): not exported
Mar 18 00:22:41 bc01 systemd-resolved[18072]: Grace period over, resuming full feature set (UDP+EDNS0) for DNS server 192.168.3.1.
Mar 18 00:22:41 bc01 systemd-resolved[18072]: Using degraded feature set UDP instead of UDP+EDNS0 for DNS server 192.168.3.1.
Mar 18 00:23:36 bc01 rpc.mountd[250822]: refused mount request from 192.168.3.67 for /home/szhou/works/nfs_share (/home/szhou/works/nfs_share): illegal port 46824
Mar 18 00:23:36 bc01 rpc.mountd[250822]: refused mount request from 192.168.3.67 for /home/szhou/works/nfs_share (/home/szhou/works/nfs_share): illegal port 46838
Mar 18 00:25:01 bc01 CRON[279481]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Mar 18 00:27:08 bc01 systemd[1]: Started Session 137 of User szhou.
Mar 18 00:31:51 bc01 systemd[1]: session-30.scope: Deactivated successfully.
Mar 18 00:31:51 bc01 systemd[1]: session-30.scope: Consumed 2h 26min 25.169s CPU time.
szhou@bc01:~/works/qemu_linux/linux-stable$ 
5.1.3 解决办法
szhou@bc01:~/works/qemu_linux/linux-stable$ sudo vim /etc/exports  

#修改前
/home/szhou/works/nfs_share *(rw,sync)
#修改后               
/home/szhou/works/nfs_share *(rw,sync,no_root_squash,no_subtree_check,insecure) 

到了这里,关于内核实验(四):Qemu调试Linux内核,实现NFS挂载的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Openharmony鸿蒙内核编译及qemu运行过程问题记录

    该篇笔记记录鸿蒙内核编译流程,及qemu运行记录。主要根据 https://gitee.com/openharmony/device_qemu 执行。由于整个过程不是很顺利,故做此笔记。(ps:因为笔者的ubuntu环境不纯净,坑较多。纯净的环境照着文档做应该问题不大) 采用的策略是,【docker编译】+【ubuntu执行qemu】 纯

    2024年02月11日
    浏览(47)
  • 正点原子 imx6ull linux 更新内核与设备树 通过nfs挂载

    通过修改linux正点原子imx6ull设备树,防止led灯占用 编译内核与设备树 1.将原子的镜像解压到ubuntu虚拟机 2.使用tar -xf linux…解压到某一文件夹 3.修改设备树文件(imx6ull-alientek-emmc.dts) 在leds下面添加 4.编译设备树 在源码 根目录 下 (非必须)4-2.编译内核 在源码 根目录 下 如果已经

    2024年02月08日
    浏览(42)
  • qemu-基础篇——arm 裸机调试环境搭建

    裸机篇系列文章主要用于熟悉 arm 汇编及处理器结构 本系列使用 mcimx6ul-evk mcimx6ul-evk 0x80000000-0xFFFFFFFF 2048MB 空间为 DDR 地址,所以将程序链接到 0x80000000 。 通过-Ttext 选项,可以指定链接地址 -s :监听在 gdb 1234 端口 -S :表示启动后就挂起,等待 gdb 连接 -kernel 指定启用的内核

    2024年01月21日
    浏览(40)
  • qemu-基础篇——GDB 常用调试命令(三)

    info source 查看当前程序信息 layout 分割窗口,一边查看代码,一边测试 layout asm layout src continue/c 程序继续运行,到下一断点处暂停 run/r 运行 step/c 单步运行 info reg 查看寄存器 break/b + 标号/行号 设置断点 info break/b 查看断点 print 表达式 简记为 p 其中 表达式 可以是任何当前正

    2024年02月03日
    浏览(37)
  • 使用qemu创建ubuntu-base文件系统,并安装PM相关内核模块

    流程简述: (镜像基本的文件系统配置) 1、下载ubuntu-base的镜像 2、挂载镜像,配置镜像的网络,并安装各类软件 (PM模块配置) 3、编译内核模块,并拷贝到镜像中 4、启动qemu 5、安装内核模块,并配置相关软件 1、使用 qemu-img 创建image镜像(此处起名为 ubuntu-rootfs-raw-20G.

    2024年02月16日
    浏览(46)
  • VSCode gdb 调试 qemu u-boot 的方法

    最近使用 VS Code GDB 调试 qemu,有了一点收获,u-boot 编译后生成了一个 elf 文件:u-boot,是否也可以调试一下? 为何需要 VS Code GDB 调试,直接 gdb 调试不就可以了吗?答案就是:VS Code 可以界面调试,命令行调试会枯燥很多 使用 qemu,就是不需要板子 win10 64位 VMware Workstation P

    2024年02月11日
    浏览(44)
  • Linux 利用 qemu-system-aarch64 实现 x86 机器安装 arm64 的操作系统

    qemu-system-aarch64 启动的虚拟机,无法受到 kvm 的管理,也无法在后台运行 终端一旦断开了,虚拟机就被关掉了,想再次进入目前没找到方法,都会回到安装操作系统的步骤 可能是 centos 有某些特殊性吧,暂时没太多时间研究,后期有时间了再看看有没有解决的方案 qemu-5.2.0 和

    2024年02月06日
    浏览(53)
  • Linux和Windows实现挂载NFS

    以下是标准的步骤来在Windows上挂载NFS共享: 启用NFS客户端 : 在Windows功能中,确保“Services for NFS”或“NFS 客户端”(名称可能根据Windows版本有所不同)已经被安装。 挂载NFS共享 : 使用 mount 命令来挂载共享。这是一个简化的命令结构: 所以,根据上面结构举出如下例子: 这

    2024年02月03日
    浏览(44)
  • Linux 之搭建 arm 的 qemu 模拟器

    2024年02月03日
    浏览(43)
  • linux解除挂载

    永久解除linux服务器磁盘挂载 1、找到文件 etc--fstab   2、编辑 vim fstab 3、esc进入编辑状态 4、删除dev/vdb1 /home ext3 defaults o o 5、:wq保存并退出 6、reboot 重启生效  7、df -h 查看是否生效  

    2024年02月17日
    浏览(30)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包