2015-08-02

Slitaz -- Loop install


Loop install

 
If you want to install SliTaz on a disk (not a frugal install), and you don't want to create a partition for SliTaz, but you have enough room in a feature-poor filesystem (FAT32 or NTFS)…
… create a loop file and install SliTaz into it!
The problem is: what size? 200MB should be the minimum. Imagine, you could like it and install many more packages!

Loopfile creation

You can create the loop file with mountbox (click loop, enter the file name, then click create, enter the size, the units, click create) or with the command line:
# dd if=/dev/zero bs=1M count=200 of=slitaz.fs
You now need to create a filesystem in this loopfile:
# yes | mke2fs -j slitaz.fs
Later, if the loopfile is too small you can extend it (assuming you don't boot from the loopfile, but a Slitaz Live CD for example):
# dd if=/dev/zero bs=1M count=100 >> slitaz.fs
# resize2fs slitaz.fs

Root filesystem files installation

Copy files from the rootfs.gz archive of a cdrom into the loopfile:
# mount /dev/cdrom /media/cdrom
# mount -o loop,rw slitaz.fs /mnt
# unlzma -c /media/cdrom/boot/rootfs.gz | ( cd /mnt; cpio -idmu )
# umount -d /mnt
# umount /media/cdrom

Boot setup

Get a preinit iso file with same version (the kernel version must match the modules version in the root filesystem). The partition storing the loopfile (say /dev/hda1) and its path into the partition (say /data/slitaz.fs) is defined by the mount and loopfs arguments:
 
title SliTaz cooking
  map (hd0,0)/boot/slitaz-preinit.iso (hd1)
  map --hook
  kernel (hd1)/boot/bzImage mount=/dev/hda1 loopfs=data/slitaz.fs
  initrd (hd1)/boot/rootfs.gz
 
The loop install does not use exotic packages from preinit. You can use any SliTaz flavor (except lorams).
 
You can built an up-to-date preinit iso anytime with
# tazlito get-flavor preinit
# tazlito gen-distro
title SliTaz cooking in loop file
  map (hd0,0)/boot/slitaz-cooking.iso (hd1)
  map --hook
  kernel (hd1)/boot/bzImage mount=/dev/hda1 loopfs=data/slitaz.fs
  initrd (hd1)/boot/rootfs.gz
  
title SliTaz cooking in RAM (like the Live CD)
  map (hd0,0)/boot/slitaz-cooking.iso (hd1)
  map --hook
  kernel (hd1)/boot/bzImage rw root=/dev/null autologin
  initrd (hd1)/boot/rootfs.gz

Or, you can replace the device name of the mount variable by the UUID or LABEL returned by blkid:
 
title SliTaz cooking
  map (hd0,0)/boot/slitaz-preinit.iso (hd1)
  map --hook
  kernel (hd1)/boot/bzImage mount=a4b346ee-4c7b-46aa-9fd4-6bc39ab4fa96 loopfs=data/slitaz.fs
  initrd (hd1)/boot/rootfs.gz
 
You can extract the bzImage and rootfs.gz from the iso image to avoid map commands and defragmentation.