Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-25-2011, 06:57 AM   #1
LQ Newbie
Registered: Feb 2011
Posts: 8

Rep: Reputation: 0
how to write to a rc.sysinit on a tempfs? Catch 22

my rc.sysinit script has:
if [ "$FACTORY_RESET" = "1" ]; then
echo 'Reseting to factory config'
mount -o sync,remount,rw /boot
[ -r /boot/ ] && mv /boot/ /boot/
[ -r /boot/ ] && mv /boot/ /boot/
[ -r /boot/ ] && mv /boot/ /boot/
[ -r /boot/ ] && mv /boot/ /boot/
mount -o sync,remount,ro /boot
And I need to change last one to rw or comment it out until I write some other part of the installation, otherwise the whole system is ro and I can't alter or install anything. Any idea how to do it?
I guess that when my system boots put everything into rw, create the system and then move everythiong into ro, so I am locked out. If I remove the SD card and put into another system, how can I access the script and change it? Sorry guys, I am new to Linux and really stuck with this read-only issue.
Old 02-26-2011, 01:40 PM   #2
LQ Guru
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 8,981

Rep: Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930
Tell us exactly what you want to edit. We need the exact system type. just guessing wildly, if it's a squashfs, there are utilities for writing them. Others can be mounted as loop devices
Old 02-27-2011, 07:25 AM   #3
LQ Newbie
Registered: Feb 2011
Posts: 8

Original Poster
Rep: Reputation: 0
I have a ARM headless system on a SD card, so accessed by putty/ssh.
The boot files on the card are a dm3xxx.dat, linux, md5sum and rootfs.ext2.
I guess once boot up then write the system and go into ro mode, so somewhere should be a script to change.
If I do anything as I said it will complain that is a read-only, so any folder I create will dissapear when rebooting take effect.

This is the rc,sysinit, if that helps:

export PATH

# fix permissions, since cpio doesn't preserve setuid bit
/bin/chmod 4755 /sbin/msudo

/bin/mkdir -p /proc
/bin/mount -t proc proc /proc
/bin/mkdir -p /sys
/bin/mount -t sysfs sysfs /sys
/bin/dmesg -n 3

echo "Starting depmod"
depmod -a

echo "Building config"
find /etc/config -maxdepth 1 -name add_\*.cf -exec cat {} >>/etc/config/ \;

echo "Starting mdev"
/sbin/mdev -s

# /dev/fd is used by Ghostcript, bash
ln -s /proc/self/fd /dev/fd
# Detect and define out partition layout
# if changing it ALSO CHANGE linuxrc
echo "Waiting for USB partitions to become available..."
# usb-storage.delay_use (default 5 sec)
sleep 6

echo "Finding data partitions"
[ -x /etc/scripts/finddatapartitions ] && DATAPARTS=`/etc/scripts/finddatapartitions`
echo Data partitions: $DATAPARTS

grep -q 'k_btn0=1' /proc/cmdline && BTN0=1
grep -q 'k_btn1=1' /proc/cmdline && BTN1=1
[ -z "$BTN0" -a -n "$BTN1" ] && FACTORY_RESET=1
[ -n "$BTN0" -a -n "$BTN1" ] && UPGRADE_MODE=1

# Reset config if special reset time
if [ "$FACTORY_RESET" = "1" ]; then
echo 'Reseting to factory config'
mount -o sync,remount,rw /boot
[ -r /boot/ ] && mv /boot/ /boot/
[ -r /boot/ ] && mv /boot/ /boot/
[ -r /boot/ ] && mv /boot/ /boot/
[ -r /boot/ ] && mv /boot/ /boot/
mount -o sync,remount,ro /boot
echo 'Loading config'

# load config, currently only one loadable config is supported

# Configure kernel parameters
#configdb print system/sysctl|(while read line; do sysctl -e -w $line; done) >/dev/null

grep -q usbfs /proc/filesystems && mount -t usbfs usbfs /proc/bus/usb

# mount the rest of filesystems in fstab
mount -a

# Setting up data area - mount first available data partition
echo "Setting up data area"
# remove the blue trigger, if any
[ -r "$BLUE_LED" ] && echo 0 > "$BLUE_LED"
[ -r "$BLUE_LED" ] && echo 255 > "$BLUE_LED"

mkdir /data
for PART in $DATAPARTS; do
echo "Trying to mount $PART"
if ! /bin/mount ${PART} -t ext3 /data ; then
/bin/umount ${PART} >/dev/null 2>&1
echo "Formating data partition $PART"
mkfs.ext3 -q -c -j ${PART} || continue
tune2fs -i 0 -c 0 ${PART}
/bin/mount ${PART} -t ext3 /data || continue
configdb set fsck DATAFS ${DATAFS}
echo "Using $PART for data"
[ -z "$DATAFS" ] && rmdir /data

Let me know if you want any other specific file, as I am new to linux. And thanks for helping out.
Old 02-27-2011, 09:41 AM   #4
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 347Reputation: 347Reputation: 347Reputation: 347
I note that you're familiar with the remount mounting option since you use it in the line you discussed as needing to be mounted as rw instead of ro, so why not mount it as rw there, restore your system, and then remount it later as ro?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
rc.sysinit in error nightrider Linux - Newbie 11 10-02-2007 09:33 AM
minimum rc.sysinit jiml8 Linux - Software 0 07-17-2006 09:50 PM
Rc.sysinit Very Maqbool Linux - Software 2 07-27-2005 02:29 AM
sysinit rilians Slackware 1 07-01-2004 09:36 AM
/etc/rc.d/rc.sysinit problem linuxinside Linux - Newbie 5 03-29-2004 10:27 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration