wiki:Dev/KernelHack/COINS/worklog/201109

Version 1 (modified by mitty, 13 years ago) (diff)

--

09/14

download kernel source and build

  • windell57:linux s0711489$ wget https://github.com/torvalds/linux/tarball/v2.6.35 -O torvalds-linux-v2.6.35-0-g9fe6206.tar.gz --no-check-certificate
  • windell57:linux s0711489$ tar xzfv torvalds-linux-v2.6.35-0-g9fe6206.tar.gz
  • windell57:linux s0711489$ cd torvalds-linux-d786bf1/
  • windell57:torvalds-linux-d786bf1 s0711489$ export INSTALL_PATH=/home/ugrad/07/s0711489/build/boot/
  • windell57:torvalds-linux-d786bf1 s0711489$ export INSTALL_MOD_PATH=/home/ugrad/07/s0711489/build/
  • windell57:torvalds-linux-d786bf1 s0711489$ make defconfig
  • windell57:torvalds-linux-d786bf1 s0711489$ make menuconfig
    • 記録忘れ
    • 覚えている限りだと、
      • Networking support からIPv6とWirelessなどの削除
      • Device Drivers へdevtmpfsとSCSI low-level driversのBusLogic SCSI supportの導入
      • File systems からNetwork File Systemsの削除
      • Kernel hacking へCompile the kernel with debug infoの導入
      • Virtualizationの削除
  • windell57:torvalds-linux-d786bf1 s0711489$ make -j2
  • windell57:torvalds-linux-d786bf1 s0711489$ make modules
  • windell57:torvalds-linux-d786bf1 s0711489$ make install
    sh /tmp/linux/torvalds-linux-d786bf1/arch/x86/boot/install.sh 2.6.35 arch/x86/boot/bzImage \
                    System.map "/home/ugrad/07/s0711489/build/boot/"
    ln: `/home/ugrad/07/s0711489/build/boot///home/ugrad/07/s0711489/build/boot//System.map-2.6.35' へのシンボリックリンク `/boot/System.map' を作成します: 許可がありません
    ln: `/home/ugrad/07/s0711489/build/boot///home/ugrad/07/s0711489/build/boot//vmlinuz-2.6.35' へのシンボリックリンク `/boot/vmlinuz' を作成します: 許可がありません
    ln: `/home/ugrad/07/s0711489/build/boot///home/ugrad/07/s0711489/build/boot//System.map-2.6.35' へのシンボリックリンク `/boot/System.map' を作成します: 許可がありません
    
    • どうやら環境変数を指定してのmake installは古いやり方らしく(?)、一部エラーとなる
  • windell57:torvalds-linux-d786bf1 s0711489$ make modules_install
      INSTALL arch/x86/kernel/test_nx.ko
      INSTALL drivers/scsi/scsi_wait_scan.ko
      INSTALL lib/crc16.ko
      INSTALL net/netfilter/xt_mark.ko
      DEPMOD  2.6.35
    

packaging kernel

  • ~/build にコピーされた物をとりあえずtarballにし、ゲストOSにscpする
  • windell57:build s0711489$ tar czf kernel-2.6.35.tar.gz *
  • windell57:build s0711489$ scp kernel-2.6.35.tar.gz user@172.16.237.130:~
    user@172.16.237.130's password:
    kernel-2.6.35.tar.gz                          100% 8326KB   8.1MB/s   00:00
    

install kernel

  • user@ubuntu:~$ sudo cp kernel-2.6.35.tar.gz /
  • user@ubuntu:/$ sudo tar xzf kernel-2.6.35.tar.gz
  • user@ubuntu:/$ sudo mkinitramfs -o /boot/initrd.img-2.6.35 2.6.35
  • user@ubuntu:/$ sudo vim /etc/default/grub
    # GRUB_HIDDEN_TIMEOUT=0
    GRUB_HIDDEN_TIMEOUT_QUIET=false
    
  • user@ubuntu:/$ sudo update-grub
    Generating grub.cfg ...
    Found linux image: /boot/vmlinuz-2.6.35
    Found initrd image: /boot/initrd.img-2.6.35
    Found linux image: /boot/vmlinuz-2.6.35.old
    Found initrd image: /boot/initrd.img-2.6.35
    Found linux image: /boot/vmlinuz-2.6.32-33-generic
    Found initrd image: /boot/initrd.img-2.6.32-33-generic
    Found memtest86+ image: /boot/memtest86+.bin
    done
    

結論

  • 起動には成功
  • NICのドライバ(PCnet32)を設定し忘れたため、ゲスト側でNICが使えずはまる(気づかずにこの日を終える)
  • gdbを使ったリモートデバッグの動作確認もOK
    • windell57:torvalds-linux-d786bf1 s0711489$ gdb
      (gdb) file vmlinux
      Reading symbols from /tmp/linux/torvalds-linux-d786bf1/vmlinux...(no debugging symbols found)...done.
      (gdb) target remote localhost:8832
      Remote debugging using localhost:8832
      0xc1007c23 in native_safe_halt ()
          at /tmp/linux/torvalds-linux-d786bf1/arch/x86/include/asm/irqflags.h:49
      49              asm volatile("sti; hlt": : :"memory");
      (gdb) n
      default_idle () at arch/x86/kernel/process.c:386
      386                     current_thread_info()->status |= TS_POLLING;
      (gdb)
      392     }
      (gdb)
      cpu_idle () at arch/x86/kernel/process_32.c:101
      101                     while (!need_resched()) {
      (gdb)
      115                     tick_nohz_restart_sched_tick();
      (gdb)
      117                     schedule();
      (gdb)
      100                     tick_nohz_stop_sched_tick(1);
      (gdb)
      101                     while (!need_resched()) {
      (gdb)
      115                     tick_nohz_restart_sched_tick();
      (gdb)
      117                     schedule();
      (gdb)
      100                     tick_nohz_stop_sched_tick(1);
      (gdb) detach
      Ending remote debugging.
      (gdb) quit
      

Attachments (4)

Download all attachments as: .zip