개발

nvidia 를 사용하는 ubuntu 네트워크 인터페이스가 안보이는 문제

eun2ce 2022. 8. 6. 12:18

ethernet controller 모델번호를 확인합니다.

$ lspci | grep Realtek
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 03)

커널이 정상적으로 드라이버를 로딩했는지 확인합니다.

$ lsmod | grep r816*
r8169 91629 0

칩셋은 r816 인데, 드라이버는 r8169 가 등록되어있다면 이것이 문제의 원인입니다.
혹시 이미 r8168 로 되어있다면 ipv6를 사용안함으로 변경 했을 때 될 수 있습니다.

되다가 안 되는 경우
아래와 같은 문제 일 수 있습니다.

  • 커널 다운그레이드 ( 복구모드에서 잘 되던 커널 버전을 선태하고, 해당 윗 버전의 커널을 삭제합니다. )
  • 새로운 커널 버전에 맞는 네트워크 드라이버 설치

네트워크가 되는 환경 일 경우 해결 방법

# 최신 드라이버 설치
$ sudo apt-get update
$ sudo apt-get install r8168-dkms
# r8169 모듈 제거
$sudo sh -c `echo blacklist r8169` >> /etc/modprobe.d/blacklist.conf

네트워크가 안되는 환경일 경우 해결 방법 (usb 필요)

Realtek 사이트에 가서 리눅스용 8168 드라이버를 다운로드 해서 usb에 담습니다 (자신의 모델에 맞는 것으로 찾을 것)
[ethernet controller 모델번호를 확인합니다.

$ lspci | grep Realtek
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 03)

커널이 정상적으로 드라이버를 로딩했는지 확인합니다.

$ lsmod | grep r816*
r8169 91629 0

칩셋은 r816 인데, 드라이버는 r8169 가 등록되어있다면 이것이 문제의 원인입니다.
혹시 이미 r8168 로 되어있다면 ipv6를 사용안함으로 변경 했을 때 될 수 있습니다.

되다가 안 되는 경우
아래와 같은 문제 일 수 있습니다.

  • 커널 다운그레이드 ( 복구모드에서 잘 되던 커널 버전을 선태하고, 해당 윗 버전의 커널을 삭제합니다. )
  • 새로운 커널 버전에 맞는 네트워크 드라이버 설치

네트워크가 되는 환경 일 경우 해결 방법

# 최신 드라이버 설치
$ sudo apt-get update
$ sudo apt-get install r8168-dkms
# r8169 모듈 제거
$sudo sh -c `echo blacklist r8169` >> /etc/modprobe.d/blacklist.conf

네트워크가 안되는 환경일 경우 해결 방법 (usb 필요)

Realtek 사이트에 가서 리눅스용 8168 드라이버를 다운로드 해서 usb에 담습니다 (자신의 모델에 맞는 것으로 찾을 것)
https://www.realtek.com/en/component/zoo/advanced-search/776?Itemid=276

그런 다음 아래 스크립트를 autorun.sh 파일로 저장하여 usb 에 추가로 함께 담는다.

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only

# invoke insmod with all arguments we got
# and use a pathname, as insmod doesn't look in . by default

TARGET_PATH=$(find /lib/modules/$(uname -r)/kernel/drivers/net/ethernet -name realtek -type d)
if [ "$TARGET_PATH" = "" ]; then
    TARGET_PATH=$(find /lib/modules/$(uname -r)/kernel/drivers/net -name realtek -type d)
fi
if [ "$TARGET_PATH" = "" ]; then
    TARGET_PATH=/lib/modules/$(uname -r)/kernel/drivers/net
fi
echo
echo "Check old driver and unload it."
check=`lsmod | grep r8169`
if [ "$check" != "" ]; then
        echo "rmmod r8169"
        /sbin/rmmod r8169
fi

check=`lsmod | grep r8168`
if [ "$check" != "" ]; then
        echo "rmmod r8168"
        /sbin/rmmod r8168
fi

echo "Build the module and install"
echo "-------------------------------" >> log.txt
date 1>>log.txt
make $@ all 1>>log.txt || exit 1
module=`ls src/*.ko`
module=${module#src/}
module=${module%.ko}

if [ "$module" = "" ]; then
    echo "No driver exists!!!"
    exit 1
elif [ "$module" != "r8169" ]; then
    if test -e $TARGET_PATH/r8169.ko ; then
        echo "Backup r8169.ko"
        if test -e $TARGET_PATH/r8169.bak ; then
            i=0
            while test -e $TARGET_PATH/r8169.bak$i
            do
                i=$(($i+1))
            done
            echo "rename r8169.ko to r8169.bak$i"
            mv $TARGET_PATH/r8169.ko $TARGET_PATH/r8169.bak$i
        else
            echo "rename r8169.ko to r8169.bak"
            mv $TARGET_PATH/r8169.ko $TARGET_PATH/r8169.bak
        fi
    fi
fi

echo "DEPMOD $(uname -r)"
depmod `uname -r`
echo "load module $module"
modprobe $module

is_update_initramfs=n
distrib_list="ubuntu debian"

if [ -r /etc/debian_version ]; then
    is_update_initramfs=y
elif [ -r /etc/lsb-release ]; then
    for distrib in $distrib_list
    do
        /bin/grep -i "$distrib" /etc/lsb-release 2>&1 /dev/null && \
            is_update_initramfs=y && break
    done
fi

if [ "$is_update_initramfs" = "y" ]; then
    if which update-initramfs >/dev/null ; then
        echo "Updating initramfs. Please wait."
        update-initramfs -u -k $(uname -r)
    else
        echo "update-initramfs: command not found"
        exit 1
    fi
fi

echo "Completed."
exit 0

문제가 있는 pc 에 usb 를 마운트한다.

압출풀기

$tar -xvf rxxx.tar.bz2

드라이버 자동 설치를 위해 sudo 권한으로 스크립트를 실행한다.
autorun 스크립트가 패키지가 없어 실패 할 경우 https://eun2ce.tistory.com/5 참고

$ cd r8168-8.018.00
$ sudo ./autorun.sh
  1. 옵션 - 드라이버 테스트
    $ sudo rmmod r8169
    $ sudo modprobe r8168
    $ sudo /etc/init.d/networking restart

이렇게 드라이버를 새로 설치했더니, 네트워크가 정상적으로 동작한다면 아래 방법을 통해 이 설정을 저장합니다.

  1. Blacklist r8169 로 등록하기
    $ sudo gedit /etc/modprobe.d/blacklist.conf

아래 두 줄을 저장

# Blacklist Realtek RTL8111/8169 gigabit driver
blacklist r8169

저장하고 종료합니다.

  1. 드라이버 캐시 업데이트
    $ update-initramfs -u
    재부팅 후, 정상적으로 드라이버가 로드되었는지 확인
    $ lsmod | grep r816*
    r8168 91629 0

해당 원문은 다음을 참고
http://ubuntuforums.org/archive/index.php/t-1436667.html

기본 패키지도 설치가 되어있지 않은 경우 (네트워크연결 없이도 설치 가능하다.)

https://eun2ce.tistory.com/5