| |
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
|
|
|
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. |
| |
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
|
| |
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. |
| |
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
|
| |
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. |
| |
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
|
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |