tazlito rev 387
loram: Add overlayfs support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Jul 05 11:26:08 2015 +0200 (2015-07-05) |
parents | efc6181ad217 |
children | 5d7c04a1ac79 |
files | tazlito |
line diff
1.1 --- a/tazlito Sun Jun 21 20:38:56 2015 +0300 1.2 +++ b/tazlito Sun Jul 05 11:26:08 2015 +0200 1.3 @@ -326,7 +326,7 @@ 1.4 local n 1.5 local i 1.6 return # Need to fix kernel code ? 1.7 - n=$(unlzma -c $1 | wc -c) 1.8 + n=$(unlzma < $1 | wc -c) 1.9 for i in $(seq 1 8); do 1.10 printf '\\\\x%02X' $(($n & 255)) 1.11 n=$(($n >> 8)) 1.12 @@ -524,7 +524,7 @@ 1.13 # extract rootfs.gz somewhere 1.14 extract_rootfs() 1.15 { 1.16 - (zcat $1 || unlzma -c $1 || cat $1) 2>/dev/null | \ 1.17 + (zcat $1 || unlzma < $1 || cat $1) 2>/dev/null | \ 1.18 (cd $2; cpio -idm > /dev/null) 1.19 } 1.20 1.21 @@ -802,15 +802,16 @@ 1.22 $TMP_DIR/initfs/sys $TMP_DIR/initfs/lib/modules 1.23 ln -s bin $TMP_DIR/initfs/sbin 1.24 ln -s . $TMP_DIR/initfs/usr 1.25 - while [ ! -f /lib/modules/$version/kernel/fs/aufs/aufs.ko.?z ]; do 1.26 - install_package aufs $version || return 1 1.27 - done 1.28 + for aufs in aufs overlayfs ; do 1.29 + [ ! -f /lib/modules/$version/kernel/fs/$aufs/$aufs.ko.?z ] && 1.30 + install_package $fs $version && break 1.31 + done || return 1 1.32 cp /init $TMP_DIR/initfs/ 1.33 # bootfloppybox will need floppy.ko.?z, /dev/fd0, /dev/tty0 1.34 cp /lib/modules/$version/kernel/drivers/block/floppy.ko.?z \ 1.35 $TMP_DIR/initfs/lib/modules 2> /dev/null 1.36 cp -a /dev/tty0 /dev/fd0 $TMP_DIR/initfs/dev 2> /dev/null 1.37 - cp /lib/modules/$version/kernel/fs/aufs/aufs.ko.?z \ 1.38 + cp /lib/modules/$version/kernel/fs/$aufs/$aufs.ko.?z \ 1.39 $TMP_DIR/initfs/lib/modules 1.40 if [ "$1" == "cdrom" ]; then 1.41 sed -i '/mod squashfs/d' $TMP_DIR/initfs/init 1.42 @@ -855,7 +856,7 @@ 1.43 cd $TMP_DIR/initfs 1.44 echo "Getting slitaz-release..." 1.45 for i in $TMP_DIR/iso/boot/rootfs*.gz; do 1.46 - ( zcat $i 2> /dev/null || unlzma -c $i) | \ 1.47 + ( zcat $i 2> /dev/null || unlzma < $i) | \ 1.48 cpio -idmu etc/slitaz-release > /dev/null 1.49 done 1.50 cd - > /dev/null 1.51 @@ -944,7 +945,7 @@ 1.52 mount -t tmpfs \$size tmpfs /mnt 1.53 path2=/mnt/.httpfs/ 1.54 path=/mnt/.cdrom/ 1.55 -mkdir -p /mnt/.rw \$path \$path2 1.56 +mkdir -p /mnt/.rw /mnt/.wd \$path \$path2 1.57 while [ ! -d \$path/boot ]; do 1.58 for i in \$(echo \$URLISO | sed 's/,/ /g'); do 1.59 httpfs \$i \$path2 && break 1.60 @@ -954,9 +955,9 @@ 1.61 1.62 memfree=\$(grep MemFree /proc/meminfo | sed 's/[^0-9]//g') 1.63 umount /proc 1.64 -branch=br=/mnt/.rw:/mnt/.cdrom/\$DIR 1.65 +branch=:/mnt/.cdrom/\$DIR 1.66 if [ ! -d /mnt/.cdrom/\$DIR/etc ]; then 1.67 -branch=br=/mnt/.rw 1.68 +branch= 1.69 for i in \${path}rootfs* ; do 1.70 fs=\${i#*root} 1.71 branch=\$branch:/mnt/.\$fs 1.72 @@ -967,8 +968,12 @@ 1.73 else 1.74 mkdir -p /mnt/.rw/mnt/.httpfs 1.75 fi 1.76 -insmod /lib/aufs.ko.gz 1.77 -mount -t aufs -o \$branch none /mnt 1.78 +while read type opt; do 1.79 + insmod /lib/\$type.ko.gz && mount -t \$type -o \$opt none /mnt && break 1.80 +done <<EOT 1.81 +aufs br=/mnt/.rw\$branch 1.82 +overlayfs workdir=/mnt/.wd\${branch/:/,lowerdir=},upperdir=/mnt/.rw 1.83 +EOT 1.84 [ -x /bin/httpfs ] && sed -i 's/DHCP="yes"/DHCP="no"/' /mnt/etc/network.conf 1.85 [ \$memfree -lt 30000 ] && sed -i 's/ slim//' /mnt/etc/rcS.conf 1.86 [ -x /mnt/sbin/init ] && exec /bin/switch_root mnt /sbin/init || sh 1.87 @@ -994,7 +999,7 @@ 1.88 for i in $TMP_DIR/iso/boot/rootfs*.gz; do 1.89 mkdir -p $TMP_DIR/fs 1.90 cd $TMP_DIR/fs 1.91 - ( zcat $i 2> /dev/null || unlzma -c $i) | cpio -idm 1.92 + ( zcat $i 2> /dev/null || unlzma < $i) | cpio -idm 1.93 cd - > /dev/null 1.94 rootfs=$TMP_DIR/$(basename $i) 1.95 /usr/sbin/mksquashfs $TMP_DIR/fs $rootfs -comp xz -Xbcj x86 1.96 @@ -1029,7 +1034,7 @@ 1.97 fi 1.98 } 1.99 1.100 -# Move rootfs to squashfs filesystem(s) to the cdrom writeable with aufs. 1.101 +# Move rootfs to squashfs filesystem(s) to the cdrom writeable with aufs/overlayfs. 1.102 # These squashfs may be loaded in ram at boot time. 1.103 # Rootfs are also copied to cdrom for tiny ramsize systems. 1.104 # Meta flavors are converted to normal flavors. 1.105 @@ -1040,7 +1045,7 @@ 1.106 mkdir $TMP_DIR/loramiso/fs 1.107 cd $TMP_DIR/loramiso/fs 1.108 for i in $( ls ../boot/root* | sort -r ) ; do 1.109 - ( zcat $i 2> /dev/null || unlzma -c $i ) | cpio -idmu 1.110 + ( zcat $i 2> /dev/null || unlzma < $i ) | cpio -idmu 1.111 rm -f $i 1.112 done 1.113 mkdir -p $TMP_DIR/loramiso/fs/mnt/.cdrom 1.114 @@ -1099,7 +1104,7 @@ 1.115 done 1.116 } 1.117 1.118 -# Move rootfs to a squashfs filesystem into the initramfs writeable with aufs. 1.119 +# Move rootfs to a squashfs filesystem into the initramfs writeable with aufs/overlayfs. 1.120 # Meta flavor selection sizes are updated. 1.121 build_loram_ram() 1.122 { 1.123 @@ -1834,8 +1839,8 @@ 1.124 echo "No /boot/rootfs.gz in iso image. Needs a SliTaz iso." 1.125 umount -d $TMP_DIR/iso 1.126 else 1.127 - ( unlzma -c $TMP_DIR/iso/boot/rootfs.gz || \ 1.128 - zcat $TMP_DIR/iso/boot/rootfs.gz ) | \ 1.129 + ( zcat < $TMP_DIR/iso/boot/rootfs.gz || \ 1.130 + unlzma < $TMP_DIR/iso/boot/rootfs.gz ) | \ 1.131 ( cd $TMP_DIR/rootfs ; cpio -idmu > /dev/null 2>&1 ) 1.132 if [ ! -s $TMP_DIR/rootfs/etc/slitaz-release ]; then 1.133 echo "No file /etc/slitaz-release in /boot/rootfs.gz of iso image. Needs a non loram SliTaz iso." 1.134 @@ -2593,7 +2598,7 @@ 1.135 1.136 for i in $TMP_DIR/iso/boot/rootfs* ; do 1.137 echo -n "Repacking $(basename $i)" 1.138 - (zcat $i 2> /dev/null || unlzma -c $i || cat $i) \ 1.139 + (zcat $i 2> /dev/null || unlzma < $i || cat $i) \ 1.140 2>/dev/null > $TMP_DIR/rootfs 1.141 lzma e $TMP_DIR/rootfs $i \ 1.142 $(lzma_switches $TMP_DIR/rootfs)