Linux kernel debugging through virtual machines (continued)

Source: Internet
Author: User

1. nfs Verification

Verify whether the Guest machine can mount nfs of the Host machine in NAT mode.

Sudo mount 192.168.1.102:/home/qianjiang/pls temp/
Mount: wrong fs type, bad option, bad superblock on 192.168.1.102:/home/qianjiang/pls,
Missing codepage or helper program, or other error
(For several filesystems (e.g. nfs, cifs) you might
Need a/sbin/mount. <type> helper program)
In some cases useful info is found in syslog-try
Dmesg | tail or so
It turns out that nfs-common is to be installed and NAT does not support NFS.
Sudo apt-get nfs-common, because nfs is compiled into a module by installing kernel.


2. Prepare rootfs
From initrd. img
Gzip-cd/boot/initrd. img | cpio-imd -- quiet


3. add nfs to kernel command line

Kernel command line: BOOT_IMAGE =/boot/bzImage root =/dev/nfs nfsroot = 192.168.1.102:/home/qianjiang/pls/root/pc-root ip = dhcp nfsrootdebug console = ttyS0, 115200

. The mount fails at the beginning and exportfs needs to be modified (due to NAT)

/Home/qianjiang/pls * (rw, no_root_squash, no_all_squash, sync, nohide, no_subtree_check)
Change
/Home/qianjiang/pls * (rw, insecure, sync, no_subtree_check)
Mainly add insecure


4. Modify grub. cfg
To avoid entering a long command line every time, create tftpboot/boot/grub. cfg, including the following content
Menuentry Kernel debug -- class ubuntu -- class gnu-linux -- class gnu -- class OS {
Echo Loading Linux...
Linux/boot/bzImage root =/dev/nfs rw nfsroot = 192.168.1.102:/home/qianjiang/pls/root/pc-root ip = dhcp nfsrootdebug console = ttyS0, 115200
}
You can also remove the menu framework and add boot to the last line.

5.
. It should be mounted, but the following line is displayed, probably because of a problem with rootfs.
[20.512132] nfs: server 192.168.1.106 not responding, still trying
After reading the post online, I feel that it is a kernel problem,
Modify fs/nfs/nfsroot. c
# Define NFS_DEF_OPTIONS "vers = 3, proto = tcp, mountproto = udp"
Then we solved this problem. It seems that it was not good. It took two days to get it all done, but the benefits were quite high.

6. debugging becomes very convenient
Open a vim window to modify the kernel code, open a mini-com window to view debugging information, and enter commands similar to the following in a window.

Make & cp arch/x86/boot/bzImage ~ /Tftpboot/boot/# compile

Vboxmanage startvm "kernel-debug" # start the machine
Or
Vboxmanage controlvm "kernel-debug" reset # reset the machine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.