How to Configure the Network after an initial install of Gentoo?

12,871

Chrooting

You should be able to boot the minimal livecd, mount your Gentoo installation in its current state, and chroot in. From this livecd-based networking-enabled chroot, you should be able to emerge and configure any packages necessary for your install to access the network. To achieve this, you basically follow the procedures listed in the Gentoo Handbook , selectively skipping steps that would overwrite/format/delete your existing installation. So, to get started,

  1. Boot the livecd.
  2. If necessary, configure it to be able to access the internet.
  3. Mount the partitions you configured (“Mounting”), starting with mounting your root on /mnt/gentoo. E.g., # mount /dev/sda1 /mnt/gentoo in most common setups if your root partition is your first partition (some setups might have the first partition to be /boot, you want the / partition, not the /boot one in this step).
  4. chroot into it (“Chrooting”). At the simplest, this might look like # cd /mnt/gentoo; cp /etc/resolv.conf etc/; mount none -t proc proc; mount --rbind /sys sys; mount --rbind /dev dev; chroot .. The results in a shell which is just like you had booted up your computer without the livecd but with networking magically working (because we made it inherit the network configuration from the livecd). Don’t forget that you need to chroot manually from each individual VT shell that you want to use while configuring your Gentoo on hard disk.
  5. Install the necessary tools, make the necessary kernel configuration changes (if necessary), etc. through the chroot onto your computer so that it is capable of networking by itself.

Kernel

This last step is the hard part. If you used genkernel to configure your kernel, everything should, for the most part, “just work”. Your kernel is probably configured correctly if you can see something that looks like a wireless device in the output of either ifconfig -a, ip link, or iwconfig. If you are not using genkernel, you probably missed the driver in make menuconfig and should configure and recompile your kernel. I again recommend to follow the Handbook here, but the following is my best memory as to how this might go:

  1. As root, visit your kernel’s source directory. Most probably, # cd /usr/src/linux.
  2. Run # make menuconfig.
  3. Ensure that the necessary drivers and correct general wireless subsystem support is enabled.
    • Under Networking supportWirelesscfg80211 (CONFIG_CFG80211)
    • Under Device driversNetwork device supportWireless LAN is the most likely place you’ll find your specific device. If you don’t know which driver to choose, check the output of # lspci or, on the livecd, see if any of the loaded kernel modules (output of # lsmod) appear to be wifi-related.
  4. Exit from menuconfig, being sure to save the configuration when prompted.
  5. Run # make && make modules_install.
  6. Ensure that /boot is mounted (if you have a separate /boot partition configured). If booted from disk, # mount /boot should work.
  7. Copy arch/x86/boot/bzImage (yes, use x86 even if you’re on amd64. For other arches, the procedure at this point is probably different) over your existing image in /boot. If necessary, run any magic commands related to your bootloader (if using GRUB, just popping the kernel into place and possibly editing grub.conf (unsure about grub-2*) should be enough).
  8. Reboot cleanly.

Userspace

If you think your wireless interface shows up in ifconfig -a or ip link, you probably are just missing the necessary userspace utilities and configuration to get networking to start up by itself. “Installing Necessary Tools: Networking Tools” gets you started. But it sounds like you need wireless userspace tools which are not directly mentioned in that section but discussed under “Wireless Networking”. But you might instead want to install something like kde-misc/networkmanagement which is a NetworkManager integrated into KDE. This might (I don’t use KDE/haven’t tested) automatically ensure that networkmanager is running once you log into your KDE session and should automatically pull in any necessary wifi-supportive packages. If you go this route, you will end up with a NetworkManager instance which will automatically manage launching the necessary wifi tools/supplicant—I think you shouldn’t need to touch wpa_supplicant.conf yourself in this situation. Or if you want to have iwconfig available on your system, install net-wireless/wireless-tools. If you want to manually configure access to wifi networks secured with modern (WPA/WPA2) technology through the CLI (without NetworkManager), you will need to directly install net-wireless/wpa_supplicant, add your networks to /etc/wpa_supplicant/wpa_supplicant.conf, create the appropriate symlink to net.lo in /etc/init.d named net.<wifi iface> where <wifi iface> is the wireless interface’s name as seen in # ifconfig -a, and configure the interface to initialize at boot time with # rc-update add net.<wifi iface> default (this might not work if you are using systemd and assumes you are using openrc).

One note on installing KDE: selecting a KDE portage profile through # eselect profile set default/linux/amd64/13.0/desktop/kde (you may be running an arch other than amd64) is not enough to actually get KDE installed. It just sets USEflags and other values so that, when you install packages, you get the KDE/Qt variants and avoid Gnome/GTK+ somewhat. To install KDE, you should install either kde-meta (more packages) or kdebase-meta (fewer packages, should install much faster), and you might do this while still running on the livecd chroot if you want KDE to be there when you reboot from your hard disk. You could also install the KDE frontend to networkmanager, kde-misc/networkmanagement, at the same time. But, be warned: depending on your hardware and other factors, it will take a while. The following will install the more minimal starting KDE install and the KDE-integrated NetworkManager:

# emerge -va kdebase-meta kde-misc/networkmanagement

Synopsis

But, to sum up, you need to configure critical things like network access while still running from the livecd. Installing the necessary network support packages works much better when there is a working internet connection over which their sources can be downloaded. And once your Gentoo install has what it needs to internet, you can try booting from disk and see if that was enough. You may find yourself booting the livecd and chrooting in again (and, regardless, being familiar with how to do this can be very handy!). Sorry for the condensed answer, but this is quite broad and, really, exactly how to configure wireless and use KDE is up to you to a point.

Share:
12,871

Related videos on Youtube

tread
Author by

tread

Updated on September 18, 2022

Comments

  • tread
    tread over 1 year

    I installed gentoo with the minimal CD. Utilities like iwconfig and net-setup are included and I managed to connect on the livecd to the network (and the internet).

    However when I boot my system I noticed that the desktop environment KDE didn't start even though I had chosen that eselect profile. Anyway, I needed to emerge xorg but I realised I wasn't connected to net.

    Now I get command not found for: iwconfig and net-setup

    So I don't really know how to use the livecd and emerge the Wireless tools and net-setup. How do I do that or is a better way of doing it?

  • tread
    tread about 10 years
    Alright so KDE is not installed by default, it just changes USE flags so it is a smooth transition. Yes I setup wireless on the livecd, but I though I could just pull the configuration over in conf files. Anyway I will do as you said and emerge the required packages. Thanks.
  • tread
    tread about 10 years
    How do you make kernel changes, I don't remember if I installed wireless, as when I iwconfig it says no extensions found. o I have to rebuild the kernel / recomplie?
  • binki
    binki about 10 years
    @StevieG, If you used genkernel to compile/configure your wireless device, it should “just work”. The only other thing I can think of is that perhaps some firmware package specific to your wireless card is necessary. But, that error message from iwconfig does mean your kernel is missing the driver (or, perhaps, the driver was missing the firmware necessary to initialize). You can run lspci (perhaps from the livecd) or, from the livecd, examine the output of lsmod to try to see which drivers the livecd is using to help you configure your on-disk kernel.
  • binki
    binki about 10 years
    I’ve added a section attempting to summarize how to reconfigure the kernel.
  • BatchyX
    BatchyX about 10 years
    @StevieG: iwconfig and wireless extensions are totally obsolete by today's standard, as they do not even support 802.11n properly, let alone 802.11ac. Use iw instead. The kernel option to enable wext hackward compatibility (it is such an horror that it lies most of the time) is CONFIG_CFG80211_WEXT and is disabled by default. Keep it disabled and forget about iwconfig. All other tools moved to the newer nl80211 kernel API.
  • binki
    binki about 10 years
    When I configure wifi via CLI, I configure wpa_supplicant.conf as root directly and initialize it through /etc/init.d/net.<wifi iface>. When starting the init.d script, it should give some message about how wpa_supplicant was launched but the script can’t wait for the interface to come up because it doesn’t know when it’ll actually get connected to the network. This works poorly in real mobile use with configuring new nets on the fly. If having it working under KDE is sufficient, I’d just be happy with that as a manually-configured wpa_supplicant would conflict with KDE/networkmanager.
  • Scott - Слава Україні
    Scott - Слава Україні over 6 years
    If the problem were that ping superuser.com reported that it couldn't figure out the IP address for superuser.com, that would make sense.  But how would that relate to “command not found” for: iwconfig and net-setup?