Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 17 of 17
Thats just a great idea Dolda!! i think i will try to fix an image that first trys to mount a rootfilesystem from the repository-server and if that fails it ...
  1. #11
    Linux Engineer
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    796


    Thats just a great idea Dolda!! i think i will try to fix an image that first trys to mount a rootfilesystem from the repository-server and if that fails it goes over to the local rootfs.

    So your commands creating a roofilesystems, have i understand it correctly...

    Code:
    # Creating a blockspecial file so i can create a filessytem on it
    dd if=/dev/zero of=/tmp/initrd bs=1024 count=8000 
    
    # Creating the actual filesystem
    mke2fs /tmp/initrd 
    
    # Mounting the created filesystem as loopback so i can put files in it
    mount -o loop /tmp/initrd /mnt/initrd 
    
    # Copying the valid files in to the new filesystem..but which files do i need here for it to work??
    cp -a ~/initrd-template/* /mnt/initrd 
    
    # Umounting the tempfilesystem
    umount /mnt/initrd 
    
    # Zipping the filesystem with higest compresslevel..Why do we wont to gzip it??
    gzip -9 /tmp/initrd

    This will create and initrd**.img that i just can point to with lilo right??

    Thanks so far!
    Regards

    Andutt

  2. #12
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Basically... The dd command doesn't create a device file, it just creates a file with 8 MBs of zero bytes in it. The reason to gzip it... well, why not? =) Both LILO and GRUB has support for unzipping initrds, so if you make it smaller, it will take less time to load it from the HD, if not for any other reason.

    As for files to put an the initrd, that's always a bit tricky; creating a small root file system is almost a science in itself. First, if you don't want to copy a couple megs of shared libraries, you will need to create statically linked programs. Download the source for util-linux, and create a statically linked mount program, to be able to mount nfs filesystems. Then, either use nash to call it, or create a simple /linuxrc program yourself, something like this:
    Code:
    #include <stdio.h>
    #Include <unistd.h>
    #include <linux/unistd.h>
    #include <sys/wait.h>
    #include <sys/stat.h>
    #include <linux/reboot.h>
    
    #define HALT reboot&#40;LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, RB_HALT_SYSTEM, NULL&#41;
    
    int main&#40;void&#41;
    &#123;
        pid_t pid;
        int status;
    
        /* Or do this in advance be creating an empty directory as part of the filesystem */
        mkdir&#40;"/newroot", 0644&#41;;
        printf&#40;"Mounting root filesystem...\n"&#41;;
        if&#40;!&#40;pid = fork&#40;&#41;&#41;&#41;
        &#123;
            execl&#40;"/bin/mount", "/bin/mount", "-t", "nfs", "server&#58;/pseudo-root", "/newroot", NULL&#41;;
            exit&#40;127&#41;;
        &#125;
        waitpid&#40;pid, &status, 0&#41;;
        if&#40;status&#41;
        &#123;
            printf&#40;"Help! Couldn't mount newroot!\n"&#41;;
            HALT;
        &#125;
        /* You must have an /initrd directory in the new root */
        if&#40;pivot_root&#40;"/newroot", "/newroot/initrd"&#41;&#41;
        &#123;
            printf&#40;"Help! Couldn't pivot_root!\n"&#41;;
            HALT;
        &#125;
        chdir&#40;"/"&#41;;
        execl&#40;"/sbin/init", "/sbin/init", NULL&#41;;
        perror&#40;"/sbin/init"&#41;;
        HALT;
    &#125;
    Then compile it with static linkage.

  3. #13
    Linux Engineer
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    796
    Thanks..But cant i just do like for example mkbootdisk...copying the drivers that i need and just build a RAMdisk.
    Regards

    Andutt

  4. #14
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I don't know what mkbootdisk does, exactly, so I can't really answer that.

  5. #15
    Linux Engineer
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    796
    I have come along way but got stuck on one thing, maybe someone can help me out.

    I have now buildt a kernel and a special small rootfilesystem that i have sucessfully loaded in RAM instead to go down on disk, but the thing on buliding your own small root filesystem is like chrooting..its a bit messy.

    My problem is now when linux have loaded my kernel and mounted my rootfs in RAM, that kernel and linuxrc does and completes sucessfully but when the initprocess takes over and shall go to runlevel 2 and start mingetty tty1 to start my console so i can log on i get an error. The errormessage is

    INIT: id "1" respawning too fast: disabled for five minutes


    Which means that mingetty buggs out on something, i have maked sure that the binary exists and that inittab looks sane. I also maked sure with ldd that the libs that mingetty needs exists and that tty1 exist in the dev-catalog.

    Does anybody else have any idea how or where to look for more info, or how to get around this problem..??
    Regards

    Andutt

  6. #16
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I don't trust mingetty for a second. I've never got it to work at all (admittedly I haven't tried to hard either, but nonetheless), except when it's called from RH's init scripts. Try using a real getty instead, like agetty.

  7. #17
    Linux Engineer
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    796
    OK Thanks, i will try that and see if it works any better.
    Regards

    Andutt

Page 2 of 2 FirstFirst 1 2

Posting Permissions

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