Reply
Megabyte
wig_out
Posts: 96
Registered: ‎07-10-2010
0

chroot your way out of unwriteable root squashfs

 

 

#!/bin/sh
#chroot-startup

#change to a writeable directory
cd /usr/local/etc

#make the directory we'll chroot into, newroot
mkdir -p newroot

#change to newroot dir
cd /usr/local/etc/newroot

#DIRECTORIES

#find all the directories (and symlink directories) in the root dir
for i in /*; do if [ -d $i ]; then echo $i; fi; done>/tmp/chrootdirs

#find all the firmware partitions mounted in /etc/fstab
grep /dev/mtdblock /etc/fstab | cut -f 2 >> /tmp/chrootdirs

#make empty dirs for overmounting
while read i; do mkdir -p `echo $i | cut -c 2-`; done < /tmp/chrootdirs

#FILES

#find all the files (and symlink files) in the root dir
for i in /*; do if [ ! -d $i ]; then echo $i; fi; done>/tmp/chrootfiles

#make empty files for overmounting
while read i; do touch `echo $i | cut -c 2-`; done </tmp/chrootfiles


#OVERMOUNT / mount -o bind time

#combine the list of dirs and files to be overmounted
cat /tmp/chrootdirs /tmp/chrootfiles >/tmp/chrootbinds

#overmount
while read i; do mount -o bind $i `echo $i | cut -c 2-`; done </tmp/chrootbinds

#CHROOT time

chroot /usr/local/etc/newroot

 

 

 

I have tested the above as a script and it works on my system.

now you can mkdir /opt and whatever

I'd be interested in hearing back on this if anyone has an experience to share.


Don't you see that the whole aim of Newspeak is to narrow the range of thoght? In the end we shall make thoughtcrime literally impossible, because there will be no words in which to express it.
1984 (Nineteen Eighty-Four)

http://minimodding.com
- a place to discuss modifying embedded devices.
Regular Visitor
trisk
Posts: 4
Registered: ‎12-03-2010
0

Re: chroot your way out of unwriteable root squashfs

That's... creative. Might be better to just get a unionfs driver built for this thing. :smileytongue:

Gigabyte
dm
Posts: 191
Registered: ‎08-18-2010
0

Re: chroot your way out of unwriteable root squashfs

cute.

If I ever have time, I will try to Redo a firmware of 2.2 without the encrypted image, and get it to work with a new/altered kernal that does not force Secure_boot.

 

then i can just make a firmware with new links to whatever and a script that can call from usb or a temp dir

 

Kilobyte
capatty
Posts: 31
Registered: ‎08-10-2010
0

Re: chroot your way out of unwriteable root squashfs

If you feel like doing something really creative, you throw in the custom kernel, then add onto wig_out's script to erase and then flash back into squashfs, and write a new boot sector.

 

Have you guys tried any testing using QEMU?  I haven't had any time to plug through the source code or test any code, but I might have some free time over the next few weeks.

 

 

Visitor
dubanks
Posts: 1
Registered: ‎12-15-2010
0

Re: chroot your way out of unwriteable root squashfs

Just giving it a bump.. any updates folks?