PacktPublishing / Mastering-Embedded-Linux-Programming-Third-Edition

Mastering Embedded Linux Programming Third Edition, published by Packt
MIT License
532 stars 151 forks source link

Issue mounting rootfs via NFS #47

Closed robamu closed 2 years ago

robamu commented 3 years ago

Thanks for creating this great book. I have some improvement suggestions, but I am not sure whether this is a problem which only occurs on certain host machines. I already created an issue here for this topic : https://github.com/PacktPublishing/Mastering-Embedded-Linux-Programming-Second-Edition/issues/8 .

I had to adapt the commands to mount a rootfs from a NFS server for both QEMU and BBB. For both cases, I had to append the option v3 to the nfsroot linux command line parameter.

The QEMU start command then looks like this

QEMU_AUDIO_DRV=none \
    qemu-system-arm -m 256M -nographic -M versatilepb -kernel
    ${KERNEL} -append "console=ttyAMA0,115200 root=/dev/nfs rw
    nfsroot=${HOST_IP}:${ROOTDIR},v3 ip=${TARGET_IP}" -dtb ${DTB} -net
    nic -net tap,ifname=tap0,script=no

On the BBB, I used DHCP, so the U-Boot command looked like this (assuming the host IP is known of course, can be found with ifconfig):

dhcp
setenv serverip <hostIp>
setenv npath <pathToRootfsOnHost>
setenv bootargs console=ttyO0,115200n8 root=/dev/nfs rw nfsroot=${serverip}:${npath},v3 ip=dhcp
fatload mmc 0:1 0x80200000 zImage
fatload mmc 0:1 0x80f00000 am335x-boneblack.dtb
bootz 0x80200000 - 0x80f00000

Also, after a change to etc/exports, I think the changes can be applied with the command

sudo exportfs -ra

and it should not be necessary to restart the nfs server

fvasquez commented 3 years ago

@robamu thank you for the feedback and buying the book. You are probably right about the missing v3 option. I ran most of the examples on Ubuntu 20.04 LTS when I was updating the book. This nfsroot example is one of the few I did not test because I did not expect it to change from the second edition. Since the example appears to be broken in that edition, it is also broken in mine. I'm pretty busy with work right now but I will try to take a look at this issue and post any errata here in a couple of weeks.

fvasquez commented 2 years ago

Resolved with merge of pull request #48.