Debian Linux/amd64 9.1をUSBメモリーにインストールし、カスタマイズされたLinuxカーネルを使う

普段は、NetBSD/amd64-currentを使用しているのだが、WindowsかLinuxでしか動かないデバイスを使ってみたり、どういう挙動をしているのか確認する際には、Linuxを一時的に起動させたい。 その際には、printkをいくつも追加してビルドしたLinuxカーネルで起動させたい。

USBメモリーまたはUSB HDDにDebian Linuxをインストールする

NetBSDだと、build.sh live-imageで、そのままgzcatとddコマンドで書き込めるXも含まれた環境のイメージファイルが作れるので、あるマシンで一時的にNetBSDを起動させようと言う場合には、非常に助かっている。 同じようにLinuxでもライブイメージを探してみたのだが、カーネルをISO 9660イメージの中に含めていて置き換えが難しいものしか見つからない。 確かにあっても、ルートディスクデバイスを決め打ちするので、あまり汎用性はないかもしれないが…。

Debian Linux/amd64 9.1を以下のような手順でインストールすれば、1台目のUSBメモリーやUSB HDDでどのマシンでも起動できるので、書いておく。

  1. Debian Linux/amd64 9.1のライブイメージをダウンロードする(今回はXFCE版を使用した)
  2. ダウンロードしたイメージファイルをDVD-Rに書き込む
  3. Debian Linux/amd64 9.1をインストールしたいUSBメモリーやUSB HDDをマシンにつなぐ
  4. 書き込んだDVD-RからDebian Graphical Installerを起動させる(USB接続のDVD-ROMドライブで良い)
  5. USBメモリーやUSB HDDにインストールする
  6. DVD-Rをドライブから抜き、あるいは、DVD-Rドライブを外して、USBメモリーまたはUSB HDDから起動させる
USBメモリーにダウンロードしたイメージファイルをddコマンドで書き込んでインストールする方が速いし楽なのだが、そうすると、grub.cfgを後で手修正しないといけないので、DVD-Rにしておくのがお勧めである。

Linuxカーネルをビルドする

Debian Linux 9.1では、linux-packageというパッケージはなくなっているようだが、それを使ったウェブページばかり検索されてくるので、 Debian Linux 9.1での場合を書いておく。 一部冗長な部分があるかもしれない。


# apt-get update
# apt-get install linux-source
# apt-get build-dep linux
$ cd ~/
$ tar Jxvf /usr/src/linux-source-4.9.tar.xz
$ cd ~/linux-source-4.9
$ cp /boot/config-4.9.0-3-amd64 ./.config
$ make -j4 bindeb-pkg
$ cd ../
$ sudo dpkg -i linux-headers-*.deb
$ sudo dpkg -i linux-image-*.deb
# reboot

NetBSDでwpa_supplicantを使ってWEPでWi-Fi接続する場合

NetBSDでWEPでWi-Fi接続する場合には、ifconfig(8)コマンドを使えば簡単なのだが、 wpa_supplicantを使っても接続してみたい。

まず、ifconfig(8)を使った場合を書いておく。run(4)なWi-Fiアダプターを使う場合である。


# ifconfig run0 ssid [SSID名] nwkey [パスフレーズ]
# dhcpcd run0

同じことをwpa_supplicantを使って設定する場合を書いておく。


$ cat ~/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel
network={
        ssid="[SSID名]"
        scan_ssid=1
        key_mgmt=NONE # WEP
        wep_tx_keyidx=0
        wep_key0="[パスフレーズ]"
}
# wpa_supplicant -d -i run0 -c ~/wpa_supplicant.conf
# dhcpcd run0

今さらWEPもないはずなのだが、必要な時はあるので、書いておいた。

FreeBSD 11.1のリリースとALPS GlidePoint

PS/2接続のALPS GlidePointがどう動くのかを知りたくて、 NEC VersaPro JVF-7にリリースしたてのFreeBSD/amd64 11.1 RELEASEをインストールしてみた。 結果として、xf86-input-synapticsでProtocol "alps"で動かすことは できなかった。

他には、pkgコマンドでX.orgをインストールすると、llvm 4.0がインストール されてしまうのが気になった。 baseにllvm 4.0が含まれているのに、重複してしまうのは、あまり面白くない。

Windows 10でインストールされているフォントをPowerShellで一覧する

Windows 10でインストール済みのフォントの一覧をテキストファイルで得たい用事があった。 こんな簡単なことなのだが、ぴったりの例を探すことができなかった。 ちゃんとPowerShellを体系的に理解しないといけないが、以下のようにすれば動く。


[void] [system.reflection.assembly]::loadwithpartialname("system.drawing")
(new-object system.drawing.text.installedfontcollection).families.name | out-file fonts.txt

http://codegists.com/snippet/powershell/displayallfontsps1_matthewjberger_powershell が参考になった。

NetBSDのdate(1)コマンドは、なぜデフォルトでは分かりにくい結果を返すのか?

はじめに

NetBSDでLANG=ja_JP.UTF-8な環境で生活しているが、date(1)コマンドを 実行すると、分かりにくい結果の文字列が返って来るのがなぜなのか ずっと気になっていた。


$ date
月 7月 10 21:00:41 JST 2017

やっと重い腰を上げて調べてみたので、結果を書いておく。

date(1)のソースコードを見てみる

src/bin/date/date.cに出力の処理は書かれているようである。 特にフォーマットを指定しない場合の出力フォーマットを決めている箇所を 探すと、以下の箇所が見付かった。141行目である。


   132          if (!rflag && time(&tval) == -1)
   133                  err(EXIT_FAILURE, "time");
   134
   135
   136          /* allow the operands in any order */
   137          if (*argv && **argv == '+') {
   138                  format = *argv;
   139                  ++argv;
   140          } else
   141                  format = "+%a %b %e %H:%M:%S %Z %Y";
   142
   143          if (*argv) {
   144                  setthetime(*argv);
   145                  ++argv;
   146          }

どうやら、ロケールの標準値を指定する等ではなく、私が見やすくないと思っていた フォーマットで決め打ちになっている。

POSIXの規格を見てみる

POSIX(これはIEEE 1003.1-2008のことであって、Open Groupのウェブサイトで公開されているものと思っている)の規格の内容を調べてみると、date(1)コマンドに関する最新版はhttp://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.htmlで公開されているようである。ここで読んで行くと、以下のような記述があった。


STDOUT

    When no formatting operand is specified, the output in the POSIX locale shall be equivalent to specifying:

    date "+%a %b %e %H:%M:%S %Z %Y"

ここで使われているのは「shall」である。RFC 2119の用語に従えば、 以下のような意味なので、従わないという選択肢はない。

1. MUST   This word, or the terms "REQUIRED" or "SHALL", mean that the
   definition is an absolute requirement of the specification.

結論

NetBSDのdate(1)コマンドは、私には見やすくないが、POSIX標準に従っているために、変更されることはないことが分かった。

であれば、仕方がないので、


$ alias date='date +%c'
とでもしておくしかない。

Windows 10 home Creators UpdateでCAPSキーをCTRLキーにする

Microsoft Windows 10 homeをインストールしているマシンがあるのだが、CAPSキーをCTRLキーに置き換えて使用している。 以下のような内容をcaps2ctrl.regと言うファイル名で保存し、ダブルクリックでregedit.exeで書き込むば良い。


REGEDIT4

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

どこで入手したのか原典が分からなくなってしまっているが、Microsoft Windows 10 home Creators Updateで動いている。

NetBSD/evbearmv7hf-el VEXPRESS_A15カーネルをqemu-system-armで動かす

Jared McNeillさんがNetBSD/evbarmのVEXPRESS_A15カーネルをqemu-system-arm -M vexpress-a15で動かせるようにしてくれた。 fdt(4)を使うようになったのが注目点なのかもしれないが、私としてはqemuのSDカードエミュレーションがNetBSDから使えるようになったことに注目している。 以前、INTEGRATOR_CPカーネルやGUMSTIXカーネルを起動させた際には、SDカードコントローラーの想定しない状態変化をNetBSDが設定しようとしてエラーになり、使えなかったような記憶があるためだ。

INTEGRATOR_CPカーネルやGUMSTIXカーネルは後ほど試してみるとして、まずはhttp://mail-index.netbsd.org/port-arm/2017/06/02/msg004154.htmlにある内容をやってみた。 qemuは、pkgsrc/emulators/qemuからインストールしたqemu-2.9.0nb1であり、ホストはNetBSD/amd64 8.99.1である。

まずは、以下のように実行し、最新のevbearmv7hf-elのreleaseディレクトリーを用意する。場所は、/usr/world/8.99/evbearmv7hf-el/releaseにする。


$ cd /usr/src
$ cvs up -dPA
$ ./build.sh -U -O /usr/world/8.99.1/evbearmv7hf-el/obj -T  /usr/world/8.99.1/evbearmv7hf-el/tools -D  /usr/world/8.99.1/evbearmv7hf-el/destdir -R  /usr/world/8.99.1/evbearmv7hf-el/release -u -x -j 4 -m evbearmv7hf-el release

次に、作業用ディレクトリーを作り、必要なファイルを用意する。注意事項としては、dtbファイルは最新のNetBSD-currentではbuild.shの実行の中で生成されるので、pkgsrcからインストールする必要はない点がある。


$ mkdir ~/tmp
$ cd ~/tmp
$ cp /usr/world/8.99/evbearmv7hf-el/release/evbarm/binary/gzimg/armv7.img.gz .
$ gunzip armv7.img.gz
$ cp /usr/world/8.99/evbearmv7hf-el/release/evbarm/binary/kernel/vexpress-v2p-ca15-tc1.dtb.gz .
$ gunzip vexpress-v2p-ca15-tc1.dtb.gz
次に、2GBのディスクイメージを用意する。初回起動時に2GBにパーティションが伸長される。

$ dd if=/dev/zero of=sdcard.img bs=1m count=2048
$ dd if=armv7.img of=sdcard.img bs=1m conv=notrunc

qemuの起動とdmesgは以下のようになった。オーディオ機能も使えるようだが、試せていない。


$ qemu-system-arm -M vexpress-a15 -kernel netbsd-VEXPRESS_A15.ub -dtb vexpress-v2p-ca15-tc1.dtb -nographic -sd sdcard.img -append 'root=ld0a'
WARNING: Image format was not specified for 'sdcard.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
audio: Could not init `oss' audio driver
[ Kernel symbol table missing! ]
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 8.99.1 (VEXPRESS_A15) #1: Thu Jun 29 15:22:18 JST 2017
        ryoon@brownie:/usr/world/8.99/evbearmv7hf-el/obj/sys/arch/evbarm/compile/VEXPRESS_A15
total memory = 128 MB
avail memory = 121 MB
sysctl_createv: sysctl_create(machine_arch) returned 17
armfdt0 (root)
fdt0 at armfdt0: V2P-CA15
fdt1 at fdt0
fdt2 at fdt1: V2M-P1
fdt3 at fdt2
fdt4 at fdt0
cpus0 at fdt0
cpu0 at cpus0: Cortex-A15 r2p1 (Cortex V7A core)
cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled
cpu0: 32KB/64B 2-way L1 PIPT Instruction cache
cpu0: 32KB/64B 2-way write-back-locking-C L1 PIPT Data cache
cpu0: 2304KB/64B 16-way write-through L2 PIPT Unified cache
vfp0 at cpu0: NEON MPE (VFP 3.0+), rounding, NaN propagation, denormals
cpu1 at cpus0: disabled (unresponsive)
gic0 at fdt0: GIC
armgic0 at gic0: Generic Interrupt Controller, 160 sources (160 valid)
armgic0: 256 Priorities, 128 SPIs, 16 PPIs, 16 SGIs
gtmr0 at fdt0: Generic Timer
armgtmr0 at gtmr0: ARMv7 Generic 64-bit Timer (62500 kHz)
armgtmr0: interrupting on irq 27
fregulator0 at fdt2: 3V3
fclock0 at fdt2: 32768 Hz fixed clock
fclock1 at fdt2: 1000000 Hz fixed clock
fclock2 at fdt2: 24000000 Hz fixed clock
/dcc at fdt0 not configured
vxsysreg0 at fdt3
/smb@08000000/motherboard/iofpga@3,00000000/sysctl@020000 at fdt3 not configured
/smb@08000000/motherboard/mcc at fdt2 not configured
/smb@08000000/motherboard/vram@2,00000000 at fdt2 not configured
genfb0 at fdt3
wsdisplay0 at genfb0 kbdmux 1
/virtio_mmio@1c130000 at fdt0 not configured
/virtio_mmio@1c130200 at fdt0 not configured
/virtio_mmio@1c130400 at fdt0 not configured
/virtio_mmio@1c130600 at fdt0 not configured
/hdlcd@2b000000 at fdt0 not configured
/memory-controller@2b0a0000 at fdt0 not configured
/memory-controller@7ffd0000 at fdt0 not configured
/dma@7ffb0000 at fdt0 not configured
/pmu at fdt0 not configured
/smb@08000000/motherboard/flash@0,00000000 at fdt2 not configured
/smb@08000000/motherboard/psram@1,00000000 at fdt2 not configured
smsh0 at fdt2: SMSC LAN9118 Rev 1
smsh0: MAC address 52:54:00:12:34:56
ukphy0 at smsh0 phy 1: OUI 0x00800f, model 0x000d, rev. 1
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
smsh0: interrupting on GIC irq 47
/smb@08000000/motherboard/usb@2,03000000 at fdt2 not configured
/smb@08000000/motherboard/leds at fdt2 not configured
/smb@08000000/motherboard/iofpga@3,00000000/i2c@030000 at fdt3 not configured
aaci0 at fdt3: Advanced Audio CODEC
aaci0: ac97: National Semiconductor LM4549 codec; headphone, 18 bit DAC, 18 bit ADC, National Semi 3D
aaci0: ac97: ext id 0x1
audio0 at aaci0: half duplex, playback, mmap
aaci0: Virtual format configured - Format SLINEAR, precision 16, channels 2, frequency 48000
spkr0 at audio0: PC Speaker (synthesized)
wsbell at spkr0 not configured
aaci0: interrupting on GIC irq 43
plmmc0 at fdt3
sdmmc0 at plmmc0
plkmi0 at fdt3: PS2 controller
pckbd0 at plkmi0 (kbd slot)
wskbd0 at pckbd0 mux 1
plkmi0: interrupting on GIC irq 44
plkmi1 at fdt3: PS2 controller
pms0 at plkmi1 (aux slot)
wsmouse0 at pms0 mux 0
plkmi1: interrupting on GIC irq 45
plcom0 at fdt3
plcom0: txfifo disabled
plcom0: console
plcom1 at fdt3
plcom1: txfifo disabled
plcom2 at fdt3
plcom2: txfifo disabled
plcom3 at fdt3
plcom3: txfifo disabled
/smb@08000000/motherboard/iofpga@3,00000000/wdt@0f0000 at fdt3 not configured
/smb@08000000/motherboard/iofpga@3,00000000/timer@110000 at fdt3 not configured
/smb@08000000/motherboard/iofpga@3,00000000/timer@120000 at fdt3 not configured
/smb@08000000/motherboard/iofpga@3,00000000/i2c@160000 at fdt3 not configured
plrtc0 at fdt3: RTC
/smb@08000000/motherboard/iofpga@3,00000000/compact-flash@1a0000 at fdt3 not configured
ld0 at sdmmc0: <0xaa:0x5859:QEMU!:0x01:0xdeadbeef:0x062>
ld0: 2048 MB, 1040 cyl, 64 head, 63 sec, 512 bytes/sect x 4194304 sectors
ld0: 4-bit width, 12.000 MHz
boot device: ld0
root on ld0a dumps on ld0b
root file system type: ffs
kern.module.path=/stand/evbarm/8.99.1/modules

GnuPG2で、revoke済みのUIDを表示させる

20年以上利用して来たインターネット・サービス・プロバイダーの提供してくれている電子メールアドレスを廃止することにした。 近年は全く価値に見合うようなサービス品質ではないように考えられるアカウントもあったし、受信がほぼできなくなるような状態になったりすることもあった。 ...