wiki:Dev/KernelHack/COINS/worklog/201109

Version 2 (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
      

09/15

  • 方針
    • ゲスト上でビルドすると遅いので、ホスト上でビルドしたソースツリーをVMwareのHGFSを使ってゲスト上にマウントし、そこからsudo make installする

build kernel on Guest

  • 比較対象として、同時並行でゲスト上でビルド&インストールも行ってみた
  • mitty@ubuntu-lucid:~$ sudo aptitude update
  • mitty@ubuntu-lucid:~$ sudo aptitude install build-essential kernel-package libncurses-dev
    Note: selecting "libncurses5-dev" instead of the
          virtual package "libncurses-dev"
    The following NEW packages will be installed:
      binutils{a} build-essential cvs{a} dpkg-dev{a} fakeroot{a} g++{a}
      g++-4.4{a} gcc{a} gcc-4.4{a} gettext{a} intltool-debian{a} kernel-package
      libc-dev-bin{a} libc6-dev{a} libcroco3{a} libfile-copy-recursive-perl{a}
      libgomp1{a} liblzma1{a} libmail-sendmail-perl{a} libncurses5-dev
      libstdc++6-4.4-dev{a} libsys-hostname-long-perl{a} linux-libc-dev{a}
      manpages-dev{a} patch{a} po-debconf{a} update-inetd{a} xz-utils{a}
    0 packages upgraded, 28 newly installed, 0 to remove and 0 not upgraded.
    Need to get 25.7MB of archives. After unpacking 88.4MB will be used.
    
  • mitty@ubuntu-lucid:~/kernel/mirrors-linux-d786bf1$ make defconfig
  • mitty@ubuntu-lucid:~/kernel/mirrors-linux-d786bf1$ make menuconfig
    • 設定内容については後述
  • mitty@ubuntu-lucid:~/kernel/mirrors-linux-d786bf1$ make
  • mitty@ubuntu-lucid:~/kernel/mirrors-linux-d786bf1$ make modules
  • mitty@ubuntu-lucid:~/kernel/mirrors-linux-d786bf1$ sudo make install
  • mitty@ubuntu-lucid:~/kernel/mirrors-linux-d786bf1$ sudo make modules_install
  • mitty@ubuntu-lucid:~/kernel/mirrors-linux-d786bf1$ sudo mkinitramfs -o /boot/initrd.img-2.6.35 2.6.35
  • mitty@ubuntu-lucid:~/kernel/mirrors-linux-d786bf1$ sudo update-grub
  • mitty@ubuntu-lucid:~$ sudo reboot
  • mitty@ubuntu-lucid:~$ uname -a
    Linux ubuntu-lucid 2.6.35 #3 SMP Fri Sep 16 15:01:05 JST 2011 i686 GNU/Linux
    
    • ビルド成功
    • ただ、ホスト側にはソースツリーが無いので、このままではリモートデバッグ出来ない

build kernel on Host

install packages to Guest

  • s0711489@ubuntu-lucid:~$ sudo aptitude update
  • s0711489@ubuntu-lucid:~$ sudo aptitude install build-essential kernel-package libncurses-dev
    Note: selecting "libncurses5-dev" instead of the
          virtual package "libncurses-dev"
    The following NEW packages will be installed:
      binutils{a} build-essential cvs{a} dpkg-dev{a} fakeroot{a} g++{a}
      g++-4.4{a} gcc{a} gcc-4.4{a} gettext{a} intltool-debian{a} kernel-package
      libc-dev-bin{a} libc6-dev{a} libcroco3{a} libfile-copy-recursive-perl{a}
      libgomp1{a} liblzma1{a} libmail-sendmail-perl{a} libncurses5-dev
      libstdc++6-4.4-dev{a} libsys-hostname-long-perl{a} linux-libc-dev{a}
      manpages-dev{a} patch{a} po-debconf{a} update-inetd{a} xz-utils{a}
    0 packages upgraded, 28 newly installed, 0 to remove and 0 not upgraded.
    Need to get 25.7MB of archives. After unpacking 88.4MB will be used.
    

install VMware Tools

  • s0711489@ubuntu-lucid:~$ sudo mount /dev/cdrom /media/
  • s0711489@ubuntu-lucid:~$ tar xzf /media/VMwareTools-8.4.6-385536.tar.gz
  • s0711489@ubuntu-lucid:~/vmware-tools-distrib$ sudo ./vmware-install.pl --default

download kernel source and build

  • windell57:mirrors-linux-d786bf1 s0711489$ make defconfig
  • windell57:mirrors-linux-d786bf1 s0711489$ make menuconfig
      │ │                [*] Networking support  --->                                                           │ │
      │ │                      Networking options  --->                                                         │ │
      │ │                < >   The IPv6 protocol  --->                                                          │ │
      │ │                [ ]   Amateur Radio support  --->                                                      │ │
      │ │                -*-   Wireless  --->                                                                   │ │
      │ │                < >   cfg80211 - wireless configuration API                                            │ │
      │ │                < >   RF switch subsystem support  --->                                                │ │
      │ │                    Device Drivers  --->                                                               │ │
      │ │                    Generic Driver Options  --->                                                       │ │
      │ │                [*] Maintain a devtmpfs filesystem to mount at /dev                                    │ │
      │ │                [*]   Automount devtmpfs at /dev, after the kernel mounted the rootfs                  │ │
      │ │                    SCSI device support  --->                                                          │ │
      │ │                [*] SCSI low-level drivers  --->                                                       │ │
      │ │                <*>   BusLogic SCSI support                                                            │ │
      │ │                [*] Network device support  --->                                                       │ │
      │ │                [*]   Ethernet (10 or 100Mbit)  --->                                                   │ │
      │ │                <*>     AMD PCnet32 PCI support                                                        │ │
      │ │                    File systems  --->                                                                 │ │
      │ │                <*> The Extended 4 (ext4) filesystem                                                   │ │
      │ │                [ ] Network File Systems  --->                                                         │ │
      │ │                    Kernel hacking  --->                                                               │ │
      │ │                [*] Compile the kernel with debug info                                                 │ │
      │ │                [ ] Virtualization  --->                                                               │ │
    
  • windell57:mirrors-linux-d786bf1 s0711489$ make -j2
  • windell57:mirrors-linux-d786bf1 s0711489$ make modules

make install on Guest

  • s0711489@ubuntu-lucid:~$ cd /mnt/hgfs/linux-v2.6.35/mirrors-linux-d786bf1/
  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.35/mirrors-linux-d786bf1$ sudo make install
    sh /mnt/hgfs/linux-v2.6.35/mirrors-linux-d786bf1/arch/x86/boot/install.sh 2.6.35 arch/x86/boot/bzImage \
                    System.map "/boot"
    
  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.35/mirrors-linux-d786bf1$ sudo make modules_install
      INSTALL arch/x86/kernel/test_nx.ko
      INSTALL drivers/scsi/scsi_wait_scan.ko
      INSTALL fs/ext4/ext4.ko
      INSTALL fs/jbd2/jbd2.ko
      INSTALL lib/crc16.ko
      INSTALL net/netfilter/xt_mark.ko
      DEPMOD  2.6.35
    
  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.35/mirrors-linux-d786bf1$ sudo mkinitramfs -o /boot/initrd.img-2.6.35 2.6.35
  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.35/mirrors-linux-d786bf1$ 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
    

reboot

  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.35/mirrors-linux-d786bf1$ uname -a
    Linux ubuntu-lucid 2.6.32-33-generic #72-Ubuntu SMP Fri Jul 29 21:08:37 UTC 2011 i686 GNU/Linux
    
  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.35/mirrors-linux-d786bf1$ sudo reboot
  • 起動しない
    • 注: 後日同じ(と思われる)手順で繰り返したところ、再現せず問題なく起動した

retry with 2.6.32

  • windell57:mirrors-linux-459b3d5 s0711489$ make defconfig
  • windell57:mirrors-linux-459b3d5 s0711489$ make menuconfig
  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.32/mirrors-linux-459b3d5$ sudo make install
    sh /mnt/hgfs/linux-v2.6.32/mirrors-linux-459b3d5/arch/x86/boot/install.sh 2.6.32 arch/x86/boot/bzImage \
                    System.map "/boot"
    
  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.32/mirrors-linux-459b3d5$ sudo make modules_install
      INSTALL arch/x86/kernel/test_nx.ko
      INSTALL drivers/scsi/scsi_wait_scan.ko
      DEPMOD  2.6.32
    
  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.32/mirrors-linux-459b3d5$ sudo mkinitramfs -o /boot/initrd.img-2.6.32 2.6.32
  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.32/mirrors-linux-459b3d5$ 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 linux image: /boot/vmlinuz-2.6.32
    Found initrd image: /boot/initrd.img-2.6.32
    Found memtest86+ image: /boot/memtest86+.bin
    done
    
  • s0711489@ubuntu-lucid:~$ uname -a
    Linux ubuntu-lucid 2.6.32-33-generic #72-Ubuntu SMP Fri Jul 29 21:08:37 UTC 2011 i686 GNU/Linux
    
  • s0711489@ubuntu-lucid:/mnt/hgfs/linux-v2.6.32/mirrors-linux-459b3d5$ sudo reboot
  • s0711489@ubuntu-lucid:~$ uname -a
    Linux ubuntu-lucid 2.6.32 #1 SMP Fri Sep 16 15:49:51 JST 2011 i686 GNU/Linux
    
    • 今度は起動成功

結論

  • 2.6.35で何故失敗したかは不明(再現しなかった)
  • makeにかかる時間が長すぎるので、violaを使ってビルドする方法を探る

Attachments (4)

Download all attachments as: .zip