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

简介: 本文介绍了在Qemu虚拟机中配置NFS挂载的过程,包括服务端的NFS服务器安装、配置和启动,客户端的DHCP脚本添加和开机脚本修改,以及在Qemu中挂载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成功的画面

不知什么时候开始,非得加个图片,就秀下成功画面吧……
在这里插入图片描述

五、错误处理

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)
相关文章
|
1月前
|
缓存 网络协议 测试技术
NFS挂载信息如何调整?
NFS挂载信息如何调整?
61 3
|
4天前
|
Linux Shell 网络安全
Kali Linux系统Metasploit框架利用 HTA 文件进行渗透测试实验
本指南介绍如何利用 HTA 文件和 Metasploit 框架进行渗透测试。通过创建反向 shell、生成 HTA 文件、设置 HTTP 服务器和发送文件,最终实现对目标系统的控制。适用于教育目的,需合法授权。
28 9
Kali Linux系统Metasploit框架利用 HTA 文件进行渗透测试实验
|
6天前
|
运维 监控 Linux
BPF及Linux性能调试探索初探
BPF技术从最初的网络数据包过滤发展为强大的系统性能优化工具,无需修改内核代码即可实现实时监控、动态调整和精确分析。本文深入探讨BPF在Linux性能调试中的应用,介绍bpftune和BPF-tools等工具,并通过具体案例展示其优化效果。
35 14
|
1月前
|
缓存 NoSQL Linux
Linux调试
本文介绍了Linux调试、性能分析和追踪的培训资料,涵盖调试、性能分析和追踪的基础知识及常用工具。
228 6
Linux调试
|
29天前
|
Linux
如何查看当前的NFS挂载信息?
如何查看当前的NFS挂载信息?
152 2
|
2月前
|
Unix Linux 网络安全
NFS挂载服务
【10月更文挑战第14天】
65 2
|
2月前
|
Linux
linux开机挂载镜像
【10月更文挑战第1天】在 Linux 系统中,开机挂载镜像通常涉及几个关键步骤,包括创建挂载点、编辑配置文件以及重新加载配置
94 0
|
2月前
|
Kubernetes 容器
基于Ubuntu-22.04安装K8s-v1.28.2实验(三)数据卷挂载NFS(网络文件系统)
基于Ubuntu-22.04安装K8s-v1.28.2实验(三)数据卷挂载NFS(网络文件系统)
151 0
|
3月前
|
Linux
linux内核 —— 读写信号量实验
linux内核 —— 读写信号量实验
|
Linux 网络安全
Linux系统之NFS共享配置教程
Linux系统之NFS共享配置教程
254 1
Linux系统之NFS共享配置教程