Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: xpector on March 27, 2018, 11:54:24 AM
-
It took me a while to put these pieces together. Maybe it helps someone.
#set copy flag
>/mnt/mmcblk0p2/tce/copy2fs.flg
sudo reboot
#get the SD locker tool
wget "https://github.com/BertoldVdb/sdtool/blob/master/static/arm-sdtool?raw=true" -O arm-sdtool
chmod +x arm-sdtool
sudo ./arm-sdtool /dev/mmcblk0 status
#unmount data partition after extensions are loaded
echo umount /mnt/mmcblk0p2 >> /opt/bootlocal.sh
filetool.sh -bv
#remaster the core to mount the data partition read-only
sudo mount /dev/mmcblk0p1
cd ~
sudo mkdir extract
cd extract
zcat /mnt/mmcblk0p1/9.0.3v7.gz | sudo cpio -i -H newc -d
sudo sed -i -e 's#OPTIONS="noauto,users,exec"#OPTIONS="ro,noload,noauto,users,exec"#g' ./usr/sbin/rebuildfstab
sudo find | sudo cpio -o -H newc | gzip --best > ../9.0.3v7.gz
sudo cp -f ../9.0.3v7.gz /mnt/mmcblk0p1/9.0.3v7.gz && rm ../9.0.3v7.gz
sudo rm -f -r ~/extract/*
zcat /mnt/mmcblk0p1/9.0.3.gz | sudo cpio -i -H newc -d
sudo sed -i -e 's#OPTIONS="noauto,users,exec"#OPTIONS="ro,noload,noauto,users,exec"#g' ./usr/sbin/rebuildfstab
sudo find | sudo cpio -o -H newc | gzip --best > ../9.0.3.gz
sudo rm /mnt/mmcblk0p1/9.0.3.gz
sudo cp -f ../9.0.3.gz /mnt/mmcblk0p1/9.0.3.gz && rm ../9.0.3.gz
sudo rm -f -r ~/extract/*
cd ..
rmdir extract
sudo umount /mnt/mmcblk0p1
#lock the SD card
sudo umount /mnt/mmcblk0p2
sudo ./arm-sdtool /dev/mmcblk0 lock
#sudo reboot or just pull the power plug...
#making changes after you locked it read-only
sudo ./arm-sdtool /dev/mmcblk0 unlock
mount /mnt/mmcblk0p2
sudo mount -o remount,rw /mnt/mmcblk0p2
#now make the change
filetool.sh -bv
sudo umount /mnt/mmcblk0p2
sudo ./arm-sdtool /dev/mmcblk0 lock
-
I know this is old, but I just wanted to say THANK YOU. Posting this has saved me whatever time it would have taken me to put together all the steps outlined. (I would have assumed there would be a section in the official docs outlining how to make it readonly (completely, because a lot of SDcards fail in a year or two if written to a lot, and many guides don't note the hardware switch on the card itself which makes corruption on power loss as the card internally moves things less likely) since so many projects are to make "appliance-style" devices; so I appreciate it.
-
I found that this procedure prevented my Pi from mounting a USB memory stick. I worked around it by doing this in /opt/bootlocal.sh:
sed -i -e 's#/mnt/sda1 *vfat *ro,noload,noauto,users,exec#/mnt/sda1 vfat noauto,users,exec#' /etc/fstab
mount /mnt/sda1
Rob