-2

I want to install Kali Linux on a 64 GB USB drive and want to take it just anywhere and plug it in any PC and have my setup up and running. IOW I just want a HDD like complete Kali Linux portable installation on a USB.

I don't want Live boot or persistence or anything, I clearly want to install it on that USB just like we normally install Kali Linux on HDDs.

I would like to give some information about my internal HDD -

root@Kali:~# fdisk -l
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: ST500DM009-2F110
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 0BBC9B99-EE7E-11E8-8BD6-843C86F9DFC6
Device         Start       End Sectors     Size Type
/dev/sda1       2048   1126399 1124352     549M Microsoft basic data
/dev/sda2    1126400 210561023 209434624  99.9G Microsoft basic data
/dev/sda3  210561024 210765823 204800      100M EFI System
/dev/sda4  210765824 315623423 104857600    50G Linux filesystem
/dev/sda5  315623424 328206335 12582912      6G Linux swap
/dev/sda6  328206336 537921535 209715200   100G Linux filesystem
/dev/sda7  537921536 976773134 438851599 209.3G Microsoft basic data

Disk /dev/sdb: 57.9 GiB, 62109253632 bytes, 121307136 sectors
Disk model: Ultra          
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: BC1A35EC-FF80-4CCB-BD61-30F7FF3CDA4A
Device        Start End       Sectors    Size  Type
/dev/sdb1      2048 206847    204800     100M  EFI System
/dev/sdb2    206848 68567039  68360192   32.6G Linux filesystem
/dev/sdb3  68567040 76380159  7813120    3.7G  Linux swap
/dev/sdb4  76380160 121305087 44924928   21.4G Linux filesystem

The /dev/sda is my internal HDD with Windows 10 + Manjaro installed on it in dual boot in UEFI mode.

The /dev/sdb is the target 64 GB USB drive on which I want to install Kali Linux. What you are seeing here in /dev/sdb is the current installation of my Kali Linux (my 3rd try).

I downloaded the Kali Linux KDE 2019 ISO from the official Kali Linux Downloads page, used Rufus to make a Live boot in DD mode in another spare 16 GB USB. I deleted all the partitions on the target USB and made it unallocated. Booted from the Live USB, selected Graphical installer, went through all the process until Partitioning.

I chose Manual partitioning method, then partitioned my target USB (shown as /dev/sdc in the installer) as follows -

SCSIl (0,0,0) (sdc) - 62.1 GB
>                       1.0 MB              FREE SPACE
>   #1   /dev/sdc1    104.9 MB    B    K    ESP         EFI system partition
>   #2   /dev/sdc2     35.0 GB         f    ext4        /
>   #3   /dev/sdc3      4.0 GB         f    swap        swap
>   #4   /dev/sdc4     23.1 GB         f    ext4        /home
>                       1.0 MB              FREE SPACE

I checked everything especially the bootable flag "on" in EFI partition. After making sure everything was right I proceeded with the installation. One unusual thing I did notice after clicking Continue was I only created 4 partitions on my /dev/sdc, but there were 5 partitions listed under "partitions to be formatted", I examined and found that along with the 4 newly created partitions on /dev/sdc , the swap partition on /dev/sda was also listed to be formatted there. I thought that is strange as I didn't even touch /dev/sda while partitioning, but I ignored it and clicked Continue. The system got installed successfully, finished the installation and rebooted. Also took out the Live USB stick.

So far so good.

Got the grub screen, selected Kali and boom! The first thing I encountered was a black screen with (initramfs) as the grub failed to find root partition on /dev/sdc (NOTE: While installation the target USB was /dev/sdc , but after removing Live USB stick it became /dev/sdb ). So I went back to grub by rebooting and pressed "e" and changed the device path for root from /dev/sdc2 to /dev/sdb2. Pressed F10 and that booted me into my Kali Linux desktop, YAY!

Well, not so yay. I just fired up GParted to check whether all my partitions are intact, and to my surprise I saw that instead of the EFI partition that I created on /dev/sdb, the EFI partition of /dev/sda was mounted, the root, swap & home partitions on /dev/sdb were mounted and the swap partition on /dev/sda was mounted too! WTF!

Also the EFI partition on /dev/sdb which was expected to be mounted at /boot/efi was not mounted!

This just got my head spinning, I tried the above step one more time but got the same result. Then I read somewhere that the EFI partition must already be present on the target USB drive, so I tried that too but no result.

So I shutdown the system and plugged the USB in a different laptop to see whether it works, but as soon as I fire up the boot menu there is no option to boot from USB. I tried disabling Legacy support & Secure Boot. Also tried to Add a boot option but there is no EFI file available in the file system of the USB. The EFI file for Kali is available with Manjaro and Windows in the file system of my internal HDD which clearly shows that the EFI files got installed on the EFI partition of /dev/sda.

I need to find out what's happening here, what's going wrong, how can I fix this, and how can I fulfill my aim mentioned above.

0

First of all, boot your Linux system and insert your USB with Kali, mount all partitions of the USB from the terminal, issue blkid and keep all the UUID's of the partitions on the USB drive. Open /etc/sftab on the / of the USB and ensure all partitions mentioned therein are mounted via UUID, that way you do not confuse the system with partitions to load. I would add discard,noatime,commit=600 and please, remove the swap partition from the USB drive, swapping on that is .

Example:

UUID=739cbe4a-82c1-46cb-8bb1-dbce3259d1f8 / ext4 discard,noatime,commit=600,defaults 0 2

You might have to edit the grub config as well to use UUID to find the root.

When you boot the computer, find the F key for selecting the boot device (I have seen F10 and F12, it might be another), you should see two entries for the USB (if legacy boot is enabled on the computer), select your US drive and, if there are two you might select the wrong one (legacy boot) so repeat with the other, the system "should" boot.

  • My system is just booting on "my" PC. The problem is if I insert the USB in any other laptop or desktop then there is no option for booting from USB no matter what I do. In my post I have written that I tried to boot from USB on my dad's laptop and there was just no option for booting from USB, I tried all sorts of things from turning off legacy support and secure boot to adding boot options but none of it works. Please can you tell me what's going wrong here – Super User May 18 at 11:42
  • Have you installed grub2 on the USB drive ? – thecarpy May 18 at 17:39
  • I installed the grub-efi-amd64 and grub-efi packages, is there something more I need to do? – Super User May 18 at 18:07
  • Well, did you install grub to the USB drive during installation ? If yes, then you have to configure that to point to your Linux install. You can search for the root partition using its UUID in grub, then it "should" just work, regardless ... – thecarpy May 18 at 18:16
  • Yes I installed the grub on my USB drive......but at least I should get the GRUB window after boot......or I should at least see an option to boot from the USB at the BIOS screen. I am getting neither of it. What else should I do? – Super User May 20 at 8:30
0

I finally solved this issue!

Using this wiki - https://wiki.debian.org/GrubEFIReinstall

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.