Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a ramdisk.img file that I would like to change to ramdisk.cpio.gz, can I simply rename the file or do I have to go through the whole archiving process? If I need to go through the archiving process, can someone please tell me the steps required for the process.

share|improve this question

migrated from stackoverflow.com Feb 1 '11 at 17:33

This question came from our site for professional and enthusiast programmers.

3  
Changing a file extension does not change the contents of the file. Adding .gz to a file name does not magically create a gzip archive. StackOverflow is not the place to learn to use archive software, ask on superuser.com or just check the man page on your computer or do a Google search. – Dan Grossman Jan 31 '11 at 14:12

No, ramdisk.img is a complete filesystem. You'll need to

  1. Mount the .img in a directory, e.g.

    mkdir /mnt/ramdisk
    mount ramdisk.img /mnt/ramdisk
    

    You should now see files in /mnt/ramdisk. (You may need -o loop in the mount command - I can never remember when that's needed.)

  2. Build a new newc-format cpio archive from the contents of /mnt/ramdisk

    cd /mnt/ramdisk
    find . -print |cpio -H newc -o |gzip -9 > ~/ramdisk.cpio.gz
    
  3. Unmount / clean-up

    umount /mnt/ramdisk
    rm -rf /mnt/ramdisk
    

This is all off the top of my head so may contain silly errors. Hope it works!

share|improve this answer
    
Do I need to mount the ramdisk? The ramdisk is going to be used for an android platform – Hank Jan 31 '11 at 14:48
    
If the ramdisk.img is a filesystem image then you'll need to read the files off it somehow and mounting it is going to be the easiest way to do that - it's only temporary to access the files. I don't know if there's anything specific you'd need to do for Android though. – Rup Jan 31 '11 at 14:51
    
I ended up not needing to archive the file, but I did try your method and ran into the problem needing to know the file system type – Hank Jan 31 '11 at 17:13
    
Oh, OK - sorry about that. You can usually tell by file ramdisk.img, although if that works it's likely mount could autodetect it too. However from Googling now it's possible we mislead you: apparently some Android ramdisk.imgs really are ramdisk.cpio.gzs :-/ Sorry if that was the case - I'd no idea Android worked like that. ramdisk.img is usually an ext2 (or romfs I think) filesystem image. – Rup Jan 31 '11 at 17:29

You probably want to replace an initrd image, with an initramfs archive. There is a script in the kernel sources to do the second part. It is in scripts/gen_initramfs_list.sh. You might want to read this.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .