# [SOLVED]make: *** No rule to make target 'menuconfig'. Stop

## C666PO

Hello,

I need to config tor but for that i need to make some changes in the kernel configuration. I went to /usr/src/linux and after make menuconfig i get this error:

make: *** No rule to make target 'menuconfig'.  Stop.

I searched on the docs and found this:Make menuconfig error:

https://wiki.gentoo.org/wiki/Handbook_Talk:AMD64/Installation/Kernel

Apparently it's fixed by doing "emerge --ask sys-kernel/gentoo-sources" which i did. A new folder in /usr/src appeared linux-4.19.86. I went to this folder and i could make menuconfig without error, however i assume it has the default kernel config for my PC. 

I don't mind to upgrade the kernel but i would like at least to keep the configuration.

What do you advise and how do i keep my config ?

Kind regards,Last edited by C666PO on Fri Aug 28, 2020 1:13 pm; edited 1 time in total

----------

## nvaert1986

1. Make a backup of the .config file in /usr/src/linux

2. Create a new symlink to /usr/src/linux. The easiest way is eselect kernel list and eselect kernel set [number] (replace [number]) with the new kernel number).

3. Copy .config back to /usr/src/linux

4. Make your changes

5. Run either make oldconfig or make && make modules_install

----------

## C666PO

Hi,

So this topic was actually from an old installation, i changed machine and reinstalled Gentoo but i'm facing a similar issue.

I had the kernel version 5.4.48-gentoo manual configured. i couldn't make menuconfig as the topic is described. The link of /usr/src/linux was directed to the kernel version 48 located in /usr/src/

I did eselect kernel list, could only find the version 5.4.60 which was strange. eselect kernel set 1 and after an ls -a i see the link directed to version 5.48.60, i copied the .config i had as a backup to the linux folder.

With make menuconfig i loaded .config, made the changes i needed, saved them, then make && make modules_install.

After this uname -r told me the version was still 48. So i did "make install" and rebooted the machine.

Issue i have now is that i can't vnc the machine anymore for some reason, and while i can ssh it the uname -r tells me the version is still 48.

Does anyone know what i have missed ?

Kind regards,

----------

## ian.au

 *C666PO wrote:*   

> 
> 
> With make menuconfig i loaded .config, made the changes i needed, saved them, then make && make modules_install.
> 
> After this uname -r told me the version was still 48. So i did "make install" and rebooted the machine.
> ...

 

At no point there do you say where you pointed your bootloader at the new kernel...

Edit to say, you are --depcleaning your running kernel sources, which is at the root of this inconvenience. man emerge and look up the --no-replace and --deselect options - they're ideal for managing kernel sources

----------

## C666PO

Hi ian,

Yes, i didn't configure the bootloader for the new kernel, i'm still a noob at this and no doubt i forget the simple steps. I deleted the version 48 in the grub folder, configured the grub again, rebooted and now i have the 60 version. 

I was reading the options --depclean, --no-replace, --deselect but they sound more complicated then i expected, specially without an example.

I thought --depclean simply removed packages that were not needed by the system, or at least not needed anymore. Are you able to provide an example with a command to update, upgrade and remove packages the system doesn't need without affecting the kernel, an example to avoid this issue in the future ?

With thanks and regards,

----------

## NeddySeagoon

C666PO,

New kernels don't have a .config file at all.

When you run make menuconfig, the make system loads a defaultconfig which is mostly no use to anyone.

Here's what happened to you. You did an update that fetched new kernel sources.

The update went well and you ran 

```
emerge --depclean
```

That removed all the downloaded files from /usr/src/linux, which points to an older kernel that the one your update fetched.

The key here is  'downloaded files'. Your .config and all the generated files are still there but  /usr/src/linux/Makefile has gone as it was downloaded.

Hence your error.

Copy  /usr/src/linux/.config to your new kernel source tree and do the kernel update dance.

You can do something similar with gcc when you have a new gcc installed but not yet selected.

--depclean will remove your active gcc. That's scary the first time.

What you are reporting is normal behavior.

Its possible emerge your old kernel again if you really need it but you need to specify the slot, as you don't want the newest kernel.

----------

## ian.au

 *C666PO wrote:*   

> Hi ian,
> 
> Yes, i didn't configure the bootloader for the new kernel, i'm still a noob at this and no doubt i forget the simple steps. I deleted the version 48 in the grub folder, configured the grub again, rebooted and now i have the 60 version. 
> 
> I was reading the options --depclean, --no-replace, --deselect but they sound more complicated then i expected, specially without an example.
> ...

 

C666PO,

I can tell you how I manage kernel sources, there are different methods, and I think there was a thread from earlier this year with a few contributors who use different methods - but this works for me:

If after syncing there is a kernel source upgrade I want to apply, I'll install that explicitly before I emerge world ie.

```
emerge --no-replace sys-kernel/gentoo-sources:5.4.60
```

 That will keep your sources from being inadvertently nuked by a subsequent --depclean 

```
emerge --deselect sys-kernel/gentoo-sources:5.4.60
```

 can subsequently be used to remove the slotted kernel from @world for a later --depclean when you actually want to remove those sources. The --depclean output will then tell you what artifacts it has left for manual removal.

Then emerge world ie.

```
emerge --update --deep --changed-use --with-bdeps=y @world
```

That emerges the sources, step 1 of the below, then starting from 2 is copying the .config across per NeddySeagoon's reply and you can go from there.

```
Work from # /usr/src

1. emerge the sources

2. cp /usr/src/linux/.config /usr/src/linux-x.x.x-gentoo/

3. eselect kernel list

4. eselect kernel set x

5. cd /usr/src/linux

6. make oldconfig menuconfig [add menuconfig only if you're wanting to modify the kernel]

7. make && make modules_install

8. make install

9. grub-mkconfig -o /boot/grub/grub.cfg [assuming grub as your bootloader]

10 emerge --ask @module-rebuild

Clean Old Kernels Out and delete them at your leisure

mv /boot/*-X.X.X-gentoo ~/oldKernels/

On some older installs with small boot partitions, I have to insert the above command between 7&8 above to preserve space
```

----------

## figueroa

Note that there is a handbook page for kernel configuration, compilation and installation. It's a good idea to read and understand, even though it's somewhat old.

My recent cheat sheet (note, my NEW kernel is 4.9.233):

```
# Install your new kernel sources.

emerge -a gentoo-sources

or

emerge -a =sys-kernel/gentoo-sources-4.9.233

# NB: /usr/src/linux should currently be a symlink to your current kernel sources.

# Copy the .config from your current kernel sources to your new kernel sources, i.e.

cd /usr/src/

cp linux/.config linux-4.9.233-gentoo/

# Remove the (old) symlink.

rm linux

# Create a new "linux" symlink to your new kernel sources, i.e.

ln -s linux-4.9.233-gentoo linux

# Alternatively, you can change/set the symlink using eselect. (I don't use this method.) Example:

eselect kernel list

Available kernel symlink targets:

  [1]   linux-4.9.221-gentoo

  [2]   linux-4.9.228-gentoo *

  [3]   linux-4.9.233-gentoo

eselect kernel set 3

# Be sure to check your work with:

eselect kernel list

Available kernel symlink targets:

  [1]   linux-4.9.221-gentoo

  [2]   linux-4.9.228-gentoo

  [3]   linux-4.9.233-gentoo *

or

ls -l

total 15080

lrwxrwxrwx  1 root     root           20 Aug 24 13:20 linux -> linux-4.9.233-gentoo/

drwxr-xr-x 26 root     root         4096 May  5 22:58 linux-4.9.221-gentoo/

drwxr-xr-x 26 root     root         4096 Aug  9 23:11 linux-4.9.228-gentoo/

drwxr-xr-x 26 root     root         4096 Aug 24 13:41 linux-4.9.233-gentoo/

# Change to the new kernel sources directory using,

cd linux/

# Configure the new kernel.

make menuconfig

# Compile the new kernel and install the modules.

make && make modules_install

# Backup your current boot files, just in case, and you wont' be sorry.

cp -a /boot/* /backup_path/

# Copy important kernel boot files to /boot

cp .config /boot/config-4.9.233-gentoo

cp System.map /boot/System.map-4.9.233-gentoo

cp arch/x86/boot/bzImange /boot/kernel-4.9.233-gentoo

# Check your work.

ls -l /boot

total 29984

drwxr-xr-x 2 root root    4096 Aug 24 14:34 bak/

drwxr-xr-x 6 root root    4096 Aug 24 14:34 grub/

-rw-r--r-- 1 root root  103990 May  5 23:22 config-4.9.221-gentoo

-rw-r--r-- 1 root root  103979 Jul 31 16:40 config-4.9.228-gentoo

-rw-r--r-- 1 root root  103968 Aug 24 14:28 config-4.9.233-gentoo

-rw-r--r-- 1 root root   70656 Jun 18 15:09 early_ucode.cpio

-rw-r--r-- 1 root root 6566384 May  5 23:24 kernel-4.9.221-gentoo

-rw-r--r-- 1 root root 6566384 Jul 31 16:40 kernel-4.9.228-gentoo

-rw-r--r-- 1 root root 6566384 Aug 24 14:29 kernel-4.9.233-gentoo

-rw-r--r-- 1 root root 3527358 May  5 23:23 System.map-4.9.221-gentoo

-rw-r--r-- 1 root root 3528569 Jul 31 16:40 System.map-4.9.228-gentoo

-rw-r--r-- 1 root root 3529767 Aug 24 14:28 System.map-4.9.233-gentoo

lrwxrwxrwx 1 root root      21 Aug 27 16:46 vmlinuz -> kernel-4.9.233-gentoo

# Configure boot loader (grub assumed).

grub-mkconfig -o /boot/grub/grub.cfg

Reference: https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel
```

----------

## C666PO

Thank you all for your responses.

This will help alot!

Kind regards,

----------

## figueroa

In my kernel building notes, I left out one step.

After copying the kernel files to /boot, remove old symlink "vmlinuz" to old /boot/kernel-nn-gentoo and create new symlink "vmlinuz" to new kernel file, i.e.

```
cd /boot

rm vmlinuz

ln -s kernel-4.9.233-gentoo vmlinuz
```

because vmlinuz is the traditional name of the bootable compressed kernel image that we've copied into /boot.

----------

