KUSONEKOの見る世界

自宅サーバ省電力化 NIC編

以前使っていた自宅サーバは、夜にshutdownし、朝にbootするというのを自動でやっていたのですが、現在の自宅サーバはshutdownに失敗することが多く、断念し、常時稼働にしていました。

そのまま何の対策もせずに放置でしたが、AtermがECOモードで1Gbpsから100Mbpsに下げる事を思い出し、自宅サーバでもやってみました。
我が家にワットチェッカーが無いので分かりませんが、ネットで調べると、
1000BASE-Tから100BASE-TXに落とすのは効果があるようです。

初期状態

ethtoolを使うと現状のリンク状態が分かります。
サーバ側は、Advertised link modesが1000baseT/Fullになっており、
対向のヤマハ RTX810で、Auto-negotiationになっているので、最高速度の1000/Fullでアップしています。
[root@Server ~]# ethtool enp2s0
Settings for enp2s0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000033 (51)
                               drv probe ifdown ifup
        Link detected: yes

速度変更後

ethtoolでは、以下のコマンドでAdvertised link modesを変更できます。
[root@Server ~]# ethtool -s enp2s0 speed 10 duplex full autoneg on

結果、リンク速度は、10/FUllとなりました。
[root@Server ~]# ethtool enp2s0
Settings for enp2s0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: 10Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000033 (51)
                               drv probe ifdown ifup
        Link detected: yes
戻す場合は、以下のコマンドで戻します。
[root@Server ~]# ethtool -s enp2s0 speed 1000 duplex full autoneg on

crontabに登録

これらのコマンドをcrontabで自動化させます。
内容は、夜0:30に10Mに落とし、朝6時に1000Mに戻します。
[root@Server ~]# crontab -e

30 0 * * * /sbin/ethtool -s enp2s0 speed 10 duplex full autoneg on
0 6 * * * /sbin/ethtool -s enp2s0 speed 1000 duplex full autoneg on