Results 1 to 7 of 7

Thread: HOWTO: Converting your minirt.gz from initRD to initRAMFS

  1. #1
    Member registered user
    Join Date
    Mar 2005
    Posts
    87

    HOWTO: Converting your minirt.gz from initRD to initRAMFS

    HOWTO: Converting your minirt.gz from initRD to initRAMFS

    Change Log:
    * Version 1.3 - Mon Aug 21, 2006
    Spelling corrections (Linuxgamer)

    * Version 1.2 - Thu Feb 23, 2006
    Ammended some grammar.

    * Version 1.1 - Tue Nov 29, 2005
    A little bit of clarification and restructuring.

    * Version 1.0 - Tue Nov 28, 2005
    Initial write

    Disclaimer:
    Always needed cause you just never know how people will interpret things. Please people, use this at your own risk. Whilst this method has and continues to work for me, I will not be held responsible for anything that might go wrong, due to an ommision or typo in this document. I too, like you, am human and do make mistakes.

    initRD vs initRAMFS:
    initRAMFS is, as it's described in the kernel documentation, 'a chunk of code that unpacks the compressed cpio image midway through the kernel boot process.' The files contained within that image are then used to populate the root filesystem. Initramfs is a part of a bigger concept called 'early-userspace'. It's described in detail in <kernel-sources>/Documentation/early-userspace/. The general idea is "if it can be kept out of the kernel, let it stay that way".

    I'm not going into any huge debate about the pros and cons of these two but one thing I will mention is that initRD is old generation and there are plans to supersede it. "With what?" you ask. Currently there are two options being looked at that I know of, one is yaird (name speaks for itself) and the other is initramfs (which I will be talking about here). If you want to know more try Google but for now there is a Debian comparison available at http://wiki.debian.org/InitrdReplacementOptions

    With initramfs you'll not notice any significant differences, in fact if you install it correctly, you should not notice any changes.

    Why?
    Simple really, firstly I was tired of upgrading the kernel and replacing the unionfs.ko module with the latest revision and getting all those out of space errors becuase it was to big to fit in minirt. Secondly, I've added the fbsplash patch, to to my distro and to get the live splash screen working required an initramfs image.

    Another benefit that comes out of it for me, is that I can edit my miniroot image at any time, and rebuild it with one line of code. There is no immediate size limitations and i'm all for making things easier and simpler.

    What are we going to replace/upgrade:
    From my experience, in short, the steps are:

    For the compressed filesystem (ie chroot environment, /source)
    1. Extract and mount the initrd miniroot
    2. Copy the files from the initrd to an initramfs working directory
    3. Add the init script
    4. Compress the initramfs miniroot

    Easy, huh ... let's get our fingers dirty.

    Extract and mount the miniroot
    Code:
    # cd /path/to/working/directory
    # mkdir miniroot-initrd
    # cp /path/to/minirt.gz .
    # gunzip minirt.gz
    # mount -o loop minirt miniroot-initrd
    Setup our initramfs working directory, copy and clean up
    Code:
    # mkdir miniroot-initramfs
    # cp -Rp miniroot-initrd/* miniroot-initramfs/
    # umount ./miniroot-initrd
    # rmdir ./miniroot-initrd
    Ensure initramfs requirements are met with init
    Code:
    # cd miniroot-initramfs
    # touch init
    # chmod +x init
    # vi init
    Note we are creating an init file in the root directory of the miniroot image. Unlike an initRD image that looks for /linuxrc an initRAMFS image looks for /init

    Add the following text and save
    Code:
    #!/static/ash
    /linuxrc
    exec /etc/init "$@" </dev/console >/dev/console 2>&1
    You'll notice that this init may look like the same one in /etc of your miniroot (alternatively you could move that init file from /etc to /, if it exists that is)

    Lastly we need to compress the miniroot environment to the minirt.gz that we know so well
    Code:
    # find . | cpio --quiet -o -H newc | gzip -9 > ../minirt.gz
    # cd ..
    And there you have it the one liner that takes your miniroot source tree and generates an initramfs image. Now everytime you have to replace a module or edit the linuxrc script you can just run the last command and get the most recent snapshot of your miniroot working directory. Supoib!!

    Closing:
    This HOWTO, like my others, will continue to evolve from any constructive feedback received. For now ... use it, abuse it, and let me know what you think.

  2. #2
    Junior Member
    Join Date
    Jan 2006
    Location
    Boston, USA
    Posts
    4

    how to unpack using cpio

    If you need to unpack minirt.gz after creating the cpio image - :
    Code:
    gzip minirt.gz
    cat minirt | (cpio -i -d -m; cpio -i -d -m)
    Perhaps there is a better way, but this seems to work

  3. #3
    Junior Member
    Join Date
    Dec 2005
    Posts
    4

    Re: how to unpack using cpio

    Quote Originally Posted by pracsec
    If you need to unpack minirt.gz after creating the cpio image - :
    Code:
    gzip minirt.gz
    cat minirt | (cpio -i -d -m; cpio -i -d -m)
    Perhaps there is a better way, but this seems to work
    Is that supposed to be 'gunzip minirt.gz' before that 'cat minirt'?

  4. #4
    Junior Member
    Join Date
    Jan 2006
    Location
    Boston, USA
    Posts
    4

    Re: how to unpack using cpio

    Quote Originally Posted by meatwad
    Quote Originally Posted by pracsec
    If you need to unpack minirt.gz after creating the cpio image - :
    Code:
    gzip minirt.gz
    cat minirt | (cpio -i -d -m; cpio -i -d -m)
    Perhaps there is a better way, but this seems to work
    Is that supposed to be 'gunzip minirt.gz' before that 'cat minirt'?
    Yes, typo.

  5. #5
    Senior Member registered user
    Join Date
    Apr 2004
    Location
    Finland
    Posts
    272

    Re: how to unpack using cpio

    [quote="meatwad"]
    Quote Originally Posted by pracsec
    If you need to unpack minirt.gz after creating the cpio image - :
    Your method seems too complicated for me, so this is how I do this:
    Code:
    gunzip minirt.gz
    cpio -i < minirt
    Now minirt is in the same directory as unpacked minirt - so you can delete it. Then do changes and repack directory to minirt.g as is told in this HOWTO:
    Code:
    find . | cpio --quiet -o -H newc | gzip -9 > ../minirt.gz
    Now you have your minirt.gz in parent directory but also those minirt files existing in the directory where you gzunzipped them for further use. Great!

    -tapsa-

  6. #6
    Senior Member registered user
    Join Date
    Apr 2004
    Location
    Finland
    Posts
    272
    Knoppix 5.0.1 seems to cause some extra problem if using mkinitramfs. Boot process fails in Starting udev hot-plug hardware detection.... It should reply 'started' but now it is 'failed'.

    I can bypass that by changing linuxrc:
    Code:
      # /dev is a special case, it is now normally handled via udev
    #  UNIONDEV=""
    #  case "$CMDLINE" in *noudev*) UNIONDEV="dev"; ;; esac
    #  for i in bin boot etc $UNIONDEV sbin var lib opt root usr; do # Move directories to unionfs
     for i in bin boot dev etc sbin var lib opt root usr; do # Move directories to unionfs
    As you can see that last line is from Knoppix 4.0.2 (or from Kanotix - don't remember) and I had to comment 'UNIONDEV' section out from new Knoppix 5.0.1's linuxrc.

    How could this be fixed? I don't find any better solution myself. I don't know exactly what this can cause but I noticed that Ctrl-O in Midnight Commander clears the screen in virtual consoles. It don't do that using original Knoppix 5.0.1's minirt.gz file with initrdfs.

    Should init file be modified? Now my init file is:
    Code:
    #!/static/ash
    /linuxrc
    exec /etc/init "$@" </dev/console >/dev/console 2>&1

  7. #7
    Member registered user
    Join Date
    Mar 2005
    Posts
    87
    It would appear that when udev is used in 5.0.1 then the /dev is not copied accross but rather entirely created dynamically during the bootup process. I don't think it is a problem of initRAMFS itself but something to do with the udev startup scripts.

    I'll download 5.0.1 and give it a go.

Similar Threads

  1. Udev fails if using initramfs when building minirt.gz
    By tr in forum Customising & Remastering
    Replies: 0
    Last Post: 04-25-2007, 08:29 PM
  2. converting avi files to mpeg?
    By turbine in forum General Support
    Replies: 2
    Last Post: 01-06-2006, 12:57 PM
  3. Converting RPM to DEB
    By Sabih in forum Hdd Install / Debian / Apt
    Replies: 2
    Last Post: 04-28-2005, 10:36 PM
  4. Converting german to english
    By chronictoker420 in forum General Support
    Replies: 7
    Last Post: 05-02-2004, 11:20 PM
  5. What is this initrd=/boot/initrd.gz
    By alex52 in forum Hdd Install / Debian / Apt
    Replies: 4
    Last Post: 02-01-2004, 06:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


HP ProLiant DL360 G9 Server | 2 x E5-2660V3 2.6Ghz | 64GB | 2 x 900GB SAS HDD picture

HP ProLiant DL360 G9 Server | 2 x E5-2660V3 2.6Ghz | 64GB | 2 x 900GB SAS HDD

$339.00



H261-Z61 2U 24SFF AMD Server 8x EPYC 7551 256-Cores 256GB RAM 8x25G NIC 2x2200W picture

H261-Z61 2U 24SFF AMD Server 8x EPYC 7551 256-Cores 256GB RAM 8x25G NIC 2x2200W

$2612.18



Dell PowerEdge R730 8 SFF 2x E5-2660 v4 28 Cores 128/256GB 0/3x 900GB 6Gbps H730 picture

Dell PowerEdge R730 8 SFF 2x E5-2660 v4 28 Cores 128/256GB 0/3x 900GB 6Gbps H730

$349.99



Supermicro 4U 36 Bay Storage Server 2.2Ghz 16-C 128GB 1x1280W Rails TrueNAS ZFS picture

Supermicro 4U 36 Bay Storage Server 2.2Ghz 16-C 128GB 1x1280W Rails TrueNAS ZFS

$716.98



Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 128GB RAM No HDD picture

Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 128GB RAM No HDD

$389.99



Dell PowerEdge R620 Server 2x E5-2660 v1 2.2GHz 16 Cores 256GB RAM 2x 300GB HDD picture

Dell PowerEdge R620 Server 2x E5-2660 v1 2.2GHz 16 Cores 256GB RAM 2x 300GB HDD

$79.19



HP Proliant DL360 Gen9 28 Core SFF Server 2X E5-2680 V4 16GB RAM P440ar No HDD picture

HP Proliant DL360 Gen9 28 Core SFF Server 2X E5-2680 V4 16GB RAM P440ar No HDD

$196.95



Dell PowerEdge R720XD Xeon E5-2680 V2 2.8GHz 20 Cores 256GB RAM 12x4TB picture

Dell PowerEdge R720XD Xeon E5-2680 V2 2.8GHz 20 Cores 256GB RAM 12x4TB

$510.00



1U Supermicro Server 10 Bay 2x Intel Xeon 3.3Ghz 8C 128GB RAM 480GB SSD 2x 10GBE picture

1U Supermicro Server 10 Bay 2x Intel Xeon 3.3Ghz 8C 128GB RAM 480GB SSD 2x 10GBE

$297.00



DELL R730XD Server 2x E5-2680v4 2.4GHz =28 Cores 128GB H730 4x 1.2TB SAS 4xRJ45 picture

DELL R730XD Server 2x E5-2680v4 2.4GHz =28 Cores 128GB H730 4x 1.2TB SAS 4xRJ45

$504.00