0

I have a Kali Linux installation (VM) which I customized so much with custom bash & python scripts plus installing quite a few additional software,
I would like to know if it is possible to take this VM and turn it to a bootable media, say USB storage.
One way is to install Kali on a usb with persistence option to make the changes permanent, but it's just too much work!

"Please note, this is not the usual ISO-to-USB kind of thing, I'm looking for a way to make a bootable media from an already installed OS"

  • 1
    AFAIK that is not possible. But assuming you develop python scripts within installable packages you can use stdeb to make packages out of those and include them to update an ISO distribution. The bash-scripts and any non-packaged python scripts you could put into one .deb and add that as well. – Anthon Jan 27 '15 at 12:12
  • Thanks for your answer, but I think it should be possible. Nice suggestion anyway. – Sam Jan 27 '15 at 12:22
1

Yes, you can do it but it is a bit of a tedious process.

First prepare the USB with the partitions you need to match your VM. After that mount the USB's partition/s you've created and rsync (don't copy as I first posted since copying wont keep users and permissions) all files from your VM to the USB partition/s, avoid copying /dev /sys and /proc.

Once you've done that unmount the USB's partition/s and mount / in /mnt. After that mount with bind /dev, /sys and /proc:

mount --bind /dev /mnt/dev 
mount --bind /proc /mnt/proc 
mount --bind /sys /mnt/sys

Once you've done that, chroot to /mnt. In case /boot is a partition mount that partition now.

Execute blkid and identify your USBs UUID root partition, edit /etc/fstab and modify the UUID of root for the one in your USB (and all mount points if you have various partitions).

At this point you must update your grub so that a new /boot/grub/grub.cfg is generated. I don't know if updating grub from the chrooted will create the right grub.cfg, but you can edit it manually and replace UUID with the right one, and once you start from your USB update-grub from there.

OK you're almost done now, install grub in the USB and you should be ready.

grub-install /dev/your-usb-device-here

Make sure the root partition is set as bootable in your USB and try the USB.

I hope I haven't missed any step, but in case you have any problem let me know and I'll try to help.

  • Thanks. I'm gonna test this and return with an update on the matter! – Sam Jan 27 '15 at 12:22
  • I was going to test it now, but I forgot to ask, what system file should I format the storage to? FAT? NTFS? EXT4? – Sam Jan 28 '15 at 13:04
  • It depends, do you want to see the files from windows? FAT would be the standard, but it can be what ever you want if you don't forget to load that module from Grub. – YoMismo Jan 28 '15 at 14:02

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.