mirror of
				https://github.com/Telecominfraproject/ols-nos.git
				synced 2025-10-31 01:57:48 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			147 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			147 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| https://bugs.debian.org/cgi-bin/bugreport.cgi?att=0;bug=468114;msg=32
 | |
| 
 | |
| On 2015-08-11, Vagrant Cascadian wrote:
 | |
| > On 2015-08-11, Vagrant Cascadian wrote:
 | |
| >> I've taken a quick stab as refreshing this, though I haven't yet tested
 | |
| >> it. I did move mounting of the loopback to mount_loop_root in functions,
 | |
| >> as I would like to eventually support loopback mounted files from NFS.
 | |
| >
 | |
| > Made some small changes, updated and *tested* this time! Patch below...
 | |
| 
 | |
| And added NFS support! Full patch below...
 | |
| 
 | |
| live well,
 | |
|   vagrant
 | |
| 
 | |
| diff --git a/init b/init
 | |
| index abf7f25..2760bcb 100755
 | |
| --- a/init
 | |
| +++ b/init
 | |
| @@ -98,6 +98,15 @@ for x in $(cat /proc/cmdline); do
 | |
|  			;;
 | |
|  		esac
 | |
|  		;;
 | |
| +	loop=*)
 | |
| +		LOOP="${x#loop=}"
 | |
| +		;;
 | |
| +	loopflags=*)
 | |
| +		LOOPFLAGS="-o ${x#loopflags=}"
 | |
| +		;;
 | |
| +	loopfstype=*)
 | |
| +		LOOPFSTYPE="${x#loopfstype=}"
 | |
| +		;;
 | |
|  	nfsroot=*)
 | |
|  		NFSROOT="${x#nfsroot=}"
 | |
|  		;;
 | |
| diff --git a/initramfs-tools.8 b/initramfs-tools.8
 | |
| index ea8c098..ce8e830 100644
 | |
| --- a/initramfs-tools.8
 | |
| +++ b/initramfs-tools.8
 | |
| @@ -42,6 +42,19 @@ The default is 180 seconds.
 | |
|  set the file system mount option string.
 | |
|  
 | |
|  .TP
 | |
| +\fB\fI loop
 | |
| +path within the original root file system to loop-mount and use as the
 | |
| +real root file system.
 | |
| +
 | |
| +.TP
 | |
| +\fB\fI loopflags
 | |
| +set the loop file system mount option string, if applicable.
 | |
| +
 | |
| +.TP
 | |
| +\fB\fI loopfstype
 | |
| +set the loop file system type, if applicable.
 | |
| +
 | |
| +.TP
 | |
|  \fB\fI nfsroot
 | |
|  can be either "auto" to try to get the relevant information from DHCP or a
 | |
|  string of the form NFSSERVER:NFSPATH or NFSSERVER:NFSPATH:NFSOPTS.
 | |
| diff --git a/scripts/functions b/scripts/functions
 | |
| index 8c1bb1f..2ed3ce3 100644
 | |
| --- a/scripts/functions
 | |
| +++ b/scripts/functions
 | |
| @@ -426,6 +426,42 @@ mountfs()
 | |
|  	${type}_mount_fs "$1"
 | |
|  }
 | |
|  
 | |
| +# Mount a loopback device, which is present on the mounted filesystem.
 | |
| +mount_loop_root()
 | |
| +{
 | |
| +	mkdir -p /host
 | |
| +	mount -o move ${rootmnt} /host
 | |
| +	loopfile="/host/${LOOP#/}"
 | |
| +
 | |
| +	while [ ! -e "$loopfile" ]; do
 | |
| +		panic "ALERT! $loopfile does not exist.  Dropping to a shell!"
 | |
| +	done
 | |
| +
 | |
| +	if [ ${readonly} = y ]; then
 | |
| +		roflag=-r
 | |
| +	else
 | |
| +		roflag=-w
 | |
| +	fi
 | |
| +
 | |
| +	# Get the loop filesystem type if not set
 | |
| +	if [ -z "${LOOPFSTYPE}" ]; then
 | |
| +	    FSTYPE=$(get_fstype "$loopfile")
 | |
| +	else
 | |
| +	    FSTYPE=${LOOPFSTYPE}
 | |
| +	fi
 | |
| +
 | |
| +	# FIXME This has no error checking
 | |
| +	modprobe loop
 | |
| +	modprobe ${FSTYPE}
 | |
| +
 | |
| +	# FIXME This has no error checking
 | |
| +	mount ${roflag} -o loop -t ${FSTYPE} ${LOOPFLAGS} "$loopfile" ${rootmnt}
 | |
| +
 | |
| +	if [ -d ${rootmnt}/host ]; then
 | |
| +		mount -o move /host ${rootmnt}/host
 | |
| +	fi
 | |
| +}
 | |
| +
 | |
|  # Mount the root file system.  It should be overridden by all
 | |
|  # boot scripts.
 | |
|  mountroot()
 | |
| diff --git a/scripts/local b/scripts/local
 | |
| index f6424f0..072013e 100644
 | |
| --- a/scripts/local
 | |
| +++ b/scripts/local
 | |
| @@ -135,7 +135,8 @@ local_mount_root()
 | |
|  
 | |
|  	ROOT=$(resolve_device "$ROOT")
 | |
|  
 | |
| -	if [ "${readonly}" = "y" ]; then
 | |
| +	if [ "${readonly}" = "y" ] && \
 | |
| +	   ([ -z "$LOOP" ] || [ "${FSTYPE#ntfs}" = "$FSTYPE" ]); then
 | |
|  		roflag=-r
 | |
|  	else
 | |
|  		roflag=-w
 | |
| @@ -153,6 +154,10 @@ local_mount_root()
 | |
|  	else
 | |
|  		mount ${roflag} ${ROOTFLAGS} ${ROOT} ${rootmnt}
 | |
|  	fi
 | |
| +
 | |
| +	if [ "${LOOP}" ]; then
 | |
| +		mount_loop_root
 | |
| +	fi
 | |
|  }
 | |
|  
 | |
|  local_mount_fs()
 | |
| diff --git a/scripts/nfs b/scripts/nfs
 | |
| index 1c29850..d382413 100644
 | |
| --- a/scripts/nfs
 | |
| +++ b/scripts/nfs
 | |
| @@ -72,6 +72,10 @@ nfs_mount_root_impl()
 | |
|  	fi
 | |
|  
 | |
|  	nfsmount -o nolock ${roflag} ${NFSOPTS} ${NFSROOT} ${rootmnt}
 | |
| +
 | |
| +	if [ "${LOOP}" ]; then
 | |
| +		mount_loop_root
 | |
| +	fi
 | |
|  }
 | |
|  
 | |
|  # NFS root mounting
 | 
