slitaz-boot-scripts rev 469

init: fix loopfs
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed May 26 19:47:08 2021 +0000 (13 months ago)
parents d37d21683dd1
children 3e887b1a369a
files init
line diff
     1.1 --- a/init	Sun Feb 21 17:55:09 2021 +0000
     1.2 +++ b/init	Wed May 26 19:47:08 2021 +0000
     1.3 @@ -29,6 +29,9 @@
     1.4  #     bindfs= [MOUNT] (deprecated)
     1.5  #         bind out of root tree part
     1.6  #
     1.7 +# extra= [MOUNT]
     1.8 +#	  extra initrd files list to load
     1.9 +#
    1.10  ### Special disk mode ; needs extra modules/softwares from preinit flavor.
    1.11  #
    1.12  # dmraid= [RAID]
    1.13 @@ -102,7 +105,8 @@
    1.14  		r=/dev/${r%%/*}
    1.15  	fi
    1.16  	d=${root#*$r}
    1.17 -	busybox mount $r $1
    1.18 +	t=$(busybox blkid 2> /dev/null | grep "$root[:\"]" | sed '/ TYPE=/!d;s/.* TYPE="//;s/".*//')
    1.19 +	busybox mount $r $1 ${t:+-t $t}
    1.20  }
    1.21  
    1.22  
    1.23 @@ -179,6 +183,27 @@
    1.24  }
    1.25  
    1.26  
    1.27 +mntiso() {
    1.28 +	umnt=
    1.29 +	if got mount; then
    1.30 +		dev=$root
    1.31 +		x=$(busybox blkid|grep $dev|sed 's/:.*//;q')
    1.32 +		root=${x:-$dev}
    1.33 +		[ "$dev" = "$root" ] || dev="$root ($dev)"
    1.34 +		echo "Mount $dev..."
    1.35 +		mnt $1
    1.36 +		umnt=" $umnt $1"
    1.37 +		arg posixovl && echo "And posixovl..." && umnt=" $umnt $1" &&
    1.38 +		mount.posixovl -F $1 -- -oallow_other -odefault_permissions -osuid
    1.39 +	fi
    1.40 +	got loopfs && echo "Into file $root..." && umnt=" $umnt $1" &&
    1.41 +		losetup /dev/loop0 $1/$root && root=/dev/loop0 && mnt $1
    1.42 +	[ -z "$umnt" ] && mnt $1
    1.43 +	got bindfs && echo "Bind ${root/,/ to }..." &&
    1.44 +		busybox mount --bind $1/${root%,*} $1/${root/,//}
    1.45 +	true
    1.46 +}
    1.47 +
    1.48  
    1.49  
    1.50  if [ "$1" != 'log' ]; then
    1.51 @@ -243,21 +268,9 @@
    1.52  fi
    1.53  lvm
    1.54  
    1.55 -if got mount; then
    1.56 -	dev=$root
    1.57 -	x=$(busybox blkid|grep $dev|sed 's/:.*//;q')
    1.58 -	root=${x:-$dev}
    1.59 -	[ "$dev" = "$root" ] || dev="$root ($dev)"
    1.60 -	echo "Mount $dev..."
    1.61 -	mnt /mnt
    1.62 -	arg posixovl && echo "And posixovl..." &&
    1.63 -	mount.posixovl -F /mnt -- -oallow_other -odefault_permissions -osuid
    1.64 -fi
    1.65 -
    1.66 -got loopfs && echo "Into file $root..." &&
    1.67 -	losetup /dev/loop0 /mnt/$root && busybox mount /dev/loop0 /mnt
    1.68 -got bindfs && echo "Bind ${root/,/ to }..." &&
    1.69 -	busybox mount --bind /mnt/${root%,*} /mnt/${root/,//}
    1.70 +got extra && extra=$root && mntiso /mnt && for i in ${extra//,/ }; do
    1.71 +	 (unlzma < /mnt/$i 2>/dev/null || zcat /mnt/$i) | cpio -idmu
    1.72 +done && for i in $umnt; do umount -l $i; done
    1.73  arg cryptoroot= && try
    1.74  if use subroot; then
    1.75  	cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so /usr/sbin/chroot | sed\
    1.76 @@ -300,7 +313,7 @@
    1.77  	root=/dev/cdrom/fs
    1.78  	got rodev
    1.79  	mkdir -p $c /mnt$c /mnt/.rw$c
    1.80 -	mnt $c
    1.81 +	mntiso $c
    1.82  	o="-o 124"
    1.83  	p=/.cdrom/boot
    1.84  	c=$c$d
    1.85 @@ -311,8 +324,8 @@
    1.86  	fs=${i#*root}
    1.87  	r=$r:/mnt/.$fs
    1.88  	mkdir -p /mnt/.rw/mnt/.$fs /mnt/.$fs
    1.89 -	losetup $o /dev/loop$l $i
    1.90 -	busybox mount -o ro -t squashfs /dev/loop$((l++)) /mnt/.$fs
    1.91 +	losetup $o /dev/loop$((++l)) $i
    1.92 +	busybox mount -o ro -t squashfs /dev/loop$l /mnt/.$fs
    1.93  done
    1.94  while read type opt; do
    1.95  	mod $type || continue