# lvm snapshot for menuconfig of old and new kernel [solved]

## duxsco

Hi.

I would like to know whether I can do the following:

Chroot into snapshot and open menuconfig of old kernel:

```
dasa ~ # lvs

  LV        VG   Attr     LSize   Pool Origin Data%  Move Log Copy%  Convert

  root      dasa owi-aos- 200,00g

dasa ~ # lvcreate -l100%FREE -s -n root_snap /dev/dasa/root

dasa ~ # mount /dev/dasa/root_snap /mnt/snap

dasa ~ # rsync -av /boot/ /mnt/snap/boot/

dasa ~ # mount -t proc none /mnt/snap/proc

dasa ~ # mount --rbind /sys /mnt/snap/sys

dasa ~ # mount --rbind /dev /mnt/snap/dev

dasa ~ # chroot /mnt/snap /bin/bash

dasa ~ # source /etc/profile

dasa ~ # export PS1="(chroot) $PS1"

(chroot) dasa ~ # eselect kernel list

Available kernel symlink targets:

  [1]   linux-3.4.41-gentoo *

(chroot) dasa ~ # genkernel --menuconfig --save-config --lvm all
```

Emerge new kernel outside the snapshot and open menuconfig of new kernel in a different terminal window:

```
dasa ~ # emerge -avuDN world

dasa ~ # eselect kernel list

Available kernel symlink targets:

  [1]   linux-3.4.41-gentoo *

  [2]   linux-3.8.8-gentoo

dasa ~ # eselect kernel set 2

dasa ~ # genkernel --menuconfig --save-config --lvm all
```

That way I have the config of the old and new kernel side by side.Last edited by duxsco on Sun Apr 21, 2013 10:52 pm; edited 1 time in total

----------

## linear

Greetings,

Well, if I understand what you are trying to do, you want to grab a copy the file kernel-config-<arch>-<kernel version>-<kernel local version> from the old kernel (READ: inside the snapshot) and compare that with the one from your current kernel?  

The key to what you are trying to do is finding out where genkernel saves it's kernel config files by default; under /etc/kernels/.

Once you have a copy of each of the kernel configs on your system, you can just do: 

```
 ~ # diff kernel-config-<snapshot arch>-<snapshot kernel version>-<kernel local version> kernel-config-<current arch>-<current kernel version>-<kernel local version>
```

And, I would recommend using CONFIG_LOCALVERSION, if you aren't currently.  It helps you keep track of which kernels you built when and why.  E.g.:

```
CONFIG_LOCALVERSION="-linear-20130401-01"

CONFIG_LOCALVERSION_AUTO=y
```

HTH.  Let us know.

----------

## duxsco

Hi linear. Thanks for the quick response.

I think it's easier to compare two kernels by looking at their configs with menuconfig than running "diff /etc/kernels/kernel-config-x86_64-3.8.8 /etc/kernels/kernel-config-x86_64-3.4.41".

If you just upgraded to a new kernel you just have the standard kernel config which differs from the old and well-configured kernel in hundreds of lines. I would like to know whether s.th. speaks against mounting proc, sys and dev in the mounted snapshot folder and running two instances of menuconfig at the same time.

Will this mess up proc, sys or dev?

----------

## linear

Hmmm... 

Well, while the configs are much easier to read with menuconfig, it will take a LOT of flipping between terminal windows and pages within 'make menuconfig' to find all the differences, and the probability of missing something is pretty high.  If you are using a standard terminal (e.g. 80 characters wide), then how about trying something like this:

```
 ~ # diff -y -W80 /etc/kernels/kernel-config-x86_64-3.8.8 /etc/kernels/kernel-config-x86_64-3.4.41 | less
```

which produces something like this:

```
#                                       #

# Automatically generated make config   # Automatically generated make config

# Linux kernel version: 2.6.33-gentoo   # Linux kernel version: 2.6.33-gentoo

# Wed Jun 30 11:58:11 2010            | # Thu Jul  1 14:39:23 2010

#                                       #

CONFIG_64BIT=y                          CONFIG_64BIT=y

# CONFIG_X86_32 is not set              # CONFIG_X86_32 is not set

CONFIG_X86_64=y                         CONFIG_X86_64=y

CONFIG_X86=y                            CONFIG_X86=y

CONFIG_OUTPUT_FORMAT="elf64-x86-64"     CONFIG_OUTPUT_FORMAT="elf64-x86-64"

CONFIG_ARCH_DEFCONFIG="arch/x86/confi   CONFIG_ARCH_DEFCONFIG="arch/x86/confi

CONFIG_GENERIC_TIME=y                   CONFIG_GENERIC_TIME=y

CONFIG_GENERIC_CMOS_UPDATE=y            CONFIG_GENERIC_CMOS_UPDATE=y

CONFIG_CLOCKSOURCE_WATCHDOG=y           CONFIG_CLOCKSOURCE_WATCHDOG=y

CONFIG_GENERIC_CLOCKEVENTS=y            CONFIG_GENERIC_CLOCKEVENTS=y

...<snip>...
```

You can easily tell the changed options by searching for the pipes (e.g. the "|" character) and the missing/added options by searching for the greater than/less than symbols (e.g. the ">" & "<" characters).  As a quick example:

```
#                                                               #

# Automatically generated make config: don't edit             | # Automatically generated file; DO NOT EDIT.

# Linux kernel version: 2.6.33-gentoo-r2                      | # Linux/x86 3.3.8-gentoo Kernel Configuration

# Wed Jun 30 11:58:11 2010                                    <

#                                                               #

CONFIG_64BIT=y                                                  CONFIG_64BIT=y

# CONFIG_X86_32 is not set                                      # CONFIG_X86_32 is not set

CONFIG_X86_64=y                                                 CONFIG_X86_64=y

CONFIG_X86=y                                                    CONFIG_X86=y

                                                              > CONFIG_INSTRUCTION_DECODER=y

CONFIG_OUTPUT_FORMAT="elf64-x86-64"                             CONFIG_OUTPUT_FORMAT="elf64-x86-64"

CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"       CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"

CONFIG_GENERIC_TIME=y                                         <

CONFIG_GENERIC_CMOS_UPDATE=y                                    CONFIG_GENERIC_CMOS_UPDATE=y

CONFIG_CLOCKSOURCE_WATCHDOG=y                                   CONFIG_CLOCKSOURCE_WATCHDOG=y

CONFIG_GENERIC_CLOCKEVENTS=y                                    CONFIG_GENERIC_CLOCKEVENTS=y

                                                              > CONFIG_ARCH_CLOCKSOURCE_DATA=y

CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y                          CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y

CONFIG_LOCKDEP_SUPPORT=y                                        CONFIG_LOCKDEP_SUPPORT=y

CONFIG_STACKTRACE_SUPPORT=y                                     CONFIG_STACKTRACE_SUPPORT=y

CONFIG_HAVE_LATENCYTOP_SUPPORT=y                                CONFIG_HAVE_LATENCYTOP_SUPPORT=y

CONFIG_MMU=y                                                    CONFIG_MMU=y

CONFIG_ZONE_DMA=y                                             | CONFIG_NEED_DMA_MAP_STATE=y

                                                              > CONFIG_NEED_SG_DMA_LENGTH=y

CONFIG_GENERIC_ISA_DMA=y                                        CONFIG_GENERIC_ISA_DMA=y

CONFIG_GENERIC_IOMAP=y                                        <

CONFIG_GENERIC_BUG=y                                            CONFIG_GENERIC_BUG=y
```

Just trying to save you some time and headache.

HTH.  Let us know.

----------

## Hu

 *onndsd wrote:*   

> I think it's easier to compare two kernels by looking at their configs with menuconfig than running "diff /etc/kernels/kernel-config-x86_64-3.8.8 /etc/kernels/kernel-config-x86_64-3.4.41".

 There is no need to play with LVM snapshots for this.  If the kernels are of differing versions, their configurations can coexist under the default name.  If they are of the same version, you can instruct menuconfig to use an alternate name for one of them.

 *onndsd wrote:*   

> 
> 
> If you just upgraded to a new kernel you just have the standard kernel config which differs from the old and well-configured kernel in hundreds of lines.

 If you just upgraded to a new kernel, you should use one of the oldconfig targets to update your configuration.  You still need to proofread it because the results are imperfect, but it does most of the work for you.

 *onndsd wrote:*   

> I would like to know whether s.th. speaks against mounting proc, sys and dev in the mounted snapshot folder and running two instances of menuconfig at the same time.
> 
> Will this mess up proc, sys or dev?

 Only root should have permission to damage any of these, so your build user cannot cause any problems here.

----------

## duxsco

Thanks. I forgot that this is possible:

Terminal 1:

```
# cd /usr/src/linux-3.4.41-gentoo

# make menuconfig
```

Terminal 2:

```
# cd /usr/src/linux-3.8.8-gentoo

# make menuconfig
```

So, lvm isn't needed. Problem solved  :Smile: . I'll use menuconfig or diff depending on the situation. Thanks for the help.

----------

