Documente Academic
Documente Profesional
Documente Cultură
###
mount -o bind /proc/ /tmp/squashfs/proc/
mount -o bind /dev/ /tmp/squashfs/dev/
mount -o bind /dev/pts /tmp/squashfs/dev/pts/
mount -o bind /sys /tmp/squashfs/sys/
chroot /tmp/squashfs/ /bin/bash
umount /tmp/squashfs/proc/
umount /tmp/squashfs/dev/
umount /tmp/squashfs/dev/pts/
umount /tmp/squashfs/sys/
##
If your system supports some uion-filesystem, such as aufs or overlayfs, you don't
have to extract your original squashfs file.
For example the overlayfs is used( a kernel option to enable it): You can mount
your squashfs.file to /fm or somewhere else first. Prepare a writable filesystem
with 2 directories in it, say /to and /temp. prepare another writable directory
/fin for the merged results. Mount them together as an overlayfs to your system
mount -t overlay -o lowerdir=/fm,upperdir=/to,workdir=/temp overlay /fin
Now you can add/modify files in /fin. Once everything done, you can mksquashfs /fin
to a new squashfs file,
mksquashfs /fin newfile; umount /fin
, then clear/unmount all the other used directories as you will.
The squashfs and some unionfs are commonly used for a live-cd.
####################
Script make squashfs
####################
#!/bin/sh
#
# make a filesystem.squashfs for use in casper liveCD/liveUSB images
# usage sudo ./do_squashfs rootdir
rm filesystem.squashfs
chroot $1 dpkg-query -W --showformat='${Package} ${Version}\n' >
filesystem.manifest
mksquashfs $1 filesystem.squashfs
printf $(sudo du -sx --block-size=1 $1 | cut -f1) > filesystem.size
#############################
Script chroot to folder $1
##############################
#!/bin/sh
#
# chroot into a rootfs for the same architecture
# usage: sudo ./do_chroot rootdir
cp /etc/resolv.conf $1/etc
chroot $1 /bin/bash
umount $1/dev/pts
umount $1/dev
umount $1/sys
umount $1/proc || umount -lf $1/proc
rm $1/etc/resolv.conf
rm $1/var/lib/dbus/machine-id