Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 457702

Summary: eclean-kernel doesn't work w/ grub2 when /boot is FAT
Product: Gentoo Linux Reporter: Douglas J Hunley <doug.hunley>
Component: Current packagesAssignee: Michał Górny <mgorny>
Status: UNCONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Douglas J Hunley 2013-02-15 14:48:25 UTC
I've got Gentoo installed on a macbook pro which uses UEFI and Grub2 to boot. My grub.cfg is in /boot/GRUB2/grub.cfg but eclean-kernel looks for /boot/grub2 so it removes all my kernels since it thinks they are not listed in the config. Since my /boot is FAT, it is case-insensitive so 'cd /boot/grub2' works but eclean-kernel doesn't want to be case-insensitive apparently:
doug-mac boot # pwd
/boot
doug-mac boot # ls
EFI    System.map-3.7.7-gentoo  config-3.7.7-gentoo  vmlinuz-3.7.7-gentoo
GRUB2  System.map-3.7.8-gentoo  config-3.7.8-gentoo  vmlinuz-3.7.8-gentoo
doug-mac boot # grep vmlinuz /boot/grub2/grub.cfg
        linux   /vmlinuz-3.7.8-gentoo root=/dev/sda3 ro  
                linux   /vmlinuz-3.7.8-gentoo root=/dev/sda3 ro  
                linux   /vmlinuz-3.7.8-gentoo root=/dev/sda3 ro single 
                linux   /vmlinuz-3.7.7-gentoo root=/dev/sda3 ro  
                linux   /vmlinuz-3.7.7-gentoo root=/dev/sda3 ro single 
doug-mac boot # eclean-kernel -a -p
Preserving currently running kernel (3.7.7-gentoo)
These are the kernels which would be removed:
- 3.7.8-gentoo: not referenced by bootloader (grub2)
Bootloader grub2 config will be updated.
doug-mac boot #

doug-mac boot # eix eclean-kernel
[I] app-admin/eclean-kernel
     Available versions:  (~)0.3.1 (~)0.3.2{tbz2} **9999 {PYTHON_TARGETS="pypy1_9 python2_6 python2_7 python3_1 python3_2 python3_3"}
     Installed versions:  0.3.2{tbz2}(09:00:43 PM 02/02/2013)(PYTHON_TARGETS="python2_7 python3_2 -pypy1_9 -python2_6 -python3_1 -python3_3")
     Homepage:            https://bitbucket.org/mgorny/eclean-kernel/
     Description:         Remove outdated built kernels

doug-mac boot #
Comment 1 Chí-Thanh Christopher Nguyễn gentoo-dev 2013-02-15 15:09:14 UTC
As a temporary workaround you can mount with iocharset=utf8 so the filesystem becomes case sensitive.

Keep in mind however that Windows does not handle well if two files' filenames differ only in case.
Comment 2 Douglas J Hunley 2013-02-15 15:17:45 UTC
(In reply to comment #1)
> As a temporary workaround you can mount with iocharset=utf8 so the
> filesystem becomes case sensitive.

I'll try this, thanks

> Keep in mind however that Windows does not handle well if two files'
> filenames differ only in case.

No other OS on this machine (I even nuked OSX completely) so that's not much of a concern thankfully
Comment 3 Douglas J Hunley 2013-02-20 13:40:37 UTC
It appears that the mount option recommended doesn't help:
doug-mac ~ # mount|grep /boot
/dev/sda1 on /boot type vfat (rw,iocharset=utf8)
doug-mac ~ # grep vmlinuz /boot/grub2/grub.cfg
grep: /boot/grub2/grub.cfg: No such file or directory
doug-mac ~ # grep vmlinuz /boot/GRUB2/grub.cfg
        linux   /vmlinuz-3.8.0-gentoo root=/dev/sda3 ro  
                linux   /vmlinuz-3.8.0-gentoo root=/dev/sda3 ro  
                linux   /vmlinuz-3.8.0-gentoo root=/dev/sda3 ro single 
                linux   /vmlinuz-3.7.8-gentoo root=/dev/sda3 ro  
                linux   /vmlinuz-3.7.8-gentoo root=/dev/sda3 ro single
doug-mac ~ # eclean-kernel -a -p
Preserving currently running kernel (3.7.8-gentoo)
These are the kernels which would be removed:
- 3.8.0-gentoo: not referenced by bootloader (symlinks)
- 3.7.7-gentoo: vmlinuz does not exist, not referenced by bootloader (symlinks)

Note that the 'grep' that used to work, now fails with this mount option :(
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-02-20 20:35:39 UTC
I don't really see where something could fail here. Could you run with '--debug' please? And please also paste 'eclean-kernel --list-kernels'.
Comment 5 Douglas J Hunley 2013-02-20 20:40:36 UTC
doug-mac ~ # mount|grep boot
/dev/sda1 on /boot type vfat (rw,iocharset=utf8)
doug-mac ~ # ls /boot
EFI    System.map-3.7.8-gentoo  config-3.7.8-gentoo  vmlinuz-3.7.8-gentoo
GRUB2  System.map-3.8.0-gentoo  config-3.8.0-gentoo  vmlinuz-3.8.0-gentoo
doug-mac ~ # eclean-kernel --list-kernels
3.8.0-gentoo:
- vmlinuz: /boot/vmlinuz-3.8.0-gentoo
- systemmap: /boot/System.map-3.8.0-gentoo
- config: /boot/config-3.8.0-gentoo
- modules: /lib64/modules/3.8.0-gentoo
- build: /usr/src/linux-3.8.0-gentoo
3.7.8-gentoo:
- vmlinuz: /boot/vmlinuz-3.7.8-gentoo
- systemmap: /boot/System.map-3.7.8-gentoo
- config: /boot/config-3.7.8-gentoo
- modules: /lib64/modules/3.7.8-gentoo
- build: /usr/src/linux-3.7.8-gentoo
doug-mac ~ # eclean-kernel -a -p --debug
* Trying bootloader lilo
* Trying bootloader grub2
* Trying bootloader grub
* Trying bootloader yaboot
* Trying bootloader symlinks
* In get_removal_list()
Preserving currently running kernel (3.7.8-gentoo)
These are the kernels which would be removed:
- 3.8.0-gentoo: not referenced by bootloader (symlinks)
doug-mac ~ #
Comment 6 Douglas J Hunley 2013-02-20 20:44:21 UTC
It looks like it doesn't realize Grub2 is in use, so I tried to force it:
doug-mac ~ # eclean-kernel -a -p --bootloader=grub2
Traceback (most recent call last):
  File "/usr/bin/eclean-kernel-python3.2", line 26, in <module>
    sys.exit(main(sys.argv))
  File "/usr/lib64/python3.2/site-packages/ecleankernel/cli.py", line 142, in main
    debug = debug)
  File "/usr/lib64/python3.2/site-packages/ecleankernel/process.py", line 39, in get_removal_list
    % bootloader)
SystemError: Unable to get kernels from bootloader config (None)
doug-mac ~ # eclean-kernel -a -p --bootloader=grub2 --debug
* Trying bootloader grub2
* In get_removal_list()
Traceback (most recent call last):
  File "/usr/bin/eclean-kernel-python3.2", line 26, in <module>
    sys.exit(main(sys.argv))
  File "/usr/lib64/python3.2/site-packages/ecleankernel/cli.py", line 142, in main
    debug = debug)
  File "/usr/lib64/python3.2/site-packages/ecleankernel/process.py", line 39, in get_removal_list
    % bootloader)
SystemError: Unable to get kernels from bootloader config (None)
doug-mac ~ #
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-02-20 20:47:09 UTC
Well, since you set iocharset, the filesystem became case-insensitive and eclean-kernel behaves properly now.

You can either:

a) try to debug it further -- unmount, mount it again *without* the iocharset thing so it becomes case-insensitive and show me debug then,

b) or just mv /boot/{GRUB2,grub2} while it is mounted case-sensitive and it should work from now on.

Also, from your first paste it seems that eclean-kernel was actually reading the config file but didn't match kernels from it for some reason.
Comment 8 Douglas J Hunley 2013-02-20 20:51:05 UTC
doug-mac ~ # mount|grep boot
/dev/sda1 on /boot type vfat (rw)
doug-mac ~ # eclean-kernel -a -p --debug
* Trying bootloader lilo
* Trying bootloader grub2
** /boot/grub2/grub.cfg found
* In get_removal_list()
** Config is autogenerated, ignoring
Preserving currently running kernel (3.7.8-gentoo)
These are the kernels which would be removed:
- 3.8.0-gentoo: not referenced by bootloader (grub2)
Bootloader grub2 config will be updated.
doug-mac ~ # !grep
grep vmlinuz /boot/GRUB2/grub.cfg
        linux   /vmlinuz-3.8.0-gentoo root=/dev/sda3 ro  
                linux   /vmlinuz-3.8.0-gentoo root=/dev/sda3 ro  
                linux   /vmlinuz-3.8.0-gentoo root=/dev/sda3 ro single 
                linux   /vmlinuz-3.7.8-gentoo root=/dev/sda3 ro  
                linux   /vmlinuz-3.7.8-gentoo root=/dev/sda3 ro single 
doug-mac ~ #
Comment 9 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-08-07 09:52:20 UTC
Sorry for answering that late.

(In reply to Douglas J Hunley from comment #8)
> ** Config is autogenerated, ignoring

This is the key note. When config is autogenerated, grub automatically adds and removes kernels from it. eclean-kernel can't really make any useful info out of that as usually all kernels will be there.

You need to use '-nX' to decide how many recent kernels you want to keep. However, I could also add some kind of failsafe to prevent removing the last kernel.