You are not logged in.

#1 2014-12-02 19:17:26

AGT
Member
From: Null Void
Registered: 2012-10-27
Posts: 59
Website

Running SSH Client from InitRAMFS/InitCPIO

Hi,

I'm trying to mount the root FS via ssh (with sshfs) at bootup, when loading the initramfs image by loading a custom initcpio hook. (Actually, SSH is one type of source - I want to add support for more sources, if possible.)
I'm getting this error when running the command during bootup: "Read: connection reset by peer". I'm not sure what could cause it -- does anyone know? And would anyone know how to resolve this error, too?

Here is the custom hook that I am using:

/etc/initcpio/hooks/root

run_hook() {
	hook_name="ram"
	indentation=""
	
	sleep_time=5
	
	dhclient "${root_fs_dev_net}"
	
	mount_handler="root_mount_handler"
	echo "Sleeping for ""${sleep_time}"" seconds"
	sleep "${sleep_time}" 
}

root_mount_handler() {
	echo "P1:""${1}"":P1"
	
	msg "${indentation}""${hook_name}"": Mounting \""${root_fs_source}"\" (with \""${root_fs_options}"\" options) as the root file system..."
	#mkdir --parents "${1}"
	#mount -t "${ramdisk_ram_fs_type}" -o rbind "${ramdisk_ram_mount_location}" "${1}"
	
	# mount --no-mtab --options rbind "${temporary}" "${1}"
	#mount --options "${temporary}" "${1}"
	mount --types "${root_fs_type}" --options "${root_fs_options}" "${root_fs_source}" "${1}"
	
	#umount "/root_ram/root_source"
	echo "Sleeping for ""${sleep_time}"" seconds"
	sleep "${sleep_time}"
	
	echo "ROOT FS DONE 2"
}

/etc/initcpio/install/root

#!/bin/bash

build() {
	add_module fuse
	
	add_binary "mount"
	add_binary "mount.cifs"
	#add_binary "mount.curl"
	add_binary "mount.fuse"
	#add_binary "mount.glusterfs"
	add_binary "mount.ntfs"
	add_binary "mount.ntfs-3g"
	add_binary "mount.lowntfs-3g"
	add_binary "mount.nfs"
	add_binary "mount.nfs4"
	add_binary "mount.ssh"
	add_binary "mount.ftp"
	add_binary "sshfs"
	add_binary "curl"
	add_binary "curlftpfs"
#	add_binary "mountpoint"
	#add_binary "mountstats"
#	add_binary "ls"
	#add_binary "cd"
#	add_binary "cp"
#	add_binary "pwd"
#	add_binary "test"
#	add_binary "mkdir"
#	add_binary "rmdir"
#	add_binary "chown"
	add_binary "echo"
#	add_binary "sleep"
	
	add_binary "dhclient"
	add_binary "ssh"
	# Exclude list for rsync.
#	add_file "/root/.rsync/exclude.txt"
	
	add_dir "/root/.ssh"
	
	add_runscript
}

help() {
	cat <<HELPEOF
This hook mounts the root volume from miscellaneous sources.
HELPEOF
}

Note that there are many comments and echoes to help me debug, and some comments remain from another hook.

Thank you.

Last edited by AGT (2014-12-02 19:21:51)

Offline

Board footer

Powered by FluxBB