You are not logged in.

#1 2017-10-06 19:16:04

nicolo
Banned
Registered: 2013-08-10
Posts: 90

[solved] edit .img file

To update bios on my machine, I download an iso file from manufacturer. Then using software geteltorito I extract an img file out of that, the reason being that I need to edit the content that is flashed in my bios due to some incompatibilities between newer firmwares and linux kernels. While on mac os I can easily mount and manipulate the img file, on Linux it seems I can only mount it with read privilege: is there a simple way out of this?

Last edited by nicolo (2017-10-06 21:05:55)

Offline

#2 2017-10-06 19:27:12

HalosGhost
Forum Fellow
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,097
Website

Re: [solved] edit .img file

How are you mounting the file now? In worst case, you could mount it read-only, copy the contents to a writeable location and reimage it.

All the best,

-HG

Offline

#3 2017-10-06 19:29:50

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [solved] edit .img file

It depends on the format of the .img file, can you post the output of...

file filename.img

No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#4 2017-10-06 19:33:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: [solved] edit .img file

That is almost certainly not an "img" file like you are using to on a mac (e.g., a mac-specific disk image) - that would make no sense for a firmware upgrade.  However a cpio archive (like the initramfs images) would make perfect sense, and cpio tools can readily work with that.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2017-10-06 20:07:17

nicolo
Banned
Registered: 2013-08-10
Posts: 90

Re: [solved] edit .img file

i was mounting it just by double clicking on it in gnome.

file n1cur16w-mod.img 
n1cur16w-mod.img: DOS/MBR boot sector; partition 1 : ID=0x4, active, start-CHS (0x0,1,1), end-CHS (0x16,63,32), startsector 32, 47072 sectors

indeed it's not a mac os related file, it's a thinkpad bios update.

Offline

#6 2017-10-06 20:19:15

HalosGhost
Forum Fellow
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,097
Website

Re: [solved] edit .img file

You will likely need to mount it manually with mount (or, perhaps just remount it read-write with mount) to get it writable.

All the best,

-HG

Offline

#7 2017-10-06 20:26:02

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: [solved] edit .img file

nicolo wrote:

using software geteltorito I extract an img file out of that, the reason being that I need to edit the content that is flashed in my bios due to some incompatibilities between newer firmwares and linux kernels.

What incompatibilities?  What do you need to change exactly?  What instructions are you following?

Offline

#8 2017-10-06 20:32:02

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: [solved] edit .img file

If the only way you'd even think to attempt to access the data in an img file is to double click on it in some gui, then please do not even think about trying to hand-modify your firmware.  It will likely end in unrecoverable disaster.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#9 2017-10-06 20:33:56

nicolo
Banned
Registered: 2013-08-10
Posts: 90

Re: [solved] edit .img file

this

sudo mkdir /tmp/test
sudo mount -o rw n1cur16w-mod.img /tmp/test
mount: /tmp/test: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.

is not working. what is the correct way?

incompatibilities: the bios update is both flashing the bios and the ec; this last firmware update does not work well with recent linux kernels, so i'm just substituting its .fl2 file with an older working one inside some folder in .img file.

Offline

#10 2017-10-06 20:36:41

nicolo
Banned
Registered: 2013-08-10
Posts: 90

Re: [solved] edit .img file

(thank you Trilby for your illuminating comments.)

Offline

#11 2017-10-06 20:41:13

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,874

Re: [solved] edit .img file

look up the mount manpage for "loop"

Offline

#12 2017-10-06 20:44:55

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: [solved] edit .img file

The output of file on n1cur16w-mod.img seems to indicate it is a bootloader not an archive.  Why are you trying to change the contents of the eltorito loader instead of using the same loader and change the contents of the ISO?

Offline

#13 2017-10-06 21:05:08

nicolo
Banned
Registered: 2013-08-10
Posts: 90

Re: [solved] edit .img file

thank you seth, indeed the command

mount -o loop,offset=16384 n1cur16w-mod.img /tmp/old/ 

run as root does the job, where 16384=32 x 512 and 32 i got in file output.

Last edited by nicolo (2017-10-06 21:06:23)

Offline

Board footer

Powered by FluxBB