So I installed debian in an usb, with the LUKS setup, I basically created 4 partitions:

sdb1: not encrypted, boot partition sdb2: encrypted, root partition sdb3: encrypted, swap partition sdb4: encrypted, home partition

During the debian installation, debian didn't ask me where to install grub, went ahead and install GRUB on sda, the main HDD of my pc.

So now I have this almost-full encrypted usb that boots only on the said pc. My goal was having an usb that can boot in any PC.

How can I fix this. In another place someone suggested simply to install grub from terminal inside my debian luks system. But it doesn't work. Grub gets installed without issues or error messages and my usb still doesn't boot Unless I use it in the PC where I installed.

I think that move would work for a simple setup, not for an encrypted one, despite I choose sdb1 to be the boot partition I don't get why debian at least didnt ask me where to install grub... it installed grub without asking me on sda. It seems so random to me. Im not a linux expert.

Any help is appreciated, thanks


So basically what you need to do is install the GRUB bootloader into the MBR of the USB drive. Right now, it's installed in the MBR of the main drive on the PC.

At this point, the easiest way to do that is:

  1. Boot Debian on the PC; the only one on which it's set up to boot
  2. Once logged in, make sure your /boot filesystem is mounted. If it's not, go ahead and mount it.
  3. Then, as root run: grub-install /dev/sdX, where X corresponds to the USB drive. This will install the bootloader into the MBR on the USB drive.

To clarify, the GRUB bootloader will be installed on the disk prior to the partition table, outside of your three LUKS containers; making it bootable.

You can read more about installing GRUB here. It so happens the Gentoo Linux documentation on the topic is quite exhaustive.

  • Sorry if I reply only now, is always me, I just lost access to my account. Anyway I tried the said solution, I get no errors when installing grub, however the issue remains, I think that since LUKS is involved there's something different that needs to be done here – texuhuku Jun 7 '17 at 17:38
  • @texuhuku if you've lost access to your account, please see unix.stackexchange.com/help/merging-accounts. – terdon Jun 7 '17 at 19:12
  • Hmm, it's unlikely having LUKS is the problem. You can confirm that by installing Debian on another USB drive using the same procedure, with the exclusion of LUKS. What happens in your setup, is that GRUB loads the kernel and the initrd from the unencrypted boot partition. Then, a script within the initrd calls upon cryptsetup to decrypt the other partitions. Being that the symptom is that the OS will only boot on that given PC, the most likely cause is that the GRUB bootloader being used is the one on sda, rather than sdb. This process is pre-LUKS. – Emmanuel Rosa Jun 7 '17 at 21:26

Your Answer

