Kali linux on LiveUSB with working persistent partition

Few days ago i wanted to make liveusb with kali linux (i had backtrack before). I used this guide to install kali, but i observed, that persistence partition does not work. There is partitions on my usb drive:
Kali - old partition table
When init script found persistent partition and tried to mount  their return error “mount: mounting /dev/sdaX on /root/lib/live/mount/persistence/sdaX failed: Device or resource busy”.
I think this happened because official guide suggest to write iso9660 image on usb drive, and init script think that it is cd drive and mount whole usb device, not a partition where iso placed. This i found in boot.log:

There you can see, that after kali boot, usb drive (sda) still mounted, and i can not mount second partition:
Kali1
After that whole usb drive is busy.  I attached boot.log to this post with enabled debug, may be it will help someone to fix that.

I decided to make bootable usb disk instead of flashing iso on it. For doing that i used extlinux and original kali iso file.
First i create 2 partitions on usb drive, one for kali and second for persistent files:

Kali2

Do not forget to set bootable flag on first partition and correct label for persistent paririon.
After that, install mbr from extlinux:

$ dd if=/usr/lib/extlinux/mbr.bin of=/dev/sda
0+1 records in
0+1 records out
440 bytes (440 B) copied, 0.00126658 s, 347 kB/s

Copy kali linux on first partition:

$ mkdir /mnt/sr0 /mnt/kali
$ mount /dev/sr0 /mnt/sr0/
mount: block device /dev/sr0 is write-protected, mounting read-only
$ mount /dev/sda1 /mnt/kali/
$ rsync -a /mnt/sr0/* /mnt/kali

Also i modify boot menu and add entry with persistence boot option at live.cfg:

label live-686-pae-persistence
menu label ^Live persistence (686-pae)
menu default
linux /live/vmlinuz
initrd /live/initrd.img
append boot=live noconfig=sudo username=root hostname=android-53f31a089339194f persistence

After that you need to rename isolinux.cfg to extlinux.conf and install extlinux:

$ cp /mnt/kali/isolinux/isolinux.cfg /mnt/kali/isolinux/extlinux.conf
$ extlinux --install /mnt/kali/isolinux/
/mnt/kali/isolinux/ is device /dev/sda1

Mount persistence partition and create config:

$ mkdir /mnt/persist
$ mount /dev/sda2 /mnt/persist/
$ echo "/ union" > /mnt/persist/persistence.conf

After that you can reboot and check, that persistent partition work.
Kali3

22 comments on “Kali linux on LiveUSB with working persistent partition

  • kaliuser says:

    root@kali:~# dd if=/usr/lib/extlinux/mbr.bin of=/dev/sdb1
    0+1 records in
    0+1 records out
    440 bytes (440 B) copied, 0.0156202 s, 28.2 kB/s
    root@kali:~# mkdir /mnt/sr0 /mnt/kali
    root@kali:~# mount /dev/sr0 /mnt/sr0/
    Error opening ‘/dev/sr0’: No medium found
    Failed to mount ‘/dev/sr0’: No medium found

    Reply
  • Tanjica says:

    I’ve made it from virtual box at windows 7, and everything looks Ok, but persistence is not working :-( I have multiple boot options (looks nice, but useless), and I’ve tried adding persistence (with tab, when booting), and USB Persistence, also does not work. Now checking friendship with google :-))))

    Reply
  • Nima says:

    Hi,

    I installed a live kali through the guide was in docs.kali.org and persistence partition works correctly.
    But I can only save my files in this partition and kali settings doesn’t save and after reboot all settings return to the default.
    Can you please help me about this?

    Thanks
    Nima

    Reply
    • Ivan says:

      Hello.
      I described the not standard way of installation, because when i tried to use method described at docs.kali.org it was not working, may be it work.
      If persistent partition is working correctly, then all changes that you will made will be saved.
      That about you talking, looks like just an another partition that you mount into kali.

      Reply
      • peter says:

        hi ivan
        i followed the steps in your tutorial with kali 2.0 live usb.
        everything worked fine however when i rebooted my changes were resetted to default settings.
        i have the same problems as nima and was wondering wether you had some troubleshooting advice.
        thank you

        Reply
        • Ivan says:

          Hello.
          Sorry for delay, did you tried to install new kali dist as described on project homepage?

          Reply
  • I wonder there are no far more questions on this … I’ve got the same or similar problem. First partition is recognized as CD, no partition is mountable, it always says “Could not display “/root/lib/live/mount/persistence/sdb2”, etc. Strangely this is with using the suggested persistence boot option. Without it I can mount and open everything just fine, but none of my settings are persistent …

    Thx for your alternative, but I’ll try out some more things first. ^^

    Reply
  • pippo says:

    thanks a lot..

    From Kali Live CD you have to install exlinux, right?

    apt-get install extlinux

    Reply
  • pippo says:

    Hi ivan,

    when you Copy kali linux on first partition in what Operative System are You ?

    Are You in the Kali Dvd live system or in another Linux system ?

    I am trying to operate usign the same Kali Dvd live system and i got this kind of error:

    according to mtab, /dev/sr0 is already mounted on /lib/live/mount/medium

    Coul You explain ?

    tks

    Reply
    • Ivan says:

      Hi.
      I made it when was booted in kali livecd, but it is not necessary.
      Check /lib/live/mount/medium if you will found there content of kali livecd, then you can run rsync -a lib/live/mount/medium/* /mnt/kali instead of rsync -a /mnt/sr0/* /mnt/kali

      Reply
  • pippo says:

    Hi Ivan,

    i have the same problem.

    I had to install extlinux and executed coerrectly the first command:

    dd if=/usr/lib/extlinux/mbr.bin of=/dev/sdd (sdd is my usb dongle).

    On the command mount /dev/sr0 /mnt/sr0/ i get an error: mount: mount point /mnt/sr0/ does not exist

    I am using the Kali DVD in order to install Kali in the USB dongle.

    Can You please help me?

    tks

    pippo

    mount /dev/sr0 /mnt/sr0/

    Reply
      • sr0 is a loopback which is not present in a distribution that is installed! At least that was my problem cuz I have kali already installed and decided to make a script to boot my microSD with persistence changes. I think if I’m not wrong that you made this tutorial within kali live CD/USB session, I’m I right??

        I mounted the Kali ISO with:
        mkdir /mnt/iso ; mount /path/to/iso /mnt/iso ; cp -rf /mnt/kali

        Hope this help and if I’m wrong please correct!

        Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>