THIS IS EXPERIMENTAL!!! If you do not exactly know what is being explained then STOP.
There might be typo's. I will fix them here when I find them.
Everything is based on a fixed IPaddress for the Raspberry Pi, make sure that you have ssh access.
Step 1. Take a normal SD-card and put the latest Raspbian Buster Lite on it.
Update and upgrade, you should be on: Linux raspberry 4.19.57-v7+ #1244 SMP Thu Jul 4 18:45:25 BST 2019 armv7l GNU/Linux
or higher, currently (25-7-2019) on Linux raspberry 4.19.58-v7+ #1245 SMP Fri Jul 12 17:25:51 BST 2019 armv7l GNU/Linux
Step 2. Create a iSCSI target and LUN on your Synology. Mark your IQN. I made a LUN of 16Gb.
Step 3. Install iSCSI on the Raspberry Pi, make sure it is running and discover the Target. Try to login and find the device with dmesg.
Create an empty file iscsi.initramfs. Actually there are 2 ways: One is empty file and everything concerning iSCSI on the commandline in /boot/cmdline.txt or Second, everything concerning iSCSI in this file and not in the /boot/cmdline.txt. I choose the first option (empty file).
Code: Select all
sudo apt-get install open-iscsi
sudo systemctl restart iscsi.service
sudo iscsiadm -m discovery -t sendtargets -p <IP of Synology>
sudo iscsiadm --portal <IP of Synology> -T <IQN of Target on Synology> --mode node --login
dmesg
sudo touch /etc/iscsi/iscsi.initramfs
Code: Select all
sudo mkfs.ext4 -m0 /dev/sdX
sudo blkid /dev/sdX ----> Mark this /dev/sdX UUID
sudo mkdir /mnt/iscsi
sudo mount /dev/sdX /mnt/iscsi
Code: Select all
sudo rsync -avhP --exclude /boot --exclude /proc --exclude /run --exclude /sys --exclude /mnt --exclude /media / /mnt/iscsi/
sudo mkdir /mnt/iscsi/{proc,run,sys,boot,mnt,media}
Code: Select all
sudo cp /boot/cmdline.txt /boot/cmdline.txt.org
sudo cp /boot/cmdline.txt /boot/cmdline.txt.lun
sudo cp /boot/config.txt /boot/config.txt.org
sudo cp /boot/config.txt /boot/config.txt.lun
- Spoiler: show
You might have to install initramfs-tools with:
Code: Select all
sudo apt-get install initramfs-tools
Code: Select all
cd /boot
sudo update-initramfs -v -k `uname -r` -c > /home/pi/initramfs.txt
Code: Select all
initramfs initrd.img-4.19.yy-xxx followkernel
Edit cmdline.txt.lun. Replace the complete content with (everything on 1 line!!!):
Code: Select all
dwc_otg.lpm_enable=0 ip=<Raspberry IPaddress>:<Synology IPaddress>:<Gateway IP>:255.255.255.0:<Raspberry hostname>:eth0:off
ISCSI_INITIATOR=<IQN from /etc/iscsi/initiatorname.iscsi>
ISCSI_TARGET_NAME=<IQN from Synology> ISCSI_TARGET_IP=<Synology IPaddress>
ISCSI_TARGET_PORT=3260 ISCSI_TARGET_GROUP=1 rw rootfs=ext4 root=UUID=<UUID from the /dev/sdX device>
fsck.repair=yes elevator=deadline rootwait panic=15
Code: Select all
PARTUUID=xxxxxxxxxx / ext4 defaults,noatime 0 1
Add a new line for the /dev/sdX device. Edit: nano /mnt/iscsi/etc/fstab
Code: Select all
UUID=<UUID from the /dev/sdX device> / ext4 defaults 1 1
Code: Select all
sudo /boot/switch_boot_setup.sh lun
sudo reboot
Code: Select all
sudo df -H
There should be a line like:
/dev/sdX 17G 2.2G 15G 14% /
Code: Select all
sudo /boot/switch_boot_setup.sh org
sudo reboot
If everything is stable I will post some scripts to keep the LUN and SD-card synchronized (almost done).
Enjoy.
Step 11.
Normal upgrading op packages can be done the normal way followed by sync of the files with the appropriate script.
When needed here is a logrotate file for both sd-card and lun the same file:
Code: Select all
sudo nano /etc/logrotate.d/sync_lun_and_sd-card
Code: Select all
/var/log/sync_lun_2_sd-card.log {
rotate 1
weekly
compress
missingok
}
/var/log/sync_sd-card_2_lun.log {
rotate 1
weekly
compress
missingok
}
Make sure that switching back and forth between lun and org works fine.
Also make sure that synchronising between lun and org is working fine too. There should be no errors.
Now switch back to org, synchronize and reboot to org.
Code: Select all
sudo /boot/switch_boot_setup.sh org
Now issue the following commands in exactly this order.
Code: Select all
sudo apt-get update
sudo apt-get upgrade
sudo reboot
Once up again issue this command
Code: Select all
cd /boot
sudo update-initramfs -v -k `uname -r` -c > /home/pi/initramfs.txt
Code: Select all
sudo /root/scripts/sync_sd-card_2_lun.sh
Code: Select all
sudo /boot/switch_boot_setup.sh lun
Code: Select all
uname -a