LinuxQuestions.org
Visit Jeremy's Blog.
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 07-29-2012, 12:03 AM   #1
redhat828
LQ Newbie
 
Registered: Jul 2012
Location: Delhi
Distribution: RHEL 6
Posts: 4

Rep: Reputation: Disabled
Lightbulb How to open .img file


Hello Everybody,
How to see the content of .img file (initrd.img)and how to open this file?
 
Old 07-29-2012, 01:37 AM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,090

Rep: Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474
initrd.img

good thing you clarified this a bit
The *.img 's i am used to are photos from the "Planetary Data System "

a fairly generic guide
-- for the Android phone , but....
http://android-dls.com/wiki/index.ph...ck_Boot_Images

as to your need ????
What operating system is this for?
the icon under your name "is MS Windows7 "
 
Old 07-29-2012, 02:06 AM   #3
vonbiber
Member
 
Registered: Apr 2009
Distribution: slackware 14.1 64-bit, slackware 14.2 64-bit, SystemRescueCD
Posts: 441

Rep: Reputation: 90
sometimes initrd.img is a compressed file (generally gzipped) and
the uncompressed file could be a cpio archive or a (an ext2) filesystem
To find out the type, run this command
Code:
file initrd.img
if it's a gzipped file, run
Code:
zcat initrd.img > /tmp/initrd.img
then run
Code:
file /tmp/initrd.img
If it's a cpio archive you can extract it with cpio, if it's
an ext2 filesystem you need to mount it (with the option -o loop)
You'll probably to run this as root
1st case, it's a cpio archive, then
Code:
mkdir /tmp/initrd_img
cd /tmp/initrd_img
zcat <path_to_your_initrd.img> | cpio -iumdv
Here, you should repace <path_to_your_initrd.img> by the path to your file
(e.g., if it's in your home directory, it could be ~/initrd.img)

In the second case, you just run (as root) on the uncompressed file
Code:
mkdir -p /mnt/tmp
mount -o loop initrd.img /mnt/tmp
 
Old 07-29-2012, 12:28 PM   #4
heinblöd
Member
 
Registered: May 2004
Location: France
Distribution: Slackware Gentoo
Posts: 186

Rep: Reputation: 31
A initrd.img is usually an "initial ramdisk" which is used during the boot of your computer, if the kernel is missing the modules (drivers) needed for your hardware.

You would create it after compiling a new Kernel and it's modules with
Code:
mkinitrd
Here is the man page http://linux.die.net/man/8/mkinitrd
Quote:
mkinitrd - creates initial ramdisk images for preloading modules

Last edited by heinblöd; 07-29-2012 at 02:05 PM.
 
Old 07-29-2012, 02:02 PM   #5
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Here's a script I once wrote to decompress InitRD files. It might work for you. By default, if the InitRD is in /boot, the script will create a sub-directory of /boot with the name of the InitRD file you unpacked as its name, and the contents of the image file inside that directory. The script will not execute if you are not running with an effective user id or zero (i.e., root).
Code:
#!/bin/bash
############################################################################################
#
# Decompress initial ram disk image files
#
# Arguments: [ directory [ output ]]
#
# Where directory is the location of the InitRD files (default: /boot)
# and   output    is the sub-directory of "directory" where
#                 the unpacked files should be stored.
#
# Note: Each image file will be unpacked into a sub-directory of "output" named with
#       the name of the image file being unpacked.
#
###########################################################################################
#
# Make sure we're running as root
if [ $(id -u) -ne 0 ]
then
  echo "FATAL: This program requires root access. Aborting." >/dev/stderr
  exit 1
fi
# Set the defaults
boot="/boot"            # Boot directory
dir="Initial_RAM_Disk"  # Subdirectory of $boot into which the scripts should be decompresed
# Are there any arguments?
if [ $# -gt 0 ]
then
  if [ -d "${1}" ]
  then
    boot="${1}"
  else
    echo \"$1\" is not a valid directory name.
    exit 1
  fi
fi
if [ x"$(pwd)" != x"$boot" ]
then
  echo cd ${boot}
  cd ${boot}
fi
# Is an output directory specified?
if [ $# -gt 1 ]
then
  if [ -d "${2}" ]
  then
    dir="${2}"
  else
    echo \"$2\" is not a valid directory name.
    exit 1
  fi
fi
# Create the output directory if it doesn't exist
[ -d "${dir}" ] || sudo mkdir "${dir}"
# Go to the output directory
cd "${dir}"
# Get the InitRD image file to be used
echo Enter the number corresponding to the image file you want expanded
select img in $(ls -1 ../*.img*) quit
do
  if [ ${img} == "quit" ]
  then
     break
  else
    out=$(basename ${img})
    echo "out="${out}
    echo "img="${img}
    mkdir -p "${out}"
    cd "${out}"
    gunzip -c "../${img}" | sudo cpio -idmv
    cd ../
  fi
done
 
Old 07-29-2012, 03:32 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 16,357

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
I think everyone is right about what could be done but we still need to know more about this intrid.img file. What does the OP think it should be or where did he get it from?

I too think he was talking about a initial disk, generally compressed but we almost never tend to call it an .img file.
 
Old 07-29-2012, 06:21 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,090

Rep: Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474
from the OP's other post about red hat rpms and yum
and the red hat icon under the name in that post
http://www.linuxquestions.org/questi...ry-4175419230/

but from this and that post ?????
Who knows ,seeing as there is very little in the way of usable information in the two .
 
  


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
convert an ISO file into an IMG file chris6686 Linux - Newbie 6 12-04-2011 08:11 PM
[SOLVED] Mounting .img file (chromiumos.img); can't mount it?? Help please? linus72 Linux - General 2 11-27-2009 08:11 PM
how to convert a .iso file to .img file mobquest Linux - Newbie 1 07-10-2009 04:59 AM
Add new cciss driver module to initrd.img ,stage2.img kunalroy2002 Linux - Software 4 09-25-2007 12:09 AM
open *.img file?? tricky_linux Linux - Software 2 04-27-2004 01:56 PM


All times are GMT -5. The time now is 08:33 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