Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Newbie > How can i create a bootable img??

Forgot Password?
 Linux Newbie   If you're new to the wonderful world of Linux, start here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 08-11-2003   #11 (permalink)
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
andutt is offline  


Reply With Quote
Old 08-11-2003   #12 (permalink)
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(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, RB_HALT_SYSTEM, NULL)

int main(void)
{
    pid_t pid;
    int status;

    /* Or do this in advance be creating an empty directory as part of the filesystem */
    mkdir("/newroot", 0644);
    printf("Mounting root filesystem...\n");
    if(!(pid = fork()))
    {
        execl("/bin/mount", "/bin/mount", "-t", "nfs", "server:/pseudo-root", "/newroot", NULL);
        exit(127);
    }
    waitpid(pid, &status, 0);
    if(status)
    {
        printf("Help! Couldn't mount newroot!\n");
        HALT;
    }
    /* You must have an /initrd directory in the new root */
    if(pivot_root("/newroot", "/newroot/initrd"))
    {
        printf("Help! Couldn't pivot_root!\n");
        HALT;
    }
    chdir("/");
    execl("/sbin/init", "/sbin/init", NULL);
    perror("/sbin/init");
    HALT;
}
Then compile it with static linkage.
Dolda2000 is offline   Reply With Quote
Old 08-12-2003   #13 (permalink)
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
andutt is offline   Reply With Quote
Old 08-12-2003   #14 (permalink)
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.
Dolda2000 is offline   Reply With Quote
Old 08-15-2003   #15 (permalink)
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
andutt is offline   Reply With Quote
Old 08-15-2003   #16 (permalink)
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.
Dolda2000 is offline   Reply With Quote
Old 08-16-2003   #17 (permalink)
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
andutt is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 11:07 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2