WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: my unpluggable piCore (read-only SD card, umnounted a.s.a.p.)  (Read 3609 times)

Offline xpector

  • Newbie
  • *
  • Posts: 16
It took me a while to put these pieces together. Maybe it helps someone.

Code: [Select]
#set copy flag
>/mnt/mmcblk0p2/tce/copy2fs.flg
sudo reboot

Code: [Select]
#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

Code: [Select]
#unmount data partition after extensions are loaded
echo umount /mnt/mmcblk0p2 >> /opt/bootlocal.sh
filetool.sh -bv

Code: [Select]
#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

Code: [Select]
#lock the SD card
sudo umount /mnt/mmcblk0p2
sudo ./arm-sdtool /dev/mmcblk0 lock
#sudo reboot or just pull the power plug...

Code: [Select]
#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

Offline san.gh

  • Newbie
  • *
  • Posts: 6
Re: my unpluggable piCore (read-only SD card, umnounted a.s.a.p.)
« Reply #1 on: November 24, 2018, 08:17:02 PM »
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.

Offline DrRob

  • Jr. Member
  • **
  • Posts: 61
Re: my unpluggable piCore (read-only SD card, umnounted a.s.a.p.)
« Reply #2 on: February 14, 2019, 02:49:35 AM »
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:

Code: [Select]
sed -i -e 's#/mnt/sda1  *vfat  *ro,noload,noauto,users,exec#/mnt/sda1 vfat noauto,users,exec#' /etc/fstab
mount /mnt/sda1

Rob