2

I would like to chroot into a Live USB Linux distro, if such thing is possible. I don't know if there is a generic method, so I will detail my specific test.
I am testing Kali Linux v1.0.5 Live USB created from Windows using "Universal USB Installer".
This is the root of the pendrive:

23/12/2013  01:12 am    <DIR>          uui
05/09/2013  09:50 am    <DIR>          .disk
05/09/2013  09:51 am                25 autorun.inf
05/09/2013  09:47 am    <DIR>          dists
05/09/2013  09:46 am    <DIR>          firmware
05/09/2013  09:51 am           159.629 g2ldr
05/09/2013  09:51 am             8.192 g2ldr.mbr
05/09/2013  09:50 am    <DIR>          install
05/09/2013  09:51 am    <DIR>          isolinux
05/09/2013  09:49 am    <DIR>          live
05/09/2013  09:52 am            42.803 md5sum.txt
05/09/2013  09:47 am    <DIR>          pool
05/09/2013  09:51 am           366.350 setup.exe
05/09/2013  09:50 am    <DIR>          tools
05/09/2013  09:51 am               223 win32-loader.ini
11/01/2013  05:55 pm            49.070 Uni-USB-Installer-Copying.txt
24/11/2013  10:22 pm            18.233 Uni-USB-Installer-Readme.txt
04/04/2012  08:42 pm            18.092 license.txt
01/01/2014  09:23 pm    <DIR>          Instalac
               9 archivos        662.617 bytes
              10 dirs   1.486.944.256 bytes libres

...and, as long as I suppose this is the important part:

 Directorio de k:\live

23/12/2013  01:12 am    <DIR>          .
23/12/2013  01:12 am    <DIR>          ..
05/09/2013  09:46 am            60.319 filesystem.packages
05/09/2013  09:46 am               159 filesystem.packages-remove
05/09/2013  09:45 am     2.410.737.664 filesystem.squashfs
05/09/2013  09:46 am        17.296.271 initrd.img
05/09/2013  09:47 am           176.764 memtest
05/09/2013  09:46 am         2.250.960 vmlinuz
               6 archivos  2.430.522.137 bytes
               2 dirs   1.486.944.256 bytes libres

I think that the filesystem.squashfs file is the important part here, but I am not sure.
Thanks for any help.

  • 1
    Have a look at the file. If your system has squashfs support loaded (grep squashfs /proc/filesystems) then mount the file: losetup /dev/loop0 .../filesystem.squashfs; mount -t squashfs /dev/loop0 /mnt/tmp – Hauke Laging Mar 23 '14 at 22:54
  • @HaukeLaging, I have squashfs in /proc/filesystems, but keeping your instructions I get /media/temporal2 seems to be mounted read-only (in fact it is). – Sopalajo de Arrierez Mar 23 '14 at 23:15
  • And now you wonder why that is? You can mount the squashfs file but not read-write? – Hauke Laging Mar 23 '14 at 23:22
  • Yes, @HaukeLaging: I can mount it an cd into any directory, but not write (mkdir, for example). I have rebooted and done mount -o remount,rw /media/temporal2 with same results. – Sopalajo de Arrierez Mar 23 '14 at 23:27
  • If you want rw you unsquashfs file.sfs ./ ; chroot ./. If ro is fine mount file.sfs ./ ; chroot ./ – mikeserv Mar 24 '14 at 1:01
2

After some research, it seems that SquashFS is a read-only filesystem, and writing is not possible into it, so, even when you could chroot into it by installing squashfs support, the only way to change the contents is something like these instructions resumed to:

  1. Mount the SquashFS and extract the contents to a loop device or directory.
  2. Edit what should be needed (as chrooting is possible now) in that loop device or directory.
  3. Recreate a new SquashFS from the loop device.

As for today, it seems there is nothing more easy.

EDIT: it seems these other instructions are more compact.
EDIT2: no need for a loop device on step 1. You can just chroot into the directory of extraction.

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.