PDA

View Full Version : Editing the read-only parts of an image



Devilfish
12th April, 2008, 12:37 PM
Enigma images are created in such a way that there is a read-only section of the image and read/write section. The /var folder and /tmp folder is the old folders in an image that you can edit. If, for any reason, you want to edit the read-only folders, i.e. /bin, /etc, /lib, /share, etc. this is what you'll need to do.

First of all, you'll need a linux platform to make your changes. This could be a PC with a linux OS, i.e. Ubuntu, or you could have a program called VMWare which is a virtual machine that allows you to run a different OS from within an existing OS. It's up to you which one you choose and I will not go into setting it up in this thread.

Telnet to the dreambox...
username: root
password: dreambox

Follow these commands...


mkdir /var/tmp/root
mount -t squashfs -o ro /dev/mtdblock/5 /var/tmp/root
cd /var/tmp
tar -cf root.tar root FTP the root.tar to your linux desktop and open a terminal.


cd Desktop
tar -xf root.tarLeave the terminal window open.

Treat the root folder on the desktop as the box itself but don't add or change anything in /var because that is a different location.

When you have finished go back to the terminal window and...


./mksquashfs root mtd5.img -beThen ftp the mtd5.img back to the box. You will need a copy of mksquashfs on the Desktop to be able to perform this command.

Telnet back to the box and...


cd /tmp && eraseall /dev/mtd/5 && cp mtd5.img /dev/mtd/5 && rebootDone.

To check what mtd# ...


more /proc/mtd
...but most squashfs are mtd5.

Njoy!

mattwills71187
11th August, 2008, 10:30 AM
is there anyway to do this from a Pc running on windows

beady
11th August, 2008, 12:12 PM
is there anyway to do this from a Pc running on windows
No, but you can install a virtual linux machine, using e.g. vmware, and do it from there. It's fairly easy to set up, and there's plenty of guides on the interweb.

ronlkh
19th September, 2008, 09:44 AM
can anyone please tell me if this method works? I have tested so many times but not working. I have done and follow devilfish's instruction. I am able to produce mtd5.img but when I flash back to the box, the box dont work at all. Can someone please advise me?

Thanks

DavC
19th September, 2008, 09:48 AM
will this method work for neutrino on the dbox as well?

mrdude
19th September, 2008, 04:27 PM
can anyone please tell me if this method works? I have tested so many times but not working. I have done and follow devilfish's instruction. I am able to produce mtd5.img but when I flash back to the box, the box dont work at all. Can someone please advise me?

Thanks

Yes of course it works - This is the exact method I used to make the moddified jade image I posted in here.

ronlkh
20th September, 2008, 12:29 AM
must I umount the root and delete the root.tar before I flash the new mtd5.img?

Thanks

ronlkh
20th September, 2008, 06:11 AM
What I am running is vmware + ubuntu 8.04.

First I telnet to the dm500 from ubuntu terminal
then I make directory
root@dm500 ~ #mkdir /var/tmp/root
root@dm500 ~ #mount -t squashfs -o ro /dev/mtdblock/5 /var/tmp/root
root@dm500 ~#cd /var/tmp
root@dm500 /tmp #tar -cf root.tar root
root@dm500 /tmp #
then I open another terminal to ftp to dm500
root@ubuntu8041:/home/user/Desktop# ftp 192.168.0.112
Connected to 192.168.0.112.
220 Welcome to the PLi dreambox FTP server
Name (192.168.0.112:user): root
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /tmp
250 Directory successfully changed.
ftp> get root.tar
ftp>bye
root@ubuntu8041:/home/user/Desktop# tar -xf root.tar
root@ubuntu8041:/home/user/Desktop# ./mksquashfs root mtd5.img
I mksquashfs back the original root and a new mtd5.img is created.
then I ftp back to dm500
root@ubuntu8041:/home/user/Desktop# ftp 192.168.0.112
Connected to 192.168.0.112.
220 Welcome to the PLi dreambox FTP server
Name (192.168.0.112:user): root
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /tmp
250 Directory successfully changed.
ftp> put mtd5.img
ftp>bye
exit back to Desktop and telnet back to the box
i change the directory to /tmp
root@ubuntu8041:/home/user/Desktop# telnet 192.168.0.112
Trying 192.168.0.112...
Connected to 192.168.0.112.
Escape character is '^]'.

PLi dm500 Jade 20080718 (based on 1.09)
welcome on your dreambox! - Kernel 2.6.9 (13:08:41).
dm500 login: root
Password:


BusyBox v1.01 (2008.07.11-10:44+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

root@dm500 ~ # cd /tmp && eraseall /dev/mtd/5 && cp mtd5.img /dev/mtd/5 && reboot

after image flashed dm500 reboot but dm500 is dead

I did not umount the root directory in the /var/tmp nor I have deleted the root.tar

Have I done anything wrong?

Devilfish
20th September, 2008, 07:03 AM
On a working image, do a 'more /proc/mtd' in telnet and see what it says.

ronlkh
20th September, 2008, 10:31 AM
Hi Devilfish,
What I got is :-

root@dm500 ~ # more /proc/mtd
dev: size erasesize name
mtd0: 00600000 00020000 "DreamBOX cramfs+squashfs"
mtd1: 001c0000 00020000 "DreamBOX jffs2"
mtd2: 00040000 00020000 "DreamBOX OpenBIOS"
mtd3: 007c0000 00020000 "DreamBOX (w/o bootloader)"
mtd4: 00800000 00020000 "DreamBOX (w/ bootloader)"
mtd5: 004e0000 00020000 "DreamBOX SquashedFS"
mtd6: 00120000 00020000 "DreamBOX Cramfs"

thanks

Devilfish
20th September, 2008, 02:43 PM
That looks right, was just checking that the squashfs part was indeed mtd5. Not sure what else to suggest. Maybe try a totally different image.

unai_goiko
22nd September, 2008, 01:07 AM
Hello there! I've just found this forum and have to say that i'm impress with it :)

Continuing with the thread, I'm having the same problem as ronlkh here. I followed the steps explained by Devilfish except from the part of using a mksquashfs binnary copied on the Desktop. I used the mksquashfs binnary from ubuntu instead. Then, after rebooting, the dreambox does not respond and i get a black screen...

I've read that squashfs-lzm is used for building most of the dreambox images, shouldn't will be using that program? Thanks in advance!

ajeeb
3rd January, 2009, 05:31 PM
hi,
this is gr8 topic tested with gemini4.6 not work (Black screen after reboot)
I do exactly same steps said Devilfish

BR

Devilfish
3rd January, 2009, 05:36 PM
I followed these steps about a month ago to edit /var_init on an image so that certain files stayed there after a factory reset and it worked 100%.

Maybe the SquashedFS partition is not mtd5 on a Gemini image, I'm not sure, but I imagine it would be the same.

ajeeb
3rd January, 2009, 05:54 PM
hi I get this
root@dreambox:~> more /proc/mtd
dev: size erasesize name
mtd0: 00500000 00020000 "DreamBOX cramfs+squashfs"
mtd1: 002c0000 00020000 "DreamBOX jffs2"
mtd2: 00040000 00020000 "DreamBOX OpenBIOS"
mtd3: 007c0000 00020000 "DreamBOX (w/o bootloader)"
mtd4: 00800000 00020000 "DreamBOX (w/ bootloader)"
mtd5: 003e0000 00020000 "DreamBOX SquashedFS"
mtd6: 00120000 00020000 "DreamBOX Cramfs"

I tried only to change a font in /share !!!

thanks

Devilfish
3rd January, 2009, 05:57 PM
If you want to add fonts, just upload them to /var/tuxbox/config/enigma/fonts

Adding a font would not cause the image to hang. Looking for a font that's not there would.

Are you sure you flash erased /dev/mtd/5 and not /dev/mtd/3?

ajeeb
3rd January, 2009, 06:01 PM
hi
I know that we can upload /var/tuxbox/config/enigma/fonts
but only case to test
about flash erased /dev/mtd/5 and not /dev/mtd/3
I do steps above if it cause the problem I will check that with older versions

/dev/mtd/3 - is bootloader then need jtag lol

Thanks @Devilfish

ajeeb
10th January, 2009, 06:11 PM
@Devilfish hi
maybe this cause the problem? to get it works?


root@dreambox:/tmp> tar -cf root.tar root
tar: Names longer than 100 chars not supported
tar: Names longer than 100 chars not supported.
tar: Names longer than 100 chars not supported.

br

mat989
19th January, 2009, 04:47 AM
Devil: I have some questions.

1. What is /dev/mtdblock/5? There is also /dev/mtdblock/6 in the rcS file.

2. If I am going to replace the "bild" file, does that mean i need to apply your method, but instead of mounting /dev/mtdblock/5 in read-only-mode, i shall mount /dev/mtdblock/6 ?

3. In summary what you did is this:

Dreambox: Backup the section you want to edit
Dreambox: Transfer the backup file to your linux box
Linux Box: Extract the backup file and edit the files
Linux Box: Generate the squashfs file and transfer the file to the dreambox
Linux Box: Replace the old section with the updated file and reboot the dreambox "How is this going to work? You are still in read-only mode?!! I shall try it first!"




thnx...

Devilfish
19th January, 2009, 03:09 PM
If you type more /proc/mtd it will show you the different memory locations on the dreambox.

mtd5 is the SquashFS section that we want to edit. This is all the folders that you see when you ftp to the box, except /var and /tmp.

So we extract mtd5 from the box, transfer it to our linux PC, edit it as you like and then recompile it back into an mtd5.img. Transfer the mtd5.img back to the box and flash it again. You are not flashing the complete image, only the mtd5 memory location. So now the complete image on the dreambox should have your edits.

In the DK images, the bild file is in /bin so you can easily edit it using this method.

@ajeeb, I completed that command without any problems on my dreambox. (see pic)

mat989
19th January, 2009, 03:22 PM
thnx...

I am using Gemini 4.6. The bild file is in the root file. root gets mounted at boot time to show the image , and then unmounted

mount -t cramfs /dev/mtdblock/6 /root -o loop
/bin/showlogo /root/root/platform/kernel/bild
umount /root


I tried to mount it rw but w/o success. I am using putty and winscp

Devilfish
19th January, 2009, 03:35 PM
Try backing up mtd6 instead of mtd5.

mat989
19th January, 2009, 03:40 PM
thnx... i am testing it at the moment...

i backed up mtd6 and i am currently editing the root

will get back to you with the results

mat989
19th January, 2009, 04:05 PM
hmmm... the box is dead! I am flashing back with DreamUP....

satman
19th January, 2009, 05:06 PM
hmmm... the box is dead! I am flashing back with DreamUP....


always get serial debug log so you have idea where you went wrong ;)
post results of a "cat < /proc/mtd" see what the mtd partitions mounted are after you reflash back the gemini.

regards

viper76
27th January, 2009, 01:10 PM
Hi
I have found a sloution for the blank screen or the dead box

after you have produce mtd5.img do a Factory reset on the db wait for the db to reboot do not load any thing to the box then ftp the mtd5.img to tmp telnet to the box and
cd /tmp && eraseall /dev/mtd/5 && cp mtd5.img /dev/mtd/5 && reboot

this should work in all images

Regards

Devilfish
27th January, 2009, 03:29 PM
Thanks for the information viper76. Hopefully will help others with problems.

baderh
28th January, 2009, 02:01 PM
i will try it today... will let you know

note: used to try it and black screen

baderh
28th January, 2009, 04:06 PM
It didnt work :( black screen again :(

ajeeb
28th January, 2009, 05:42 PM
not tested yet but thanks @VIPER76
as soon as possible !will test

thanks Devilfish for the gr8 topic

scruff1963
28th January, 2009, 05:47 PM
Not sure as I won't put gemini on my box (clone killer) but is'nt gemini a maxvar image ?

Not sure if this method works with maxvar images ? you could try specifying the blocksize with -b <blocksize> , I think the default is 65535
./mksquashfs -help
will give more info


Another thing to check is that you have the correct version of mksquashfs.

baderh
28th January, 2009, 07:10 PM
how to know which version i have to use? i used 2 versions and still same...

maybe as you said... i have to mention the size also... once i reach home i will give it a try....

drhg
29th January, 2009, 09:57 PM
how to know which version i have to use? i used 2 versions and still same...

maybe as you said... i have to mention the size also... once i reach home i will give it a try....

just use mksquashfs with lzma patch & all will be ok
note that all squashfs parts in the recent images need mksquashfs with lzma patch to be recompressed in right way ( pli needs mksquashfs 3 with lzma)
hope this help
cheers

drhg

exclusive2020
31st January, 2009, 01:37 PM
Devilfish hi

how i can extract all xxxx.img and compress this after edit enything
plase

redmarx
11th May, 2009, 04:21 PM
this method works with mtd0 too?

micromouse
21st May, 2009, 08:04 AM
22222222222222222222222222222222

PDApunch
30th May, 2009, 12:17 PM
Hi All

Perhaps the ones who got this to work could let us know which distro they are using and any additional software they installed on there x86 machine.

I couldn't get this to work with Slax 6.1.1 mounted on HDD which has squashfs-lzma 3.x support built in. I don't know how to check if the byte order patch has been built in to squashfs? PPC big endian, x86 little endian.

I did get a different solution working tho using the dreambox itself to put the image back together after editing.

1. On the dreambox mount an NFS share to your x86 machine.

2. Create a swap file, format it and turn on swap.

3. Put your tools and image you want edit in the mounted HDD.

4. Now you can open a complete image, edit it then pack it back together again.

Tools and scripts needed:

mkcramfs
mkdreamboxfs
mksquashfs
uncramfs
undreamboxfs

NOTE: The tools I have will not pack it as the same version of squashfs as the newest images, so the image will be slightly larger, but I can CONFIRM this works.

PS
This is not a tutorial, just a summary of what I did to edit an image. If there is much interest I will try and document more of what I did.

Best regards

badboy123
31st May, 2009, 06:50 PM
I followed the steps by devilfish using ubuntu 9.04...

I got upto "
./mksquashfs root mtd5.img -be
After putting in that command I got the following error:

bash: ./mksquashfs: No such file or directory

So I tried the above command without "./" at the begining of mksquashfs and it created the image...I then typed the following in telnet:

cd /tmp && eraseall /dev/mtd/5 && cp mtd5.img /dev/mtd/5 && reboot

It erased successfully but then gave the error:

cp: Write Error: No space left on device

I did not make many alterations...I also tried the above process without any changes but still got the above error...

Any suggestions on how to resolve this? Thanks

PDApunch
31st May, 2009, 07:31 PM
@badboy123

Try a reboot of the dreambox before you FTP mtd5.img back to the dreambox, lets us know how you get on.

badboy123
31st May, 2009, 07:52 PM
I tried rebooting before I uploaded the image but still the same issue...do you have any other suggestions?

Thanks

PDApunch
1st June, 2009, 12:12 AM
@badboy123

What is the size of your .img file?

badboy123
1st June, 2009, 09:47 AM
5.29 MB...This transfers across with no problems

duracell
1st June, 2009, 05:20 PM
Are you using mksquashfs from the the dreambox cdk?


/home/ubuntu/tuxbox-cvs/root/cdkflash/mksquashfs

badboy123
1st June, 2009, 07:55 PM
I wasnt using that mksquashfs...tried it with that and managed to sort it out...

Thanks.

Wizard1
27th June, 2009, 12:10 PM
Hi Guys

I too kept experiencing the blank screen issue after following the Devilfish Tut. I found that the problem was down to the wrong mksquashfs file. The one attatched works perfect for me. Put it on my Desktop (Ubuntu) along with the tuxbox-cvs & root directory. The ''./mksquashfs'' is a correct command. A big thanks to Devilfish for an excellent Tut. :congrats:

Regards

Wizard

Jeza67
23rd July, 2009, 09:54 PM
Ok...
Thx for tut...
I have one problem...
I want to implement OpenVPN in Gemini image.
I managed to do that on 500+ w.o. problem on Gemini 4.60
Now I want to do that on dm500.
Problem is that I need to put some libs in lib dir which is read-only.
libcrypto.so.0.9.7
liblzo.so.1
libssl.so.0.9.7
and tun.ko in /modules/net
When I put only liblzo.so.1 and tun.ko, everything is ok db reboots after flashing, but openvpn want start for some ssl problems.
I figure that problem is with two remaining libs libssl.so.0.9.7 and libcrypto.so.0.9.7 .
Then I try to put all 3 libs, flash it, but no joy...
Box do not want to reboot and blank screen.
Any suggestions?

Solved , work like charm!!!!

pentiumdb
6th January, 2010, 11:17 PM
Hello i have followed the tut but black screen, i'm using ubuntu 9.10 desktop and mksquashfs from tuxbox-cvs
I have tried it on Gemini 4.2 and Gemini 4.7

Has anyone a vmware linux image with all the working utilites ?

any other ideas?

Thanks

GuJack20
10th January, 2010, 10:21 PM
Hi Guys

I too kept experiencing the blank screen issue after following the Devilfish Tut. I found that the problem was down to the wrong mksquashfs file. The one attatched works perfect for me. Put it on my Desktop (Ubuntu) along with the tuxbox-cvs & root directory. The ''./mksquashfs'' is a correct command. A big thanks to Devilfish for an excellent Tut. :congrats:

Regards

Wizard

I don't know why but i can't download this file. Is there any other place where can i download it??

Thanks guys

Wizard1
11th January, 2010, 11:48 AM
Hi GuJack20

Try again, as I've uploaded it as rar & zip.

Regards

Wizard

GuJack20
11th January, 2010, 01:04 PM
Hi GuJack20

Try again, as I've uploaded it as rar & zip.

Regards

Wizard

Yeah...i downloaded it.

Thanks Wizard1

ajeeb
24th January, 2010, 03:06 AM
well much better to uncompress the complete image !!!
write the ROM area not good idea with gemini


br

digital-kaos
23rd February, 2010, 07:29 PM
Can this about method to edit the Read only parts be used for all dreambox's or is it only confined to the dm500 ?

peque
21st August, 2010, 07:14 AM
Well - I'm trying to update my busybox on a image (peterPan / gemini etc) I've used for seperate commands in shell - like arp nohup etc.

But each time I reboot my dm500 - it just goes into blanckscreen and nothing happends.
I've tried squash the file - with ArchLinux,Debian and the special mksquashfs file earlier in the thread.

I got no errors etc - so what can I do to make it work - reflashing the image. Is it possible to update busybox in another way ????
outprint from more /proc/mtd


dev: size erasesize name
mtd0: 00500000 00020000 "DreamBOX cramfs+squashfs"
mtd1: 002c0000 00020000 "DreamBOX jffs2"
mtd2: 00040000 00020000 "DreamBOX OpenBIOS"
mtd3: 007c0000 00020000 "DreamBOX (w/o bootloader)"
mtd4: 00800000 00020000 "DreamBOX (w/ bootloader)"
mtd5: 003e0000 00020000 "DreamBOX SquashedFS"
mtd6: 00120000 00020000 "DreamBOX Cramfs"

I've tried almost everything so what can I do - to upgraqde the busybox placed on the image!
tia
P

kegsie
8th March, 2011, 01:07 AM
For some reason my user name and password have changed on my dm800hd clone is there a way to get me back into the box without having to start again ftp comes back with a fault in the user name and password
Thanks

harrop106
11th April, 2011, 08:31 AM
hi
I know this is an old thread but its still very relevant. Thank you for the tutorials but i still seem to be having an issue with the blank screen after reboot. I know this seems to be an issue with the mksquhuashfs file and i have downloaded the file earlier in this post. When i try to run it i get denied although i think this has something to do withe the ttuxbox-cvs folder mentioned. I cant find this to put it on the desktop. Any chance someone could point me in the right direction.

Thanks

testubuntu
26th May, 2011, 01:09 PM
thanks! I will try this.

blackangel82
26th December, 2011, 12:30 AM
hi i try this method with edg nemesis 4.4 and gemini 4.7 and have black screen after erase and reboot :(

i use mksquashfs from debian squeeze maybe this is wrong ??

log mksquashfs after edit :

root@*****:/home/boss/nemesis# mksquashfs root mtd5.img -be -lzma
Parallel mksquashfs: Using 2 processors
Creating big endian 3.1 filesystem on mtd5.img, block size 131072.
lzmadic 131072
[================================================== ================================================== =========================================] 730/730 100%
Exportable Big endian filesystem, data block size 131072, compressed data, compressed metadata, compressed fragments, duplicates are removed
lzmadic 131072
Filesystem size 4845.15 Kbytes (4.73 Mbytes)
40.59% of uncompressed filesystem size (11936.32 Kbytes)
Inode table size 8874 bytes (8.67 Kbytes)
28.99% of uncompressed inode table size (30610 bytes)
Directory table size 9614 bytes (9.39 Kbytes)
59.39% of uncompressed directory table size (16189 bytes)
Number of duplicate files found 18
Number of inodes 975
Number of files 674
Number of fragments 36
Number of symbolic links 206
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 95
Number of uids 2
root (0)
boss (1000)
Number of gids 0


any sugestions ??

EDIT
attachment from this topic help me :)
http://www.digital-kaos.co.uk/forums/f70/editing-read-only-parts-image-1248/index3.html#post218934
What is a max size for mtd5 partition ??
BR
BlackAngel82

DontUseMe2011
28th December, 2011, 03:02 PM
5.29 MB...This transfers across with no problems
thanks! I will try this.

petrosza
7th January, 2012, 12:23 AM
hello to everyone!

it worked it for me.

Devilfish thanks, very good post.
---------
i think that the block size value is important in order to work...

on my pc, mksquash.... gave me...
Creating big endian 2.1 filesystem on mtd5.img, block size 65536.


and not :
eating big endian 3.1 filesystem on mtd5.img, block size 131072.

thank U

knifeparty
14th February, 2012, 05:13 PM
I would like to say THANK YOU MR Devilfish (http://www.digital-kaos.co.uk/forums/members/1-devilfish/), because i just got sucess trying to add libcrypto to lib folder after read you post.... thank youuuuuuu !