Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] grub2-mkconfig does not discover all the root parti
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
AchilleTalon
Guru
Guru


Joined: 11 Apr 2004
Posts: 368
Location: Montreal, Quebec, Canada

PostPosted: Sat Jul 18, 2015 8:56 pm    Post subject: [SOLVED] grub2-mkconfig does not discover all the root parti Reply with quote

Hi,

I am setting an external USB drive to become a bootable drive to troubleshoot a laptop I am having problem with. This disk drive was already having stuff on it, namely two old Gentoo complete bootable with grub distributions. However, they are out dated for a long time now and I decided to upgrade it (reinstall). So, I did it for one of the distribution. The partition layout is as follow:

Code:
(chroot) feynman grub # parted /dev/sdg
GNU Parted 3.2
Using /dev/sdg
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                           
Model: ST950032 5AS (scsi)
Disk /dev/sdg: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system     Flags
 1      32.3kB  74.0MB  74.0MB  primary   ext2            boot
 2      74.0MB  1160MB  1086MB  primary   linux-swap(v1)
 3      1160MB  130GB   129GB   primary                   lvm
 4      130GB   500GB   370GB   extended
 5      130GB   302GB   172GB   logical                   lvm
 6      302GB   302GB   633MB   logical   jfs
 7      302GB   303GB   524MB   logical   jfs
 8      303GB   378GB   75.2GB  logical                   lvm
(


Partitions number 6 and 7 are root filesystems. The LVM partitions are having the logical volumes for all the remaining filesystems needed by both distributions. My updated root filesystem distribution is on partition 6 and partition 7 still contains a old out dated distribution left untouched.

When I run the command in the chroot environment:

Code:
grub2-mkconfig -o /boot/grub/grub.cfg


It fails to identify partition 6 as my root filesytem and succeed to identify 7 as a root filesystem. So, the resulting grub.cfg file will not be suitable to boot properly my system. BTW, I am using the systemd setup as well.

Also, I am getting many errors due to LVM not started since I haven't booted yet.

Here are the messages I am getting and clearly I will not be able to boot my newly installed system:

Code:
(chroot) feynman grub # grub2-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
Found linux image: /boot/vmlinuz-3.18.16-gentoo-nvidia
Found initrd image: /boot/initramfs-3.18.16-gentoo-nvidia.img
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
Found Gentoo Base System release 2.0.3 on /dev/sdg7
done


How can I make grub2 detect properly partition 6 instead of 7?

I tried GRUB_DEVICE=/dev/sdg6 in /etc/default/grub configuration file and it seems this environment variable is simply ignored and the install instructions are wrongly referring to it. The official page doesn't say a word about it, so I guess it is obsoleted.

TIA


ADDENDUM: After changing few lines in /etc/default/grub as well as in /etc/grub.d/10_linux to display the value of environment variables at different steps in execution, it appears the grub2-mkconfig command ignores completely the /etc/default/grub script as well as all scripts in /etc/grub.d/. So, WTF is going on here? The command just doesn't work as expected and documented.

Here is my version of GRUB2:

Code:
(chroot) feynman default # equery l grub
 * Searching for grub ...
[IP-] [  ] sys-boot/grub-2.02_beta2-r7:2


And strange enough, if I run the command:
Code:
(chroot) feynman default # /usr/sbin/grub2-probe --target=device /
/dev/sdg6
I get the expected result. This command is copied and pasted from the grub2-mkconfig script itself setting itself GRUB_DEVICE environment variable and getting the UUID of the partition as well.
_________________
Achille Talon Hop!


Last edited by AchilleTalon on Tue Jul 21, 2015 11:51 pm; edited 3 times in total
Back to top
View user's profile Send private message
Keruskerfuerst
Advocate
Advocate


Joined: 01 Feb 2006
Posts: 2288
Location: near Augsburg, Germany

PostPosted: Sun Jul 19, 2015 2:25 pm    Post subject: Reply with quote

Which kernel and which filesystem are you using?
Back to top
View user's profile Send private message
AchilleTalon
Guru
Guru


Joined: 11 Apr 2004
Posts: 368
Location: Montreal, Quebec, Canada

PostPosted: Sun Jul 19, 2015 2:42 pm    Post subject: Reply with quote

Keruskerfuerst wrote:
Which kernel and which filesystem are you using?


Kernel is as shown on the output:

Code:
Found linux image: /boot/vmlinuz-3.18.16-gentoo-nvidia


The filesystem is jfs on both partitions 6 and 7. If is properly recognized by the command:

Code:
(chroot) feynman default # /usr/sbin/grub2-probe --device /dev/sdg6 --target=fs
jfs


As well as the uuid:

Code:
(chroot) feynman default # /usr/sbin/grub2-probe --device /dev/sdg6 --target=fs_uuid
a6bfa90a-f736-47f8-a5ec-1ee33d0568d0


It seems up to this point in the grub2-mkimage script everything is fine, this what happens after:

Code:
gettext "Generating grub configuration file ..." >&2
echo >&2


Which seems the problem and where I lost the found partitions (/ and /boot).

ADDENDUM: After reading more carefully all the scripts, it appears in fact the generated grub.cfg file is almost correct. The message about /dev/sdg7 is from the script /etc/grub.d/30_os-prober which thinks it has found another OS and make an entry for it in the grub.cfg file. It is a bit strange how it sets this other OS. It picks the root filesystem /dev/sdg7 and then, it gets from /usr/src a directory where the sources for kernel 4.0.5 are downloaded (or from the ebuild database) and decides this is the OS installed on this second root filesystem. These sources are even not configured or compiled and no file exist at all on the boot partition for it to boot. So, it seems this script can be improved to not make silly decisions based on wrong assumptions. Setting GRUB_DISABLE_OS_PROBER="true" in /etc/default/grub prevents running the script /etc/grub.d/30_os-prober which fix the problem, but not the fact the os-prober script should be more careful when "discovering" the presence of another Linux partition.
_________________
Achille Talon Hop!
Back to top
View user's profile Send private message
AchilleTalon
Guru
Guru


Joined: 11 Apr 2004
Posts: 368
Location: Montreal, Quebec, Canada

PostPosted: Sun Jul 19, 2015 9:38 pm    Post subject: HELP still needed Reply with quote

Finally, it is not solved. In fact, the entry for the root filesystem is made and at boot time it is mounted, however it fails to scan the logical volumes and mount /usr, /var, /opt and /home which are all on the volume group.

I know in grub version 0.97 I had to add kernel options rd.lvm.vg=myvgname and rd.lvm.lv=myvgname/usr so the kernel activate the volume group and the logical volume containing /usr.

Since I have errors about LVM with the grub2-mkconfig script, are they responsible for the grub.cfg file not having everything it may need to boot properly?

I am new to GRUB2, this is the first time I am trying to make it working. I don't know what is needed in the grub.cfg to make it work with LVM logical volumes.

Any help and hints will be appreciated.

The lvm module and jfs module are both compiled into the kernel, so, no need to check the initramfs for them, they are already in the kernel.
_________________
Achille Talon Hop!
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6281

PostPosted: Sun Jul 19, 2015 10:10 pm    Post subject: Reply with quote

I never used grub2 with lvm, but I would be very surprised if grub2-mkconfig would "magically" add any special lvm kernel options which you seem to need: You will have to add them somewhere to /etc/grub.d before you call grub2-mkconfig. However, this does not seem to be related with your current error you observe.
Quote:
Since I have errors about LVM with the grub2-mkconfig script, are they responsible for the grub.cfg file not having everything it may need to boot properly?

I would guess so. Moreover, I would guess that you need to mount --bind something else in the chroot so that grub2-mkconfig can access the lvm daemon:
Perhaps the socket necessary to access that daemon is in /run or /tmp, so you should also mount these into the chroot (I suppose /dev /proc and /sys are --rbind already anyway,
and I hope that you do not run a hardened kernel which might restrict access to sockets inside of the chroot).

Essentially you have to options: You can try to make grub2-mkconfig work, or you completely give up on that script and manage your grub.cfg manually; it has a similar (though slgihtly different) syntax than the legacy grub.conf, but much more possibilities. Perhaps you should ask whether somebody posts his (working with lvm) grub.cfg: It should be easy to modify. Of course, if nothing else, you can read the grub2 documentation concerning the handling of lvm in grub.cfg. (I cannot help with the latter two since I am not using lvm...)
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Sun Jul 19, 2015 11:16 pm    Post subject: Reply with quote

well grub os_prober and other stuff just broke my boxes in the past

lvm, luks + ext2 boot here and htis is all i need


Code:
menuentry ' 3.18.16-gentoo_2015_06_29' --class gento --class gnu-linux --class gnu --class os {
 linux /3.18.16-gentoo_2015_07_08 init=linuxrc ramdisk=8192 crypt_root=dev/mapper/volume_group_name_you_choose realroot=/dev/mapper/logical_volume_you_choose dolvm net.ifnames=0
 initrd /initramfs-genkernel-x86_64-3.5.3-gentoo_Sept_2012
}


net.ifnames=0 => not really essential, only when you want the old network naming like eth0, wlan0 and such
dolvm => very essential for lvm
init=linuxrc => seems in any grub2.cfg i saw for linux mint and my boxes, seems essential
ramdisk=8192 => i use this for ages, not sure if its really needed, the other box does not have it for example

and i use quite old, as you can see, genkernel generated initramfs (which contrains busybox and something else which i forgot)


---

I think you need an initramfs => use genkernel and generate one
you need all lvm stuff, fs stuff in the kernel
you need ext2 boot with 512mb size (my opinion) kernel / initramfs there, active boot flag, primary partition.
hand written boot entry
Back to top
View user's profile Send private message
AchilleTalon
Guru
Guru


Joined: 11 Apr 2004
Posts: 368
Location: Montreal, Quebec, Canada

PostPosted: Mon Jul 20, 2015 2:19 am    Post subject: Reply with quote

tw04l124 wrote:
well grub os_prober and other stuff just broke my boxes in the past

lvm, luks + ext2 boot here and htis is all i need


Code:
menuentry ' 3.18.16-gentoo_2015_06_29' --class gento --class gnu-linux --class gnu --class os {
 linux /3.18.16-gentoo_2015_07_08 init=linuxrc ramdisk=8192 crypt_root=dev/mapper/volume_group_name_you_choose realroot=/dev/mapper/logical_volume_you_choose dolvm net.ifnames=0
 initrd /initramfs-genkernel-x86_64-3.5.3-gentoo_Sept_2012
}


net.ifnames=0 => not really essential, only when you want the old network naming like eth0, wlan0 and such
dolvm => very essential for lvm
init=linuxrc => seems in any grub2.cfg i saw for linux mint and my boxes, seems essential
ramdisk=8192 => i use this for ages, not sure if its really needed, the other box does not have it for example

and i use quite old, as you can see, genkernel generated initramfs (which contrains busybox and something else which i forgot)


---

I think you need an initramfs => use genkernel and generate one
you need all lvm stuff, fs stuff in the kernel
you need ext2 boot with 512mb size (my opinion) kernel / initramfs there, active boot flag, primary partition.
hand written boot entry


I have an initramfs as shown in the output of the command in my first post. I just said lvm and jfs are compiled in the kernel as well and not as modules even if they could have. I don't need 512MB of /boot and no error is reported regarding a disk space problem here anyway.

You are using OpenRC to initialize your system, that's why you have init=linuxrc and some other options. I am using systemd and the options are then different. I will try the dolvm option which is not present to see if it matters.

Here is a sample of the entry written by the script, beside the dolvm I added manually:

Code:
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-a6bfa90a-f736-47f8-a5ec-1ee33d0568d0' {
        load_video
        if [ "x$grub_platform" = xefi ]; then
                set gfxpayload=keep
        fi
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd7,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd7,msdos1 --hint-efi=hd7,msdos1 --hint-baremetal=ahci7,msdos1  c9dd0fed-99c9-44c6-b99a-a0825f2ea13b
        else
          search --no-floppy --fs-uuid --set=root c9dd0fed-99c9-44c6-b99a-a0825f2ea13b
        fi
        echo    'Chargement de Linux 3.18.16-gentoo-nvidia…'
        linux   /vmlinuz-3.18.16-gentoo-nvidia root=UUID=a6bfa90a-f736-47f8-a5ec-1ee33d0568d0 ro init=/usr/lib/systemd/systemd dolvm
        echo    'Chargement du disque mémoire initial…'
        initrd  /initramfs-3.18.16-gentoo-nvidia.img
}


The insmod are useless, but cannot harm neither I guess, since ext2 is compiled in the kernel as well. In my old grub.conf on another server I have more options, some like: rd.lvm.vg=myvg rd.lvm.lv=myvg/usr and I am not sure if I am supposed to add them as well.


ADDENDUM: I tested the dolvm option and it doesn't make any difference.

Here is the output of the boot log I am getting:

Code:
(...)
[    5.540097] localhost kernel: random: nonblocking pool is initialized
[    5.958390] localhost systemd[1]: Found device ST9500325AS 6.
[    5.960109] localhost systemd[1]: Started dracut initqueue hook.
[    5.961038] localhost systemd[1]: Starting Remote File Systems (Pre).
[    5.962617] localhost systemd[1]: Reached target Remote File Systems (Pre).
[    5.962748] localhost systemd[1]: Starting Remote File Systems.
[    5.964154] localhost systemd[1]: Reached target Remote File Systems.
[    5.964286] localhost systemd[1]: Started dracut pre-mount hook.
[    5.964408] localhost systemd[1]: Starting File System Check on /dev/disk/by-uuid/a6bfa90a-f736-47f8-a5ec-1ee33d0568d0...
[    7.574120] localhost systemd-fsck[364]: fsck.jfs version 1.1.15, 04-Mar-2011
[    7.577195] localhost systemd-fsck[364]: processing started: 7/19/2015 19:00:38
[    7.578890] localhost systemd-fsck[364]: The current device is:  /dev/sdb6
[    7.582408] localhost systemd-fsck[364]: Block size in bytes:  4096
[    7.584009] localhost systemd-fsck[364]: Filesystem size in blocks:  154617
[    7.585567] localhost systemd-fsck[364]: **Phase 0 - Replay Journal Log
[    7.587117] localhost systemd-fsck[364]: Filesystem is clean.
[    7.602174] localhost kernel: fsck.jfs (366) used greatest stack depth: 13680 bytes left
[    7.587305] localhost systemd[1]: Started File System Check on /dev/disk/by-uuid/a6bfa90a-f736-47f8-a5ec-1ee33d0568d0.
[    7.587440] localhost systemd[1]: Mounting /sysroot...
[    7.980821] localhost kernel: mount (369) used greatest stack depth: 13288 bytes left
[    7.952263] localhost systemd[1]: Mounted /sysroot.
[    7.953323] localhost systemd[1]: Starting Initrd Root File System.
[    7.954850] localhost systemd[1]: Reached target Initrd Root File System.
[    7.954982] localhost systemd[1]: Starting Reload Configuration from the Real Root...
[    7.958701] localhost systemd[1]: Reloading.
[    8.026745] localhost systemd[1]: Expecting device dev-extrootvg-usr.device...
[    8.034700] localhost systemd[1]: Started Reload Configuration from the Real Root.
[    8.035651] localhost systemd[1]: Started dracut mount hook.
[   10.935763] localhost kernel: systemd-udevd (242) used greatest stack depth: 12048 bytes left
[   10.937226] localhost kernel: systemd-udevd (244) used greatest stack depth: 11880 bytes left
[   98.036387] localhost systemd[1]: Job dev-extrootvg-usr.device/start timed out.
[   98.037777] localhost systemd[1]: Timed out waiting for device dev-extrootvg-usr.device.
[   98.039210] localhost systemd[1]: Dependency failed for File System Check on /dev/extrootvg/usr.
[   98.039350] localhost systemd[1]: Job systemd-fsck@dev-extrootvg-usr.service/start failed with result 'dependency'.
[   98.040623] localhost systemd[1]: Dependency failed for /sysroot/usr.
[   98.042017] localhost systemd[1]: Dependency failed for Initrd File Systems.
[   98.042151] localhost systemd[1]: Job initrd-fs.target/start failed with result 'dependency'.
[   98.042273] localhost systemd[1]: Triggering OnFailure= dependencies of initrd-fs.target.
[   98.042396] localhost systemd[1]: Job sysroot-usr.mount/start failed with result 'dependency'.
[   98.042514] localhost systemd[1]: Job dev-extrootvg-usr.device/start failed with result 'timeout'.
[   98.043562] localhost systemd[1]: Stopped dracut pre-pivot and cleanup hook.
[   98.044938] localhost systemd[1]: Stopped target Initrd Default Target.
[   98.045086] localhost systemd[1]: Starting Cleaning Up and Shutting Down Daemons...
[   98.046772] localhost systemd[1]: Stopping Basic System.
[   98.048535] localhost systemd[1]: Stopped target Basic System.
[   98.048671] localhost systemd[1]: Stopping System Initialization.
[   98.049826] localhost systemd[1]: Stopped target System Initialization.
[   98.049956] localhost systemd[1]: Starting Setup Virtual Console...
[   98.054348] localhost systemd[1]: Started Setup Virtual Console.
[   98.056110] localhost systemd[1]: Requested transaction contradicts existing jobs: Transaction is destructive.
[   98.056270] localhost systemctl[404]: Failed to start initrd-switch-root.target: Transaction is destructive.
[   98.056399] localhost systemd[1]: initrd-cleanup.service: main process exited, code=exited, status=4/NOPERMISSION
[   98.059229] localhost systemd[1]: Failed to start Cleaning Up and Shutting Down Daemons.
[   98.059364] localhost systemd[1]: Unit initrd-cleanup.service entered failed state.
[   98.059485] localhost systemd[1]: Triggering OnFailure= dependencies of initrd-cleanup.service.
[   98.059603] localhost systemd[1]: initrd-cleanup.service failed.
[   98.060924] localhost systemd[1]: Starting Emergency Shell...


You can see the vg is actually recognized somehow and it was the case before the dolvm option which didn't change anything in this output from my previous trial. There is something happening that prevent the /usr filesystem to be actually mounted.

BTW, I am using dracut to generate the initramfs image. I always did before with GRUB 0.97 and never had a problem with it. So, I kept using it.


ADDENDUM 2: Finally, what makes a difference is the kernel options rd.lvm.vg=myvg rd.lvm.lv=myvg/usr after I added them, the system finally booted. Conclusion, the grub2-mkimage script doesn't handle properly the LVM case.
_________________
Achille Talon Hop!
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Mon Jul 20, 2015 7:24 am    Post subject: Reply with quote

So you solved your issue right, didn't you? Please edit the topic of your first post and add [solved]

http://superuser.com/questions/697439/grub2-documentation-about-rd-lvm-rd-luks-and-rd-md-options
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum