Last active
May 30, 2020 22:48
-
-
Save sdwilsh/d0fc043872df58bc05943c005e928ccc to your computer and use it in GitHub Desktop.
Mount and Copy Root Contents for Network Booting a Pi 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ISCSI_ROOT_PARTITION="/dev/sdb1" | |
# Create the ext4 Filesystem | |
sudo mkfs.ext4 /${ISCSI_ROOT_PARTITION} | |
ISCSI_ROOT_DIR="$(mktemp -d)" | |
sudo mount "${ISCSI_ROOT_PARTITION}" ${ISCSI_ROOT_DIR} | |
# Mount the Root Partion in the Generated Image | |
CREATION_OUTPUT=$(sudo partx --add -v output-arm-image/image) | |
LOOP_DEVICE=$(echo ${CREATION_OUTPUT} | sed -E 's@.*(/dev/loop[0-9]+).*@\1@') | |
IMAGE_ROOT_DIR="$(mktemp -d)" | |
sudo mount "${LOOP_DEVICE}p2" ${IMAGE_ROOT_DIR} | |
# Begin the Copy | |
sudo rsync -a --info=progress2 "${IMAGE_ROOT_DIR}/" ${ISCSI_ROOT_DIR} | |
# The generated image is no longer needed, so we can cleanup. | |
sudo umount ${IMAGE_ROOT_DIR} | |
sudo partx --delete -v ${LOOP_DEVICE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment