[opensuse] dracut --kernel-cmdline option not effective?
Hello: I would like to make an initrd image in openSUSE Leap 15.1 that has root=LABEL=... and resume=LABEL=... kernel command line options instead of root=UUID= and resume=UUID= . When I run mkinitrd it runs as: # mkinitrd Creating initrd: /boot/initrd-4.12.14-lp151.28.13-default dracut: Executing: /usr/bin/dracut --logfile /var/log/YaST2/mkinitrd.log --force /boot/initrd-4.12.14-lp151.28.13-default 4.12.14-lp151.28.13-default ... dracut: *** Store current command line parameters *** dracut: Stored kernel commandline: dracut: resume=UUID=ca1f9a2d-468f-4718-b993-d7041556be8c dracut: root=UUID=c6a2aa57-1ff2-4ebd-a1fb-e56cf4b3a4b9 rootfstype=ext4 rootflags=rw,relatime,data=ordered dracut: *** Creating image file '/boot/initrd-4.12.14-lp151.28.13-default' *** dracut: *** Creating initramfs image file '/boot/initrd-4.12.14-lp151.28.13-default' done *** According to dracut man page I can customize kernel command line options with --kernel-cmdline option to dracut. Based on the above I ran dracut as: # /usr/bin/dracut --kernel-cmdline "root=LABEL=L151-KDE3-ext resume=LABEL=swap-OSL" --logfile /var/log/YaST2/mkinitrd.log --force /boot/initrd-4.12.14-lp151.28.13-default 4.12.14-lp151.28.13-default dracut: Executing: /usr/bin/dracut --kernel-cmdline "root=LABEL=L151-KDE3-ext resume=LABEL=swap-OSL" --logfile /var/log/YaST2/mkinitrd.log --force /boot/initrd-4.12.14-lp151.28.13-default 4.12.14-lp151.28.13-default ... dracut: *** Store current command line parameters *** dracut: Stored kernel commandline: dracut: root=LABEL=L151-KDE3-ext resume=LABEL=swap-OSL dracut: resume=UUID=ca1f9a2d-468f-4718-b993-d7041556be8c dracut: root=UUID=c6a2aa57-1ff2-4ebd-a1fb-e56cf4b3a4b9 rootfstype=ext4 rootflags=rw,relatime,data=ordered dracut: *** Creating image file '/boot/initrd-4.12.14-lp151.28.13-default' *** dracut: *** Creating initramfs image file '/boot/initrd-4.12.14-lp151.28.13-default' done *** It seems that dracut recognizes and applies --kernel-cmdline option values but then overwrites them by the system default values, at least that is how I interpret dracut output messages. What do I do wrong and how could I set only root=LABEL=L151-KDE3-ext and resume=LABEL=swap-OSL kernel command line options in the initrd image? Thanks, Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
23.11.2019 2:21, Istvan Gabor пишет:
Hello:
I would like to make an initrd image in openSUSE Leap 15.1 that has root=LABEL=... and resume=LABEL=... kernel command line options instead of root=UUID= and resume=UUID= .
When I run mkinitrd it runs as:
# mkinitrd Creating initrd: /boot/initrd-4.12.14-lp151.28.13-default dracut: Executing: /usr/bin/dracut --logfile /var/log/YaST2/mkinitrd.log --force /boot/initrd-4.12.14-lp151.28.13-default 4.12.14-lp151.28.13-default ... dracut: *** Store current command line parameters *** dracut: Stored kernel commandline: dracut: resume=UUID=ca1f9a2d-468f-4718-b993-d7041556be8c dracut: root=UUID=c6a2aa57-1ff2-4ebd-a1fb-e56cf4b3a4b9 rootfstype=ext4 rootflags=rw,relatime,data=ordered dracut: *** Creating image file '/boot/initrd-4.12.14-lp151.28.13-default' *** dracut: *** Creating initramfs image file '/boot/initrd-4.12.14-lp151.28.13-default' done ***
According to dracut man page I can customize kernel command line options with --kernel-cmdline option to dracut.
Based on the above I ran dracut as:
# /usr/bin/dracut --kernel-cmdline "root=LABEL=L151-KDE3-ext resume=LABEL=swap-OSL" --logfile /var/log/YaST2/mkinitrd.log --force /boot/initrd-4.12.14-lp151.28.13-default 4.12.14-lp151.28.13-default dracut: Executing: /usr/bin/dracut --kernel-cmdline "root=LABEL=L151-KDE3-ext resume=LABEL=swap-OSL" --logfile /var/log/YaST2/mkinitrd.log --force /boot/initrd-4.12.14-lp151.28.13-default 4.12.14-lp151.28.13-default ... dracut: *** Store current command line parameters *** dracut: Stored kernel commandline: dracut: root=LABEL=L151-KDE3-ext resume=LABEL=swap-OSL dracut: resume=UUID=ca1f9a2d-468f-4718-b993-d7041556be8c dracut: root=UUID=c6a2aa57-1ff2-4ebd-a1fb-e56cf4b3a4b9 rootfstype=ext4 rootflags=rw,relatime,data=ordered dracut: *** Creating image file '/boot/initrd-4.12.14-lp151.28.13-default' *** dracut: *** Creating initramfs image file '/boot/initrd-4.12.14-lp151.28.13-default' done ***
It seems that dracut recognizes and applies --kernel-cmdline option values but then overwrites them by the system default values, at least that is how I interpret dracut output messages.
dracut does not overwrite anything because it does not interpret content of --kernel-cmdline option at all - it simply stores it verbatim. Another cmdline options come from dracut module that is responsible for root block device preparation, and this module is not aware that you tread on its territory.
What do I do wrong and how could I set only root=LABEL=L151-KDE3-ext and resume=LABEL=swap-OSL kernel command line options in the initrd image?
If you insist you must store them in initrd (as opposed to specifying on kernel command line) you could use --no-hostonly-cmdline which will skip storing auto-generated kernel command line. But keep in mind, this applies to *all* dracut modules. It will also no more add rootfstype & Co, so it is up to you to add *complete* correct kernel command line, not just the options you want to change. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Andrei, thanks for your reply. I am a little bit confused. Maybe I don't clearly understand how booting from/with initrd occurs. Maybe the best if I explain what I would like to achieve. I want to set up an openSUSE Leap 15.1 system with all the programs I need installed and configured. Then copy this system exactly as is onto other disks (HD or SSD) which I put in other computers. Then those copied system should boot without any "could not find device" error. For system copy I want to use cp or rsync, not dd, that is the file system UUIDS will not be copied. I thought if I add LABELs to the file sytems and refer to the file systems at every necessary place (grub.cfg, fstab etc.) by these labels, the above would be feasible. I replaced all UUID= to LABEL= in grub.cfg and fstab. I am afraid if I leave root=UUID= and resume=UUID= in the initrd, the copied system will not boot and will give device not found error. On Sat, 23 Nov 2019 10:22:13 +0300, Andrei Borzenkov wrote:
23.11.2019 2:21, Istvan Gabor пишет:
Hello:
LONG SNIP
dracut does not overwrite anything because it does not interpret content of --kernel-cmdline option at all - it simply stores it verbatim.
OK, this is clear.
Another cmdline options come from dracut module that is responsible for root block device preparation, and this module is not aware that you tread on its territory.
dracut manual says that dracut command line options overwrite dracut configuration options in /etc/dracut.conf, /etc/dracut.conf.d/*.conf etc. It seems it still applies options from modules.
What do I do wrong and how could I set only root=LABEL=L151-KDE3-ext and resume=LABEL=swap-OSL kernel command line options in the initrd image?
If you insist you must store them in initrd (as opposed to specifying on kernel command line)
I don't understand this. By "specifying on kernel command line" do you mean "linux ... root= ... resume=" line in grub.cfg? I though I have to set these both in grub.cfg and in initrd for correct booting.
you could use --no-hostonly-cmdline which will skip storing auto-generated kernel command line. But keep in mind, this applies to *all* dracut modules. It will also no more add rootfstype & Co, so it is up to you to add *complete* correct kernel command line, not just the options you want to change.
I would not like to do this. Is there other way to disable auto-generated kernel command line? Thanks, Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
23.11.2019 15:10, Istvan Gabor пишет:
Another cmdline options come from dracut module that is responsible for root block device preparation, and this module is not aware that you tread on its territory.
dracut manual says that dracut command line options overwrite dracut configuration options in /etc/dracut.conf, /etc/dracut.conf.d/*.conf etc. It seems it still applies options from modules.
You confuse dracut options and kernel options.
What do I do wrong and how could I set only root=LABEL=L151-KDE3-ext and resume=LABEL=swap-OSL kernel command line options in the initrd image?
If you insist you must store them in initrd (as opposed to specifying on kernel command line)
I don't understand this. By "specifying on kernel command line" do you mean "linux ... root= ... resume=" line in grub.cfg?
Yes.
I though I have to set these both in grub.cfg and in initrd for correct booting.
No. Stored cmdline is just fallback (or default if you will), actual kernel command line always takes precedence. If it does not, file a bug.
you could use --no-hostonly-cmdline which will skip storing auto-generated kernel command line. But keep in mind, this applies to *all* dracut modules. It will also no more add rootfstype & Co, so it is up to you to add *complete* correct kernel command line, not just the options you want to change.
I would not like to do this. Is there other way to disable auto-generated kernel command line?
I was about to suggest several ways when I discovered that you can configure dracut to use LABEL= instead of UUID=. See man dracut.conf, search for persistent_policy, set persistent_policy=by-label. But again - this is global, so any other dracut module that works with block devices will be using LABEL. So the simplest way to override only root= and resume= is really to use kernel command line. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Sat, 23 Nov 2019 13:10:25 +0100, Istvan Gabor wrote:
Andrei, thanks for your reply.
I am a little bit confused. Maybe I don't clearly understand how booting from/with initrd occurs. Maybe the best if I explain what I would like to achieve.
I want to set up an openSUSE Leap 15.1 system with all the programs I need installed and configured. Then copy this system exactly as is onto other disks (HD or SSD) which I put in other computers. Then those copied system should boot without any "could not find device" error. For system copy I want to use cp or rsync, not dd, that is the file system UUIDS will not be copied. I thought if I add LABELs to the file sytems and refer to the file systems at every necessary place (grub.cfg, fstab etc.) by these labels, the above would be feasible. I replaced all UUID= to LABEL= in grub.cfg and fstab. I am afraid if I leave root=UUID= and resume=UUID= in the initrd, the copied system will not boot and will give device not found error.
I read again dracut manual. I guess if I want to achieve the above probably is better to make an initrd with hostonly option disabled (-N option). On my system this generates a 47 MB initrd image vs the default (hostonly) 8.7 MB image. I also played a little bit with dracut trying the kernel-cmdline and no-hostonly-cmdline options and looking in the created initrd images (in all cases openSUSE default hostonly mode is enabled). When hostonly mode is enabled in initrd image these files are created: etc/cmdline.d/95resume.conf: etc/cmdline.d/95root-dev.conf with contents resume=UUID=ca1f9a2d-468f-4718-b993-d7041556be8c and root=UUID=c6a2aa57-1ff2-4ebd-a1fb-e56cf4b3a4b9 rootfstype=ext4 rootflags=rw,relatime,data=ordered When --no-hostonly-cmdline option is used, the above two files are not created. When --kernel-cmdline "parameter" is used an etc/cmdline.d/01-default.conf file is created with the specified parameter. So when I use both --no-hostonly-cmdline and --kernel-cmdline "parameter" then only etc/cmdline.d/01-default.conf is createdwith the specified parameter in the initrd image. I guess this is what I need if I want to have only my specified kernel command line in initrd. Thanks again, Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (2)
-
Andrei Borzenkov
-
Istvan Gabor