いつの間にかラップトップで使ってるGentoo Linuxのカーネルバージョンが4.9.34になってた。
年始めに更新して4.4.26で安定した生活を送っていたみたいだけど、もうそれも1年前のように感じる…
更新する度にwikiを読み漁るのがアレなので必要な手順についてまとめておきたい。
ちなみにラップトップはPC-LL750MSB-BGです。
コンフィグ
事始め
まずカーネルソースのシンボリックリンクを張り替える。
root$ eselect kernel list
Available kernel symlink targets:
[1] linux-4.4.26-gentoo *
[2] linux-4.9.34-gentoo
root$ eselect kernel set 2
現行のカーネルコンフィグをコピーしてくる。
色んな場所から取れるようですが、今回は追加したい項目もあったので1から作り直しています。
- procから取得
root$ zcat /proc/config.gz > /usr/src/linux/.config
- 前のカーネルソースから取得
CONFIG_IKCONFIG
が前のカーネルコンフィグで有効であること。
root$ /usr/src/linux/scripts/extract-ikconfig /path/to/old/kernel >/usr/src/linux/.config
- bootから取得
root$ cp /boot/config-4.4.26-gentoo /usr/src/linux/.config
- 古いカーネルソースから直接移す
これがスタンダードなのでは….
root$ cp /usr/src/linux-4.4.26-gentoo/.config /usr/src/linux/
- genkernelの遺産相続をする
もし前に genkernel
を使用していて、かつ /etc/genkernel.conf
に SAVE_CONFIG="yes"
が設定されているならコンフィグが取得できます。
root$ cp /etc/kernels/kernel-config-x86_64-4.4.26-gentoo /usr/src/linux/.config
コンフィグを起動する
GUIでもCUIでもどっちでも。
私は xconfig
使ったあとに menuconfig
で二重チェックしました。 そんなところに冗長性いらない…
対話式チェック
細かい情報がわかりにくいデメリットがあります。
root$ make silentoldconfig
または
root$ make oldconfig
GUIの場合は oldconfig
みたいなのはないから、
root$ make xconfig
でok。 menuconfig
も同様。
ドライバ関係
いちばんだいじかも。
ディスクのマウントに失敗して起動できないカーネルを何個もつくってきたので….
/dev
システムを有効化
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 Drivers --->
SCSI device support --->
<*> SCSI disk support
ファイルシステム
うちの環境ではこんなのが必要でした。
- NTFS,FUSE(Windows,Android)
- VFAT(UEFIとか、いろいろ)
- ext2(
/boot
) - ext4(
/
) - UDF(CD/DVD)
File systems --->
<*> Second extended fs support
<*> The Extended 3 (ext3) filesystem
<*> The Extended 4 (ext4) filesystem
<*> Reiserfs support
<*> JFS filesystem support
<*> XFS filesystem support
<*> Btrfs filesystem support
DOS/FAT/NT Filesystems --->
<*> MSDOS fs support
<*> VFAT (Windows-95) fs support
procfs (/proc
以下のアレ)を有効化
Pseudo Filesystems --->
[*] /proc file system support
[*] Tmpfs virtual memory file system support (former shm fs)
USB
5ポートもあるマシンなので必須。Type-Cはありません。
Device Drivers --->
HID support --->
-*- HID bus support
<*> Generic HID driver
[*] Battery level reporting for HID devices
USB HID support --->
<*> USB HID transport layer
[*] USB support --->
<*> xHCI HCD (USB 3.0) support
<*> EHCI HCD (USB 2.0) support
<*> OHCI HCD (USB 1.1) support
Xorg
入力関係
Device Drivers --->
Input device support --->
<*> Event interface
KMS(Kernel Mode Setting)有効化
Framebuffer Console Support とか色々ここから消えてた。どこいったんや。
Device Drivers --->
Graphics support --->
Frame Buffer Devices --->
<*> Support for frame buffer devices --->
## (競合するのでVGA,Intel,nVidia,ATIに関する
## Framebuffer supportを切る。
## ただしUEFIのときはEFI-based Framebuffer Supportを有効化したままにする。)
## (KMS用に、Framebuffer Console Supportを有効化する。)
Console display driver support --->
<*> Framebuffer Console Support
音声(ALSA)
現行の4.9では Intel HD Audio
は Intel/SiS/nVidia/AMD/ALi AC97 Controller
になってるっぽい。あとALSAの階層に HD-Audio
が新しく出来てるのでオンボードサウンド系はそっちを選ぶのかも。
Device Drivers --->
<*> Sound card support
<*> Advanced Linux Sound Architecture --->
[*] PCI sound devices --->
#デバイスに合ったオーディオコントローラを選択する。例:
<*> Intel HD Audio ---> (snd-hda-intel)
Select a codec or enable all and let the generic parse choose the right one:
[*] Build Realtek HD-audio codec support
[*] ...
[*] Build Silicon Labs 3054 HD-modem codec support
[*] Enable generic HD-audio codec parser
General setup --->
[*] System V IPC
時刻
Real Time Clock(RTC)の同期用。
Device Drivers --->
[*] Real Time Clock --->
[*] Set system time from RTC on startup and resume
[*] Set the RTC time based on NTP synchronization
[*] /sys/class/rtc/rtcN (sysfs)
[*] /proc/driver/rtc (procfs for rtcN)
[*] /dev/rtcN (character devices)
<*> PC-style 'CMOS'
QEMU
KVMの項目が見つからないんだけど….
[*] Virtualization --->
<*> Host kernel accelerator for virtio net
<*> Kernel-based Virtual Machine (KVM) support
<M> KVM for Intel processors support
Device Drivers --->
[*] Network device support --->
[*] Network core driver support
<*> Universal TUN/TAP device driver support
Networking options --->
<*> The IPv6 protocol
<*> 802.1d Ethernet Bridging
Kernel hacking --->
Compile-time checks and compiler options --->
[*] Debug Filesystem
File systems --->
<*> The Extended 4 (ext4) filesystem
[*] Ext4 Security Labels
SDカード
Gentooにしてから一回もSDカードが読めたことがないのです…
Arch Linuxのときはいけてたのでサポートはしてあるはずなのですが…
Device Drivers --->
<*> MMC/SD card support --->
-*- MMC/SD card support
<*> MMC block device driver
[*] Use bounce buffer for simple hosts
<*> Secure Digital Host Controller Interface support
<*> SDHCI support on PCI bus
[*] Ricoh MMC Controller Disabler
Android
USBテザリングにはカーネルモジュールが必要です。
Device Drivers --->
[*] Network device support --->
<M> USB Network Adapters --->
<M> Multi-purpose USB Networking Framework
<M> CDC Ethernet support (smart devices such as cable modems)
<M> CDC EEM support
<M> Host for RNDIS and ActiveSync devices
<M> Simple USB Network Links (CDC Ethernet subset)
[*] Embedded ARM Linux links (iPaq, ...)
あと、以下も必要な気がするんですが、本当に要るのかは不明。
Device Drivers --->
Android --->
[*] Android Drivers
[*] Android Binder IPC Driver
Arduino
カーネルモジュールは用意してやってもクロスコンパイル環境が面倒くさくて一度もLinuxでArduino開発してません。
素直にWindowsでした方が楽。
FTDIチップのとき
Device Drivers --->
[*] USB support --->
<*> USB Serial Converter support --->
<*> USB FTDI Single Port Serial Driver
Aruduino NANOのとき
Device Drivers --->
[*] USB support --->
<*> USB Serial Converter support --->
<*> USB Winchiphead CH341 Single Port Serial Driver
Aruduino MEGAか残りのAruduino
Device Drivers --->
[*] USB support --->
<*> USB Modem (CDC ACM) support
ネットワーク
WiFi
まずはプロトコルのサポート。
真ん中あたりの < > Generic IEEE 802.11 Networking Stack (mac80211)
は後に使用する wl
モジュールの邪魔になるので抜いておきますが、普通はあったほうがいいかも。
[*] Networking support --->
[*] Wireless --->
<*> cfg80211 - wireless configuration API
[ ] nl80211 testmode command
[ ] enable developer warnings
[ ] cfg80211 regulatory debugging
[ ] cfg80211 certification onus
[*] enable powersave by default
[ ] cfg80211 DebugFS entries
[ ] use statically compiled regulatory rules database
[ ] cfg80211 wireless extensions compatibility
< > Generic IEEE 802.11 Networking Stack (mac80211)
[*] Minstrel
[*] Minstrel 802.11n support
[ ] Minstrel 802.11ac support
Default rate control algorithm (Minstrel) --->
[ ] Enable mac80211 mesh networking (pre-802.11s) support
-*- Enable LED triggers
[ ] Export mac80211 internals in DebugFS
[ ] Trace all mac80211 debug messages
[ ] Select mac80211 debugging features ----
次にデバイス。
Broadcom 43xx系の無線NICが載ってるのですが、追加ファームウェアでnet-wireless/broadcom-staが要ります。
現在(2017-08-18)これのビルドが通らないのでパッチが必要なのですが、別記事にて。
また /etc/conf.d/modules
の modules=
に wl
を追記して自動ロードするようにします。
そして、 wl
を使用する場合は ssb
, b43
, bcma
, mac80211
をコンフィグで無効化するか、ブラックリストに入れないといけません。カーネルが bcma
その他を自動ロードしてしまうと wl
は使えなくなるから(らしい)です。
ビルドタイミングをミスると後でネットに繋げなくなる。
余談ですが、この wl
モジュールはArch Linuxでは標準サポートでなくAUR入りしてるので多分どこのディストリでも追加で導入しないといけないかもしれないです。 クソ。
Device Drivers --->
[*] Network device support --->
[*] Wireless LAN --->
#WiFiデバイスに合ったモジュールを選択する。例:
< > Broadcom 43xx wireless support (mac80211 stack) (b43)
[ ] Support for 802.11n (N-PHY) devices
[ ] Support for low-power (LP-PHY) devices
[ ] Support for HT-PHY (high throughput) devices
<M> Intel Wireless WiFi Next Gen AGN - Wireless-N/Advanced-N/Ultimate-N (iwlwifi)
<M> Intel Wireless WiFi DVM Firmware support
<M> Intel Wireless WiFi MVM Firmware support
<M> Intel Wireless WiFi 4965AGN (iwl4965)
<M> Intel PRO/Wireless 3945ABG/BG Network Connection (iwl3945)
<M> Ralink driver support --->
<M> Ralink rt27xx/rt28xx/rt30xx (USB) support (rt2800usb)
-*- Cryptographic API --->
-*- AES cipher algorithms
-*- AES cipher algorithms (x86_64)
<*> AES cipher algorithms (AES-NI)
LEDランプのサポートはあってもうちのラップトップはon/offぐらいのパターンしかないのであんまり意味がないです。
イーサネットに関してはLEDなし。ピコピコ光らないならあんまり恩恵のないコンフィグです。
Device Drivers --->
[*] LED Support --->
<*> LED Class Support
[*] Networking support --->
[*] Wireless --->
[*] Enable LED triggers
Bluetooth
BTキーボードにつなぐことはできても入力できなかったのはHID関係が足りてないんだろうか…
[*] Networking support --->
<*> Bluetooth subsystem support --->
[*] Bluetooth Classic (BR/EDR) features
<*> RFCOMM protocol support
[ ] RFCOMM TTY support
< > BNEP protocol support
[ ] Multicast filter support
[ ] Protocol filter support
<*> HIDP protocol support
[*] Bluetooth High Speed (HS) features
[*] Bluetooth Low Energy (LE) features
Bluetooth device drivers --->
<*> HCI USB driver
<*> HCI UART driver
<*> RF switch subsystem support --->
Device Drivers --->
HID support --->
<*> User-space I/O driver support for HID subsystem
HID関係
Device Drivers --->
[*] HID Devices --->
デバイスによってはドライバ指定がいるかも。 --->
<*> ...
[*] Networking support --->
<*> Bluetooth subsystem support --->
<*> L2CAP protocol support
<*> HIDP protocol support
IPTables
NATかけてデスクトップマシンにルーティングしてるのでiptablesないといけない。
iptablesが必要なときにロードしてくれるはずなのでモジュールで入れまくる。
[*] Networking support --->
Networking options --->
[*] TCP/IP networking
[*] IP: multicasting
[*] IP: advanced router
...
[*] IP: ARP daemon support
[*] IP: TCP syncookie support
<M> IP: AH transformation
<M> IP: ESP transformation
<M> IP: IPComp transformation
<M> IP: IPsec transport mode
<M> IP: IPsec tunnel mode
<M> IP: IPsec BEET mode
<*> Large Receive Offload (ipv4/tcp)
<*> INET: socket monitoring interface
<M> UDP: socket monitoring interface
[ ] TCP: advanced congestion control --->
...
<M> The IPv6 protocol --->
...
[*] Network packet filtering framework (Netfilter) --->
[*] Advanced netfilter configuration
Core Netfilter Configuration --->
<M> "addrtype" address type match support
<M> "comment" match support
<M> "hl" hoplimit/TTL match support
<M> "limit" match support
<M> "multiport" Multiple port match support
<M> "recent" match support
プロセッサ
マルチコアとかIA32互換モードとか。
Processor type and features --->
[*] Symmetric multi-processing support
[*] SMT (Hyperthreading) scheduler support
[*] Multi-core scheduler support (NEW)
[ ] Machine Check / overheating reporting
[ ] Intel MCE Features
[ ] AMD MCE Features
Processor family (AMD-Opteron/Athlon64) --->
( ) Opteron/Athlon64/Hammer/K8
( ) Intel P4 / older Netburst based Xeon
( ) Core 2/newer Xeon
( ) Intel Atom
( ) Generic-x86-64
High Memory Support --->
(X) 4GB
( ) 64GB
Executable file formats / Emulations --->
[*] IA32 Emulation
UEFIのサポート。これでコケたことはないけど必須。
Processor type and features --->
[*] EFI runtime service support
[*] EFI stub support
[*] EFI mixed-mode support
Firmware Drivers --->
EFI (Extensible Firmware Interface) Support --->
<*> EFI Variable Support via sysfs
3Dアクセラレーション。 intelは以下の通り。
Processor type and features --->
[*] MTRR (Memory Type Range Register) support
Device Drivers --->
Graphics support --->
<*> /dev/agpgart (AGP Support) --->
--- /dev/agpgart (AGP Support)
< > AMD Opteron/Athlon64 on-CPU GART support
-*- Intel 440LX/BX/GX, I8xx and E7x05 chipset support
< > SiS chipset support
< > VIA chipset support
[ ] VGA Arbitration
[ ] Laptop Hybrid Graphics - GPU switching support
<*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
--- Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)
[*] Enable legacy fbdev support for your modesetting driver
[ ] Allow to specify an EDID data set instead of probing for it
I2C encoder or helper chips --->
< > 3dfx Banshee/Voodoo3+
< > ATI Rage 128
< > ATI Radeon
< > AMD GPU
< > Nouveau (NVIDIA) cards
< > Intel I810
<*> Intel 8xx/9xx/G3x/G4x/HD Graphics
[ ] Enable preliminary support for prerelease Intel hardware by default
< > Matrox g200/g400
< > SiS video cards
< > Via unichrome video cards
< > Savage video cards
< > Virtual GEM provider
< > DRM driver for VMware Virtual GPU
< > Intel GMA5/600 KMS Framebuffer
< > DisplayLink
< > AST server chips
< > Kernel modesetting driver for MGA G200 server engines
< > Cirrus driver for QEMU emulated device
< > QXL virtual GPU
< > DRM Support for bochs dispi vga interface (qemu stdvga)
Display Panels ----
Display Interface Bridges ----
Frame buffer Devices --->
-*- Backlight & LCD device support --->
Console display driver support --->
[*] Bootup logo --->
その他
GPTのサポート
お気づきかもしれませんがUEFI-GPT環境ですので、必須。
-*- Enable the block layer --->
Partition Types --->
[*] Advanced partition selection
[*] EFI GUID Partition support
ACPIイベントのサポート
サスペンドできたりできなかったりしろ。
Windowsの高速スタートアップはマルチブート環境になった瞬間にゴミと化す。
Power management and ACPI options --->
[*] ACPI (Advanced Configuration and Power Interface) Support
カーネルモジュールのサポート
コレ切ったまま設定すすめててなんでモジュールにできないんだろう…ってなってました。
Enable loadable module support --->
[*] Compress modules on installation
Compression algorithm () --->
<X> GZIP
XZ
ビルド
外部モジュール
まず外部モジュールの準備
root$ make modules_prepare
ビルド
-jX
オプションは 論理コア数+1 がよいらしいです。
4コア8スレッドのマシンなので -j9
になります。
root$ make -j9
インストール
モジュールと本体をいれる。
古いカーネルを残す数ってどこで調整できるんすか(疑問)。
root$ make modules_install
root$ make install
外部モジュールのrebuildを忘れずにすること。
うちの場合は wl
とかVirtualBox関係が外部モジュールです。
ミスると再起動後にロード不能になって、該当モジュールの再インストールを余儀なくされます。
root$ emerge --ask @module-rebuild
再ビルドするとき
ミスってしまったとき用
distclean
は全部消すのでコンフィグをバックアップする。
root$ cp .config /usr/src/kernel_config_bk
root$ make distclean
root$ mv /usr/src/kernel_config_bk .config
ブートローダに読ませる
パスは適宜読み替えてください。
めんどくさいので私は grub-customizer
を使いますが…
root$ grub-mkconfig -o /boot/efi/grub/grub.cfg
再起動して無事に使えれば更新完了。
素敵なGentoo Linuxライフを。
参考
SDカードのこと以外はGentoo Wikiからです。
- カーネルアップグレード : https://wiki.gentoo.org/wiki/Kernel/Upgrade/ja
- SDカード : http://ameblo.jp/dumbobambino/entry-11648331063.html
- Xorg/ガイド : https://wiki.gentoo.org/wiki/Xorg/Guide/ja
- Xorg/3Dアクセラレーションガイド : URL長いのでここのリンクで
- intel : https://wiki.gentoo.org/wiki/Intel
- ALSA : https://wiki.gentoo.org/wiki/ALSA
- System Time : https://wiki.gentoo.org/wiki/System_time/ja
- QEMU : https://wiki.gentoo.org/wiki/QEMU
- カーネル/コンフィグレーション : https://wiki.gentoo.org/wiki/Kernel/Configuration/ja
- カーネル/コンフィグレーションガイド : 長いので同様
- カーネルの設定 : 長いので同様
- Bluetooth Input devices : https://wiki.gentoo.org/wiki/Bluetooth_Input_devices
- Bluetooth : https://wiki.gentoo.org/wiki/Bluetooth
- Wifi : https://wiki.gentoo.org/wiki/Wifi/ja
- iptables : https://wiki.gentoo.org/wiki/Iptables
- ホームルーター : https://wiki.gentoo.org/wiki/Home_Router/ja
- Android USB Tethering : https://wiki.gentoo.org/wiki/Android_USB_Tethering
- Aruduino : https://wiki.gentoo.org/wiki/Arduino