LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 08-09-2006, 08:28 PM   #1
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 49
changing contents of initrd image


Hi, I have an initrd image for my Debian 2.6.13 kernel and I wanted to modify a file in the initrd. I know how to view the contents but I don't know what I have to do in order to change it because it mounts the initrd image as a READ-ONLY filesystem.

Here is what I did:

Code:
root@debian:~# file -z /boot/initrd.img-2.6.13 /boot/initrd.img-2.6.13: Linux Compressed ROM File System data, little endian size 1372160 version #2 sorted_dirs CRC 0x30bc9195, edition 0, 879 blocks, 123 files
root@debian:~#
Looks like my initrd image is cramfs type. so next I tried accessing the contents by following this website's instruction http://www.ducea.com/2006/06/24/insp...n-initrd-file/ :
Code:
# All work is done in a temporary directory
mkdir /tmp/initrdmount
# Mount the image file directly
mount -o loop /boot/initrd.img-2.6.13 /tmp/initrdmount
#Investigate its content, etc.
cd /tmp/initrdmount
#Once done un-mount it:
umount /tmp/initrdmount
Ok I was able to mount it and I could see the contents also:
Code:
root@debian:~# ls /tmp/initrdmount/
bin   dev2   keyscripts  linuxrc.conf  proc    scripts  usr
bin2  devfs  lib         loadmodules   sbin    sys      var
dev   etc    linuxrc     mnt           script  tmp
root@debian:~#
Everything is fine till now(atleast it appears), but now when I tried to create a file in the initrd, I got the following message:
Code:
root@debian:/tmp/initrdmount# touch test
touch: cannot touch `test': Read-only file system
root@debian:/tmp/initrdmount#
Is there any way I can mount it as read-write file system? Also what will be the steps (in summary) once I am able to modify the files inside initrd, to get my new initrd image going.

THanks
 
Old 08-09-2006, 10:31 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
I've not found anything in the mount man page that states read-only is the default unless otherwise specified. But, that seems to be the case. So, add -w to the mount command to specify read-write.

# Mount the image file directly
mount -w -o loop /boot/initrd.img-2.6.13 /tmp/initrdmount
 
Old 08-10-2006, 04:29 AM   #3
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by bigrigdriver
I've not found anything in the mount man page that states read-only is the default unless otherwise specified. But, that seems to be the case. So, add -w to the mount command to specify read-write.

# Mount the image file directly
mount -w -o loop /boot/initrd.img-2.6.13 /tmp/initrdmount
Alright I will try that and let you know how did it go.

Thanks for the help anyways.
 
Old 08-10-2006, 04:50 PM   #4
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by bigrigdriver
I've not found anything in the mount man page that states read-only is the default unless otherwise specified. But, that seems to be the case. So, add -w to the mount command to specify read-write.

# Mount the image file directly
mount -w -o loop /boot/initrd.img-2.6.13 /tmp/initrdmount

Nopes it didn't work. Here is what I tried:
Code:
root@debian:/tmp/initrdmount# mount -w -o loop /boot/initrd.img-2.6.13 /tmp/initrdmount/
Code:
root@debian:/tmp/initrdmount# ls bin   dev2   keyscripts  linuxrc.conf  proc    scripts  usr
bin2  devfs  lib         loadmodules   sbin    sys      var
dev   etc    linuxrc     mnt           script  tmp
root@debian:/tmp/initrdmount#
To confirm my worst fear:

Code:
root@debian:/tmp/initrdmount# touch test
touch: cannot touch `test': Read-only file system
root@debian:/tmp/initrdmount#
What could be the problem? Also I don't know if this output helps or not which I already posted in my first post:

Code:
root@debian:~# file -z /boot/initrd.img-2.6.13 /boot/initrd.img-2.6.13:
Linux Compressed ROM File System data,
little endian size 1372160 version #2
sorted_dirs CRC 0x30bc9195, edition 0, 879 blocks, 123 files
root@debian:~#
I just found out some more information about cramfstype. Since my initrd image is cramfstype, it can be only mounted as Rad-Only and I guess that's what the output of file -z is showing to us.

Any more ideas?

Last edited by kushalkoolwal; 08-10-2006 at 04:57 PM.
 
Old 08-10-2006, 09:05 PM   #5
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
The only other thing I can come up with after googling for the last half hour is cramfsprogs. These utilities permit making and extracting a cramfs initrd. I assume that, if you can extract it, you can then edit files then re-make the initrd.
 
  


Reply



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
Make new initrd image qewldude Fedora - Installation 3 02-15-2008 09:56 AM
Maximum size of initrd image ?? PeteRossi Slackware 5 03-26-2007 09:30 AM
loading modules with an Initrd image? komuthan Slackware 4 12-07-2005 12:17 AM
Creating custom initrd image in suse 9.1 Anmol SUSE / openSUSE 1 01-08-2005 02:31 AM
What's initrd image? Nerox Linux - Newbie 2 08-25-2004 04:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 11:09 AM.

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
Open Source Consulting | Domain Registration