LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 02-25-2011, 07:57 AM   #1
mnb007
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/default.cf.2 ] && mv /boot/default.cf.2 /boot/default.cf.3
[ -r /boot/default.cf.1 ] && mv /boot/default.cf.1 /boot/default.cf.2
[ -r /boot/default.cf.0 ] && mv /boot/default.cf.0 /boot/default.cf.1
[ -r /boot/default.cf ] && mv /boot/default.cf /boot/default.cf.0
mount -o sync,remount,ro /boot
fi
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, 02:40 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 7,787

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
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, 08:25 AM   #3
mnb007
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:

PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
BLUE_LED=/sys/class/leds/blue/brightness
GREEN_LED=/sys/class/leds/green/brightness

# 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/factory.cf \;

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
DATAFS=

unset BTN0 BTN1 FACTORY_RESET UPGRADE_MODE
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/default.cf.2 ] && mv /boot/default.cf.2 /boot/default.cf.3
[ -r /boot/default.cf.1 ] && mv /boot/default.cf.1 /boot/default.cf.2
[ -r /boot/default.cf.0 ] && mv /boot/default.cf.0 /boot/default.cf.1
[ -r /boot/default.cf ] && mv /boot/default.cf /boot/default.cf.0
mount -o sync,remount,ro /boot
fi
echo 'Loading config'

# load config, currently only one loadable config is supported
/sbin/loadconfig

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

# USB
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
fi
DATAFS=${PART}
configdb set fsck DATAFS ${DATAFS}
echo "Using $PART for data"
break
done
[ -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, 10:41 AM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
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?
 
  


Reply


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 10:33 AM
minimum rc.sysinit jiml8 Linux - Software 0 07-17-2006 10:50 PM
Rc.sysinit Very Maqbool Linux - Software 2 07-27-2005 03:29 AM
sysinit rilians Slackware 1 07-01-2004 10:36 AM
/etc/rc.d/rc.sysinit problem linuxinside Linux - Newbie 5 03-29-2004 11:27 AM


All times are GMT -5. The time now is 12:38 PM.

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