Last active
May 30, 2020 18:22
-
-
Save sdwilsh/5010a58c7f248b1924dbc291e92a6f64 to your computer and use it in GitHub Desktop.
Updating /etc/fstab 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
PI_MAC="dc-a6-32-7a-b4-02" | |
TFTP_ROOT="/mnt/rust0/tftp/" | |
# Update /boot to point to the NFS mount of the TFTP folder for the Pi. | |
NFS_IP=$(cat ${ISCSI_ROOT_DIR}/etc/iscsi/iscsi.initramfs | grep 'ISCSI_TARGET_IP=' | cut -d '=' -f 2) | |
NFS_ROOT_PATH="${TFTP_ROOT}${PI_MAC}" | |
sudo sed -i -r -E \ | |
"s@.*/boot +.*@${NFS_IP}:${NFS_ROOT_PATH} /boot nfs defaults,vers=4.1,proto=tcp 0 0@" \ | |
${ISCSI_ROOT_DIR}/etc/fstab | |
# Update / to point to the iSCSI drive. | |
ISCSI_ROOT_PARTUUID=$(sudo blkid | grep ${ISCSI_ROOT_PARTITION} | tr ' ' '\n' | grep PARTUUID | cut -d '=' -f 2 | tr -d '"') | |
sudo sed -i -r -E \ | |
"s@.*/ +.*@PARTUUID=${ISCSI_ROOT_PARTUUID} / ext4 _netdev,noatime 0 1@" \ | |
${ISCSI_ROOT_DIR}/etc/fstab | |
# The connection to the iSCSI device is no longer needed, so clean it up. | |
sudo umount ${ISCSI_ROOT_DIR} | |
sudo iscsiadm --m node -T ${ISCSI_TARGET_IQN} --portal ${ISCSI_TARGET_IP}:3260 -u | |
sudo iscsiadm -m node -o delete -T ${ISCSI_TARGET_IQN} --portal ${ISCSI_TARGET_IP}:3260 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment