25 lines
1.1 KiB
Bash
25 lines
1.1 KiB
Bash
#!/bin/bash
|
|
NFS_IP="192.168.1.5"
|
|
#NFS_ROOT_PATH="/nfs/$(hostname -s)-boot"
|
|
PI_SERIAL="6218cd17"
|
|
TFTP_ROOT="/volume1/rpi/tftpboot/"
|
|
ISCSI_ROOT_PARTITION="/dev/sda1"
|
|
ISCSI_ROOT_DIR="/iscsi/$(hostname -s)-iscsi"
|
|
ISCSI_TARGET_IQN="iqn.2000-01.com.synology:SynologyNAS.Target-11.b63ef49539c"
|
|
|
|
# Update /boot to point to the NFS mount of the TFTP folder for the Pi.
|
|
NFS_ROOT_PATH="${TFTP_ROOT}${PI_SERIAL}"
|
|
sudo sed -i -r -E \
|
|
"s@.*/boot +.*@${NFS_IP}:${NFS_ROOT_PATH} /boot nfs defaults,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 |