Non-interactive install of grub2 when installing from scratch












1















There is a very similar question here "How do I apt-get -y dist-upgrade without a grub config prompt?" about updating grub without the prompt using apt-get.



However I would like to to know how to install grub2 with apt-get on a brand new image. I am preparing virtual machine disk images starting with debootstrap and going from there.



I would like to install the grub2 software on an image - but not configure it or install it on the boot sector at all ; a later script takes care of configuration and installation proper.



How can I do this?










share|improve this question





























    1















    There is a very similar question here "How do I apt-get -y dist-upgrade without a grub config prompt?" about updating grub without the prompt using apt-get.



    However I would like to to know how to install grub2 with apt-get on a brand new image. I am preparing virtual machine disk images starting with debootstrap and going from there.



    I would like to install the grub2 software on an image - but not configure it or install it on the boot sector at all ; a later script takes care of configuration and installation proper.



    How can I do this?










    share|improve this question



























      1












      1








      1


      1






      There is a very similar question here "How do I apt-get -y dist-upgrade without a grub config prompt?" about updating grub without the prompt using apt-get.



      However I would like to to know how to install grub2 with apt-get on a brand new image. I am preparing virtual machine disk images starting with debootstrap and going from there.



      I would like to install the grub2 software on an image - but not configure it or install it on the boot sector at all ; a later script takes care of configuration and installation proper.



      How can I do this?










      share|improve this question
















      There is a very similar question here "How do I apt-get -y dist-upgrade without a grub config prompt?" about updating grub without the prompt using apt-get.



      However I would like to to know how to install grub2 with apt-get on a brand new image. I am preparing virtual machine disk images starting with debootstrap and going from there.



      I would like to install the grub2 software on an image - but not configure it or install it on the boot sector at all ; a later script takes care of configuration and installation proper.



      How can I do this?







      grub2 system-installation scripts debootstrap






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 13 '17 at 12:24









      Community

      1




      1










      asked Oct 2 '14 at 10:25









      nwalthamnwaltham

      346512




      346512






















          3 Answers
          3






          active

          oldest

          votes


















          1














          Answering my own question - I have found I can do it like this:



          echo "grub-pc grub-pc/install_devices_empty   boolean true" | debconf-set-selections
          DEBIAN_FRONTEND=text apt-get -y install grub2





          share|improve this answer































            0














            My case may be a little different, but I had interactive questions from the installer when upgrading my freshly created VMs
            This ruined the automation, and finding how to get rid of it was quite hard, so here is what I did around my upgrade :



            sed -i "s/# conf_force_conffold=YES/conf_force_conffold=YES/g" /etc/ucf.conf
            apt-get -y upgrade
            sed -i "s/conf_force_conffold=YES/#conf_force_conffold=YES/g" /etc/ucf.conf


            It removes the interactivity ONLY for the time of my upgrade, which in that case, is produced by ucf, and not debconf.

            By the way, you may also edit files manually if you prefer, but I tend to convert everything to copy/pastable, since it makes life waaaaaaaaay easier.



            I use Ubuntu 16.04






            share|improve this answer































              0














              Your question may be almost two years old, but I believe I have a better answer that I should share.



              Don't install grub2 or grub-pc. Install grub-pc-bin and grub2-common.



              grub-install and update-grub are provided by grub2-common, but all the debconf and ucf stuff is provided by grub-pc.



              But be warned that grub-pc is a recommended package for most (all?) kernel image packages, so you have to install the kernel image and any kernel image upgrades with the --no-install-recommends option.



              Notice the use of the --assume-yes option as well, so apt-get can run noninteractively.



              Install:



              sudo apt-get update
              sudo apt-get install --assume-yes --no-install-recommends linux-image-virtual grub-pc-bin grub2-common
              sudo grub-install /dev/sdX
              sudo update-grub


              Upgrade:



              sudo apt-get update
              sudo apt-get dist-upgrade --assume-yes --no-install-recommends


              Hope this helps!!






              share|improve this answer

























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "89"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f531364%2fnon-interactive-install-of-grub2-when-installing-from-scratch%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                1














                Answering my own question - I have found I can do it like this:



                echo "grub-pc grub-pc/install_devices_empty   boolean true" | debconf-set-selections
                DEBIAN_FRONTEND=text apt-get -y install grub2





                share|improve this answer




























                  1














                  Answering my own question - I have found I can do it like this:



                  echo "grub-pc grub-pc/install_devices_empty   boolean true" | debconf-set-selections
                  DEBIAN_FRONTEND=text apt-get -y install grub2





                  share|improve this answer


























                    1












                    1








                    1







                    Answering my own question - I have found I can do it like this:



                    echo "grub-pc grub-pc/install_devices_empty   boolean true" | debconf-set-selections
                    DEBIAN_FRONTEND=text apt-get -y install grub2





                    share|improve this answer













                    Answering my own question - I have found I can do it like this:



                    echo "grub-pc grub-pc/install_devices_empty   boolean true" | debconf-set-selections
                    DEBIAN_FRONTEND=text apt-get -y install grub2






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Oct 3 '14 at 10:39









                    nwalthamnwaltham

                    346512




                    346512

























                        0














                        My case may be a little different, but I had interactive questions from the installer when upgrading my freshly created VMs
                        This ruined the automation, and finding how to get rid of it was quite hard, so here is what I did around my upgrade :



                        sed -i "s/# conf_force_conffold=YES/conf_force_conffold=YES/g" /etc/ucf.conf
                        apt-get -y upgrade
                        sed -i "s/conf_force_conffold=YES/#conf_force_conffold=YES/g" /etc/ucf.conf


                        It removes the interactivity ONLY for the time of my upgrade, which in that case, is produced by ucf, and not debconf.

                        By the way, you may also edit files manually if you prefer, but I tend to convert everything to copy/pastable, since it makes life waaaaaaaaay easier.



                        I use Ubuntu 16.04






                        share|improve this answer




























                          0














                          My case may be a little different, but I had interactive questions from the installer when upgrading my freshly created VMs
                          This ruined the automation, and finding how to get rid of it was quite hard, so here is what I did around my upgrade :



                          sed -i "s/# conf_force_conffold=YES/conf_force_conffold=YES/g" /etc/ucf.conf
                          apt-get -y upgrade
                          sed -i "s/conf_force_conffold=YES/#conf_force_conffold=YES/g" /etc/ucf.conf


                          It removes the interactivity ONLY for the time of my upgrade, which in that case, is produced by ucf, and not debconf.

                          By the way, you may also edit files manually if you prefer, but I tend to convert everything to copy/pastable, since it makes life waaaaaaaaay easier.



                          I use Ubuntu 16.04






                          share|improve this answer


























                            0












                            0








                            0







                            My case may be a little different, but I had interactive questions from the installer when upgrading my freshly created VMs
                            This ruined the automation, and finding how to get rid of it was quite hard, so here is what I did around my upgrade :



                            sed -i "s/# conf_force_conffold=YES/conf_force_conffold=YES/g" /etc/ucf.conf
                            apt-get -y upgrade
                            sed -i "s/conf_force_conffold=YES/#conf_force_conffold=YES/g" /etc/ucf.conf


                            It removes the interactivity ONLY for the time of my upgrade, which in that case, is produced by ucf, and not debconf.

                            By the way, you may also edit files manually if you prefer, but I tend to convert everything to copy/pastable, since it makes life waaaaaaaaay easier.



                            I use Ubuntu 16.04






                            share|improve this answer













                            My case may be a little different, but I had interactive questions from the installer when upgrading my freshly created VMs
                            This ruined the automation, and finding how to get rid of it was quite hard, so here is what I did around my upgrade :



                            sed -i "s/# conf_force_conffold=YES/conf_force_conffold=YES/g" /etc/ucf.conf
                            apt-get -y upgrade
                            sed -i "s/conf_force_conffold=YES/#conf_force_conffold=YES/g" /etc/ucf.conf


                            It removes the interactivity ONLY for the time of my upgrade, which in that case, is produced by ucf, and not debconf.

                            By the way, you may also edit files manually if you prefer, but I tend to convert everything to copy/pastable, since it makes life waaaaaaaaay easier.



                            I use Ubuntu 16.04







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered May 16 '17 at 15:27









                            BalmipourBalmipour

                            1011




                            1011























                                0














                                Your question may be almost two years old, but I believe I have a better answer that I should share.



                                Don't install grub2 or grub-pc. Install grub-pc-bin and grub2-common.



                                grub-install and update-grub are provided by grub2-common, but all the debconf and ucf stuff is provided by grub-pc.



                                But be warned that grub-pc is a recommended package for most (all?) kernel image packages, so you have to install the kernel image and any kernel image upgrades with the --no-install-recommends option.



                                Notice the use of the --assume-yes option as well, so apt-get can run noninteractively.



                                Install:



                                sudo apt-get update
                                sudo apt-get install --assume-yes --no-install-recommends linux-image-virtual grub-pc-bin grub2-common
                                sudo grub-install /dev/sdX
                                sudo update-grub


                                Upgrade:



                                sudo apt-get update
                                sudo apt-get dist-upgrade --assume-yes --no-install-recommends


                                Hope this helps!!






                                share|improve this answer






























                                  0














                                  Your question may be almost two years old, but I believe I have a better answer that I should share.



                                  Don't install grub2 or grub-pc. Install grub-pc-bin and grub2-common.



                                  grub-install and update-grub are provided by grub2-common, but all the debconf and ucf stuff is provided by grub-pc.



                                  But be warned that grub-pc is a recommended package for most (all?) kernel image packages, so you have to install the kernel image and any kernel image upgrades with the --no-install-recommends option.



                                  Notice the use of the --assume-yes option as well, so apt-get can run noninteractively.



                                  Install:



                                  sudo apt-get update
                                  sudo apt-get install --assume-yes --no-install-recommends linux-image-virtual grub-pc-bin grub2-common
                                  sudo grub-install /dev/sdX
                                  sudo update-grub


                                  Upgrade:



                                  sudo apt-get update
                                  sudo apt-get dist-upgrade --assume-yes --no-install-recommends


                                  Hope this helps!!






                                  share|improve this answer




























                                    0












                                    0








                                    0







                                    Your question may be almost two years old, but I believe I have a better answer that I should share.



                                    Don't install grub2 or grub-pc. Install grub-pc-bin and grub2-common.



                                    grub-install and update-grub are provided by grub2-common, but all the debconf and ucf stuff is provided by grub-pc.



                                    But be warned that grub-pc is a recommended package for most (all?) kernel image packages, so you have to install the kernel image and any kernel image upgrades with the --no-install-recommends option.



                                    Notice the use of the --assume-yes option as well, so apt-get can run noninteractively.



                                    Install:



                                    sudo apt-get update
                                    sudo apt-get install --assume-yes --no-install-recommends linux-image-virtual grub-pc-bin grub2-common
                                    sudo grub-install /dev/sdX
                                    sudo update-grub


                                    Upgrade:



                                    sudo apt-get update
                                    sudo apt-get dist-upgrade --assume-yes --no-install-recommends


                                    Hope this helps!!






                                    share|improve this answer















                                    Your question may be almost two years old, but I believe I have a better answer that I should share.



                                    Don't install grub2 or grub-pc. Install grub-pc-bin and grub2-common.



                                    grub-install and update-grub are provided by grub2-common, but all the debconf and ucf stuff is provided by grub-pc.



                                    But be warned that grub-pc is a recommended package for most (all?) kernel image packages, so you have to install the kernel image and any kernel image upgrades with the --no-install-recommends option.



                                    Notice the use of the --assume-yes option as well, so apt-get can run noninteractively.



                                    Install:



                                    sudo apt-get update
                                    sudo apt-get install --assume-yes --no-install-recommends linux-image-virtual grub-pc-bin grub2-common
                                    sudo grub-install /dev/sdX
                                    sudo update-grub


                                    Upgrade:



                                    sudo apt-get update
                                    sudo apt-get dist-upgrade --assume-yes --no-install-recommends


                                    Hope this helps!!







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Jan 5 at 18:50

























                                    answered Jan 5 at 17:38









                                    Jared BrandtJared Brandt

                                    235




                                    235






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Ask Ubuntu!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f531364%2fnon-interactive-install-of-grub2-when-installing-from-scratch%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                        Mangá

                                         ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕