I have several computers with 2 drives (one is ssd, the other is hdd). I've created preseed file for automated deployment that works fine except for the part with partitioning. For now it is done manually but even in this case grub does not work during next boot.

The point is when I boot from usb flash drive, the flash drive itself becomes sda device during the installation process so I put grub to SDB's MBR(which is SSD drive). But after the installation is finished and USB stick is removed SSD disk becomes sda and grub configuration does not work, so I have to manually edit grub config to be able to boot from sda, then boot into the system, change permanent grub configuration file, update grub in order to make machine bootable next time. What is the way to deal with this kind of issue?

How to make preseed:

  1. Put everything on SSD (it is main drive), auto partition it without creating swap volume, put grub into it.
  2. Format HDD as ntfs and mount it.
  3. Everything should work after the reboot without manual tweaking the grub config.
  • I am trying at the moment to do the stuff using the d-i preseed/late_command string \ in-target sed -i 's/root\=\/dev\/sdb1/root\=\/dev\/sda1/g' /boot/grub/grub.cfg;\ in-target update-grub; but this command fails during installation – Artur Korobeynyk Apr 20 '18 at 9:29
  • I've also tried: d-i preseed/late_command string sed -i 's/root\=\/dev\/sdb1/root\=\/dev\/sda1/g' /target/boot/grub/grub.cfg; in-target bash -c 'update-grub'; Does not work either – Artur Korobeynyk Apr 20 '18 at 13:44
  • Mounting /dev/sda1 in initramfs and checking the files shows that all those files were not updated. I tried also editing /etc/default/grub with in-target sed -i 's#^\(GRUB_CMDLINE_LINUX_DEFAULT="quiet\)"$#\1 root=/dev/sda1"#' /etc/default/grub – Artur Korobeynyk Apr 23 '18 at 11:23

The solution is actually not to use the last update-grub, as it restores configuration to the one that is currently in use during installation.

So my preseed step is:

d-i preseed/late_command string \
in-target sed -i 's#^\(GRUB_CMDLINE_LINUX_DEFAULT="quiet\)"$#\1 root=/dev/sda1"#' /etc/default/grub \
in-target grub-mkconfig -o /boot/grub/grub.cfg ; \
in-target sed -i 's/root\=\/dev\/sdb1/root\=\/dev\/sda1/g' /boot/grub/grub.cfg ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.