LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Mounting boot/initrd.img (http://www.linuxquestions.org/questions/linux-software-2/mounting-boot-initrd-img-274749/)

Law1213 01-06-2005 06:29 PM

Mounting boot/initrd.img
 
Ok guys I need some help here. Im wanting to boot off my usb hard drive so I need to mount my initrd.img and add some usb modules. My problem....well, I cant get the damn initrd.img to mount even when trying the suggested mount commands from various sites.

I've tried the following and a few other variations:-

mkdir initrd
zcat boot/initrd.img > initrd.img
mount initrd.img initrd -o loop

and the mount command always seems to give me the following error:-

/dev/loop0: Invalid argument
mount: you must specify the filesystem type

I've tried specifying a few filesystems, not sure for certain if they are the right ones. People have told me that the command should just work and not ask for one. Any help you can give me on mounting this .img file would be helpful.

Thanks.

jailbait 01-06-2005 09:49 PM

"I've tried the following and a few other variations:-

mkdir initrd
zcat boot/initrd.img > initrd.img
mount initrd.img initrd -o loop

and the mount command always seems to give me the following error:-

/dev/loop0: Invalid argument
mount: you must specify the filesystem type"

You are using the mount command and the mount command is calling the losetup command. I suggest that you try splitting your command into a losetup command followed by a mount command. This is no more likely to work than the combined command but it may help you isolate where the error is.

losetup -d /dev/loop0
echo "$?"
mount /dev/loop0 initrd
echo "$?"

The echo commands will give you the return codes from the commands.

If you have problems with /dev/loop0 try /dev/loop1 etc. Maybe something is already using /dev/loop0.

-------------------
Steve Stites

Law1213 01-07-2005 12:17 PM

Ok I gave it a try and got the following results:-

root@chris-laptop boot]# losetup -d /dev/loop0
ioctl: LOOP_CLR_FD: No such device or address
[root@chris-laptop boot]# echo "$?"
1
[root@chris-laptop boot]# mount /dev/loop0 initrd
/dev/loop0: Invalid argument
mount: /dev/loop0: can't read superblock
[root@chris-laptop boot]# losetup -d /dev/loop1
ioctl: LOOP_CLR_FD: No such device or address
[root@chris-laptop boot]# mount /dev/loop1 initrd
/dev/loop1: Invalid argument
mount: /dev/loop1: can't read superblock

Thanks for the suggestion btw.

Not having much luck here, any more ideas would be most welcome. I have also tried using the slackware boot cd and using the console from there with the same errors, Im guessing Im missing something with the mount command. btw, does anyone know the actual parameter for the filesystem type when mounting a .img file so I can be sure that it is not the problem.

jailbait 01-07-2005 02:46 PM

"root@chris-laptop boot]# losetup -d /dev/loop0
ioctl: LOOP_CLR_FD: No such device or address"

Sounds like you are missing your loop devices. Check to see if /dev/loop0 through /dev/loop7 exist.

------------------------
Steve Stites

Law1213 01-07-2005 06:17 PM

/dev/loop0 to loop7 are listed

jailbait 01-07-2005 07:08 PM

"/dev/loop0 to loop7 are listed"

It is possible that your loop module was compiled as a loadable module. If the loop module is not loaded then you would probably get the error message that the loop device does not exist. Also in my previous test I may have had the file name and mount point backwards. Try this test:

lsmod
(look to see if loop is loaded)
modprobe loop
echo "$?"
lsmod
(look to see if loop is loaded)
(Then run the following commands regardless of whether modprobe worked because loop might be part of the bootable kernel instead of being loadable.)
losetup /dev/loop0 initrd.img
echo "$?"
mount /dev/loop0 initrd
echo "$?"


or you could try:
modprobe loop
echo "$?"
mount initrd initrd.img -o loop
echo "$?"

-----------------------------
Steve Stites

Law1213 01-08-2005 09:20 AM

Getting there
 
Hey,

You were right about the module not being loaded I managed to get the commands working as far as:-

lsmod
modprobe loop
echo "$?"
lsmod
losetup /dev/loop0 initrd.img (this worked successfully)

but it failed on mount /dev/loop0 initrd, with the error

[root@chris-laptop boot]# mount /dev/loop0 initrd
/dev/loop0: Invalid argument
mount: you must specify the filesystem type

I also tried the following:-

[root@chris-laptop boot]# modprobe loop
[root@chris-laptop boot]# echo "$?"
0
[root@chris-laptop boot]# mount initrd.img initrd -o loop
/dev/loop0: Invalid argument
mount: you must specify the filesystem type
[root@chris-laptop boot]# echo "$?"
32
[root@chris-laptop boot]#

Thanks for the help so far :D

btw I also tried the following site (its for handhelds but I believe the commands should still work) without success: http://www.handhelds.org/handhelds-faq/filesystems.html (might be useful for some ideas)

ValidiusMaximus 01-08-2005 10:36 AM

initrd kernels are the devil

jailbait 01-08-2005 06:28 PM

"but it failed on mount /dev/loop0 initrd, with the error

[root@chris-laptop boot]# mount /dev/loop0 initrd
/dev/loop0: Invalid argument
mount: you must specify the filesystem type"

As I said before I may have confused your initrd and intird.img. What losetup does is to set up a correspondence between a file system and a file. This way you can create a file system within an ordinary file. I think that you are using initrd as the file system name and initrd.img as the file name. (In previous posts I may have scrambled your usage of these names. Also I am assuming that you have these two files set up correctly.) The losetup command sets up initrd as a file system which can be referenced as wither /dev/loop0 or initrd. Then the mount command mounts the initrd file system on the initrd.img file. So assuming that I have the names straight then the following command sequence should work:

modprobe loop
losetup /dev/loop0 initrd
mount -t ext2 /dev/loop0 initrd.img

If this does not work then I think the next thing to explore is exactly what are initrd and initrd.img and how you set them up.

-----------------------
Steve Stites

Law1213 01-09-2005 08:54 AM

Woo I've done it
 
After getting fed up of trying to mount my initrd.img (and corrupting it :eek: oops) I used the mkinitrd command to generate a new initrd.img and added the modules I needed, still I plan on looking into figuring out how to mount this for the future, but right now I have a whole load of new problems I need to sort out :scratch:

Thanks alot for all your help :D

ErikEngerd 01-25-2005 03:37 PM

Hi,


I had the same problem that you had, but digging around a bit in the script /sbin/mkinitrd, I found the solution.

The reason you cannot mount the initrd image is because it is zipped.
If you do the following:

cp initrd myrd.gz
gunzip myrd.gz
mkdir /mnt/initrd
mount -t ext2 -oloop myrd /mnt/initrd

Then it works. Luckily, mkinitrd is just a shell script and not a binary file.

Cheers
Erik


All times are GMT -5. The time now is 09:17 PM.