Re: getting linux to mount a FAT16 part at boot time so I can giveit an initrd path?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jan> So you have two options. Either make your bootloader load it (it
Jan> should be able to if it knows about "multiboot specification") or
Jan> turn the FAT16 partition into kind of initrd - the pivot_root
Jan> syscall is not limited to be used from ramdisk.

OK, I'm going for option two.  I think it is perfect.  I'm having
trouble with my pivot_root.  I've included my program below.  This is
a cleaned-up version of the program, the original did a whole bunch of
error checking to confirm that the open, ioctl, close, mount, chdir,
and pivot_root calls don't return errors.  The kernel prints:

  EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
  GOT HEREKernel panic: Attempted to kill init!

What's up with that?
Thanks,
Dave

/**
***	linuxrc.c:   Mount /initrd.bin loopback as cramfs and pivot_root to it
***
***	Usage:
***		vmlinux init=linuxrc
***
***	David Wuertele		Tue May 20 16:14:35 2003
***
**/

#include <fcntl.h>
#include <stdio.h>

#include <linux/posix_types.h>
#undef dev_t
#define dev_t __kernel_dev_t
#include <linux/loop.h>
#undef dev_t

int
main (int argc, char *const argv[])
{
  struct loop_info loopinfo;
  int fd, ffd;

  ffd = open ("/initrd.bin", O_RDWR);
  fd = open ("/dev/loop/0", O_RDWR);

  memset (&loopinfo, 0, sizeof(loopinfo));
  strncpy (loopinfo.lo_name, "/initrd.bin", LO_NAME_SIZE);
  loopinfo.lo_offset = 0;
  loopinfo.lo_encrypt_key_size = 0;
  ioctl (fd, LOOP_SET_FD, ffd);
  ioctl (fd, LOOP_SET_STATUS, &loopinfo);
  close (fd);
  close (ffd);

  mount ("/dev/loop/0", "/mnt", "ext2", 0, NULL);
  chdir ("/mnt");
  pivot_root ("/mnt", "/mnt/tmproot");

  fprintf (stderr, "GOT HERE\n");

  execv ("/sbin/init", argv);
  return 0;
}

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux