LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 03-19-2007, 10:59 AM   #1
Armane
LQ Newbie
 
Registered: Mar 2007
Posts: 24

Rep: Reputation: 15
Installation of kernel of a debootstrap


Hello!

I have a problem with creating a new system that is going to be the base system of an embedded core. Now i want to make a full working OS with gcc ect to build the code ect. = full_OS

After i have built this full_OS i will make a stripped one for the embedded flashdrive but i cant install the kernel on the full_OS.

This is what i have done and i dont know what is wrong with the installation of the kernel. I figured out that it cant find the hda1 in /dev/. Which isnt there. But how shall i install the Kernel?

This system will be stripped with ldd command and copied to a flashmemory that will be used as a bootable harddrive in a embedded robotsystem.



Tutorial:

....

root@mattias-laptop:/# mkdir /full_OS
root@mattias-laptop:/# debootstrap --arch i386 sarge /full_os/ http://ftp.se.debian.org/debian/
root@mattias-laptop:/# mkdir /stripped_OS
// Sda is my flash memory
root@mattias-laptop:/# umount /dev/sda1
root@mattias-laptop:/# fdisk /dev/sda

Fresh partition:
Delete all partion on flash using d command in fdisk
Create one partion on flash using n command in fdisk
Create linux filesystem on flash using t (83) command in fdisk
Set bootable flag on flash partion using a command in fdisk on partion u created (1)

root@mattias-laptop:/# mke2fs -j /dev/sda1
root@mattias-laptop:/# cd /full_OS/etc/
root@mattias-laptop:/full_OS/etc/# emacs fstab

// ---------------------------------------

/dev/hda1 / auto auto 0 0
proc /proc proc auto 0 0

// Save and close

root@mattias-laptop:/full_OS/etc/# mkdir /full_OS/boot/grub
root@mattias-laptop:/full_OS/etc/# cp /boot/grub/* /full_OS/boot/grub/
root@mattias-laptop:/full_OS/etc/# cd /full_OS/grub/
root@mattias-laptop:/full_OS/etc/# emacs menu.lst

// ---------------------------------------

default 0
timeout 10

title Robot OS
root (hd0,1)
kernel /boot/vmlinuz-2.6.8-3-386 root=/dev/hda1 ro quiet splash
initrd /boot/initrd.img-2.6.8-386
quiet
savedefault
boot

// ---------------------------------------

root@mattias-laptop:/full_OS/etc/# chroot /full_OS
root@mattias-laptop:/full_OS/etc/# mount -a
root@mattias-laptop:/full_OS/etc/# apt-get install kernel-image-2.6.8-3-386

This is were my problem occures!

/usr/sbin/mkinitrd: device /dev/hda1 is not a block device
Failed to create initrd image.
dpkg: error processing kernel-image-2.6.8-3-386 (--configure):
subprocess post-installation script returned error exit status 9
Errors were encountered while processing:
kernel-image-2.6.8-3-386
E: Sub-process /usr/bin/dpkg returned an error code (1)

-----------------

Any suggestions or advice would be strongly appriated!

Ps. Hope you all get what iam after Ds.
 
Old 03-19-2007, 11:05 AM   #2
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
Before the chroot, add this line to /etc/fstab
Quote:
/dev /full_OS/dev none bind 0 0
mount /full_OS/dev

then go on
chroot /full_OS
 
Old 03-19-2007, 11:07 AM   #3
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
By the way, this line:

/proc /full_OS/proc proc defaults 0 0

could help also before the chroot.

With these two lines you will have /full_OS/proc and /full_OS/dev point to the real /proc and /dev
 
Old 03-19-2007, 03:18 PM   #4
Armane
LQ Newbie
 
Registered: Mar 2007
Posts: 24

Original Poster
Rep: Reputation: 15
Thanks for the reply

i will try that tomorrow and tell u how it went.

Regards
Mattias
 
Old 03-20-2007, 04:44 AM   #5
Armane
LQ Newbie
 
Registered: Mar 2007
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by nx5000
Before the chroot, add this line to /etc/fstab

mount /full_OS/dev

then go on
chroot /full_OS
You mean that i should use the fstab in my current workshell, ubuntu?

Because when i chroot into /full_OS it wont know about the map /full_OS/ because ur inside it.

Quote:
Originally Posted by nx5000
By the way, this line:

/proc /full_OS/proc proc defaults 0 0

could help also before the chroot.

With these two lines you will have /full_OS/proc and /full_OS/dev point to the real /proc and /dev
Same here..

Ill try and give u the results.
 
Old 03-20-2007, 05:52 AM   #6
Armane
LQ Newbie
 
Registered: Mar 2007
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Armane
You mean that i should use the fstab in my current workshell, ubuntu?

Because when i chroot into /full_OS it wont know about the map /full_OS/ because ur inside it.



Same here..

Ill try and give u the results.
Same as before ... Feels like its not possible to install a kernel image inside a debootstrap folder while chrooted into it..

Anyone have any suggestions?

Best regards
Mattias

Ps. If anyone else have any tips on how to make a clean debian system with all funktion required to boot from it if copied to a partion/flash/usb ect. I know that u have to conigure the system for diffrent media but a guide or tutorial would really help. Ds.
 
Old 03-20-2007, 06:32 AM   #7
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
Quote:
Same as before ... Feels like its not possible to install a kernel image inside a debootstrap folder while chrooted into it..
Yes sure it's possible.

You said "same as before" but I don't think that's correct because now when you chroot, you do have /dev/hda1 ?
And then the error message shouldn't be "/usr/sbin/mkinitrd: device /dev/hda1 is not a block device" ?

Is it really on /dev/hda1 that you want to install it? (I didn't read all your post, I have not so much time)
 
Old 03-20-2007, 06:49 AM   #8
Armane
LQ Newbie
 
Registered: Mar 2007
Posts: 24

Original Poster
Rep: Reputation: 15
Hiya!

Ok .. think i have messed things up abit..

Ill explain again:

I want to create a sandbox enviorment for the creating of all code for the robot ect. Like a protected envioremnt that doesnt depend on my working shell, ubuntu in this case.

So i do a debootstrap of debian to full_OS and chroot into my created sandbox and install all the neccessary things for compiling code ect. No need to make full_OS bootable with kernel and grub ect.

Now when everythin is working in full_OS i want to create a minimal bootable system for my flashdisk. This is were i have missunderstood the installation of the kernel.

Now i shall mount, lets say, sda1 that is my created flashpartion to stripped_OS and make it bootable with a script that copies all the necessary files from full_OS to stripped_OS.

Think its here i was doing my misstake .. i tried to install a kernel on a chroot enviorment that had no / root..

I suppose the kernel installation has to have a root for creating the initrd image.. As the error stated in my first post it couldn't find sda1 because it wasnt availabel in full_OS/dev as it wasnt mounted to anything.

Hope you understand what i mean ..

Ill post my results after ive tried this.

Best regards
Mattias
 
Old 03-20-2007, 07:19 AM   #9
Armane
LQ Newbie
 
Registered: Mar 2007
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by nx5000
Yes sure it's possible.

You said "same as before" but I don't think that's correct because now when you chroot, you do have /dev/hda1 ?
And then the error message shouldn't be "/usr/sbin/mkinitrd: device /dev/hda1 is not a block device" ?

Is it really on /dev/hda1 that you want to install it? (I didn't read all your post, I have not so much time)
Inside ubuntu(not chrooted):

Quote:
root@mattias-laptop:/# mount
/dev/hda2 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.17-11-generic/volatile type tmpfs (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sda1 on /stripped_OS type ext3 (rw)
/proc on /stripped_OS/proc type none (rw,bind)
/sys on /stripped_OS/sys type none (rw,bind)
root@mattias-laptop:/#
This is whats mounted in ubuntu and when iam chrooted into stripped _OS this is mounted:

Quote:
root@mattias-laptop:/# chroot stripped_OS/
root@mattias-laptop:/# ls
bin dev home lib mnt proc sbin sys usr
boot etc initrd media opt root srv tmp var
root@mattias-laptop:/# cd dev
root@mattias-laptop:/dev# ls
MAKEDEV dsp1 loop4 midi1 port ram13 ram8 smpte1
agpgart dsp2 loop5 midi2 ppp ram14 ram9 smpte2
audio dsp3 loop6 midi3 ptmx ram15 random smpte3
audio1 full loop7 mixer pts ram16 rmidi0 sndstat
audio2 initctl mem mixer1 ram ram2 rmidi1 tty
audio3 kmem midi0 mixer2 ram0 ram3 rmidi2 tty0
audioctl loop0 midi00 mixer3 ram1 ram4 rmidi3 urandom
console loop1 midi01 mpu401data ram10 ram5 sequencer xconsole
core loop2 midi02 mpu401stat ram11 ram6 shm zero
dsp loop3 midi03 null ram12 ram7 smpte0
root@mattias-laptop:/dev# mount
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
none on /proc type proc (rw)
none on /proc type proc (rw)
none on /proc type proc (rw)
none on /proc type proc (rw)
none on /proc type proc (rw)
root@mattias-laptop:/dev#
I dont have /dev/sda1 in chroot enviorment =( I posted it as hda1 before but thats wrong =)

Quote:
root@mattias-laptop:/dev# cd ..
root@mattias-laptop:/# cd etc/mkinitrd/
root@mattias-laptop:/etc/mkinitrd# cat mkinitrd.conf
# /etc/mkinitrd/mkinitrd.conf:
# Configuration file for mkinitrd(8). See mkinitrd.conf(5).
#
# This file is meant to be parsed as a shell script.

# What modules to install.
MODULES=most

# The length (in seconds) of the startup delay during which linuxrc may be
# interrupted.
DELAY=0

# If this is set to probe mkinitrd will try to figure out what's needed to
# mount the root file system. This is equivalent to the old PROBE=on setting.
ROOT=/dev/sda1

# This controls the permission of the resulting initrd image.
UMASK=022

# Command to generate the initrd image.
MKIMAGE='mkcramfs %s %s > /dev/null'

# Set this to yes if you want to use busybox(1).
BUSYBOX=no

# Set this to no if you want to disable /usr/share/initrd-tools/scripts.
PKGSCRIPTS=yes

# This is the value for LD_LIBRARY_PATH when deciding what goes onto the
# image.
INITRD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH

# Hardcode partition to resume from so it doesn't have to be specified
# on the command line. The command line will override this setting.
# RESUME=
root@mattias-laptop:/etc/mkinitrd#
I changed the root=probe to root=/dev/sda1 in mkinitrd.conf also. But got the same error while installing the kernel.

Quote:
/usr/sbin/mkinitrd: device /dev/sda1 is not a block device
Failed to create initrd image.
dpkg: error processing kernel-image-2.6.8-3-386 (--configure):
subprocess post-installation script returned error exit status 9
Errors were encountered while processing:
kernel-image-2.6.8-3-386
E: Sub-process /usr/bin/dpkg returned an error code (1)
Seems like it cant get a hold of sda1.

Hope i gave u some information that can help.

Best regards
Mattias
 
Old 03-20-2007, 07:37 AM   #10
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
Quote:
root@mattias-laptop:/# mount
/dev/hda2 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.17-11-generic/volatile type tmpfs (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sda1 on /stripped_OS type ext3 (rw)
/proc on /stripped_OS/proc type none (rw,bind)
/sys on /stripped_OS/sys type none (rw,bind)
root@mattias-laptop:/#

Hummmm in ubuntu, did you put this in /etc/fstab:

/dev /stripped_OS/dev none bind 0 0
/proc /stripped_OS/proc none bind 0 0

and then
mount /stripped_OS/dev
mount /stripped_OS/proc
Check with
mount
that /stripped_OS/dev is mounted
AND only then, chroot
/stripped_OS/dev will be an exact copy of /dev. I hope you understand the concept and maybe if there is an error in my post, you will get to what you want.

Because currently your /stripped_OS/dev has been created by debootstrap with MAKEDEV generic and sda1 is not created. Anohter possibility would be in the chroot to launch MAKEDEV sda1 but prefer the mount bind first.

Last edited by nx5000; 03-20-2007 at 07:38 AM.
 
Old 03-20-2007, 08:00 AM   #11
Armane
LQ Newbie
 
Registered: Mar 2007
Posts: 24

Original Poster
Rep: Reputation: 15
Yes!

Thanks nx5000 .. i was able to install the kernel now =)

Ill post a complete guide what i did later on today!

Best regards
Mattias
 
Old 03-21-2007, 09:25 AM   #12
Armane
LQ Newbie
 
Registered: Mar 2007
Posts: 24

Original Poster
Rep: Reputation: 15
Back again!

Ok, i will now post all the commands to building my new system.

Feels like iam doing things in the wrong order =(

You guys might come with som suggestions!?

Iam not sure if the the grub command is right because when i boot to the usb-flash-hd the grub menu from my ubuntu menu.lst is showing up. I want it to use the one on my flashdisk. And the kernel is killed after a while. Something like -> Kernel alert = killing init is prompted and the system locks up.

Added this to my ubuntu mnu.lst for testing:

title Other operating systems:
title ------------------------
root

title Robot OS
root (hd0,0)
kernel /boot/vmlinuz-2.6.8-3-386 root=/dev/hda1 ro single
initrd /boot/initrd.img-2.6.8-3-386
boot

This is what i get when i execute the last command in my guide.

root@mattias-laptop:/# grub-install --root-directory=/stripped_OS/ --no-floppy /dev/sda
Installation finished. No error reported.
This is the contents of the device map /stripped_OS//boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(fd0) /dev/fd0
(hd0) /dev/hda
(hd1) /dev/sda

This might be an error that is from when i install the kernel .. I get prompted to fix the bootloader when i install the kernel.

This is the exact command i use:

-------------------------------------------------------------------------------------------------

root@mattias-laptop:/# sudo -s
root@mattias-laptop:/# umount /dev/sda1
root@mattias-laptop:/# fdisk /dev/sda

Fresh partition:
Delete all partion on the flashdisk using d command in fdisk
Create one partion on the flashdisk using n,p,1,[enter],[enter] command in fdisk
Set bootable flag on flash partion using a,1 command in fdisk
Write the partion to the flash with w

root@mattias-laptop:/# umount /dev/sda1
root@mattias-laptop:/# mke2fs -j /dev/sda1
root@mattias-laptop:/# mkdir /full_OS
root@mattias-laptop:/# apt-get install debootstrap
root@mattias-laptop:/# debootstrap --arch i386 sarge /full_OS/ http://ftp.se.debian.org/debian/
root@mattias-laptop:/# cd /full_OS/etc/
root@mattias-laptop:/full_OS/etc/# gedit fstab

// ---------------------------------------



/dev/hda1 / ext3 auto 0 0

proc /proc proc auto 0 0

// Save and close

root@mattias-laptop:/full_OS/etc/# cd /etc
root@mattias-laptop:/etc/# gedit fstab

// ---------------------------------------



... add these below:

/dev /full_OS/dev none bind 0 0
/proc /full_OS/proc none bind 0 0

// Save and close

root@mattias-laptop:/etc/# mkdir /full_OS/boot/grub
root@mattias-laptop:/etc/# cp /boot/grub/* /full_OS/boot/grub/
root@mattias-laptop:/etc/# cd /full_OS/boot/grub/
root@mattias-laptop:/full_OS/boot/grub/# gedit menu.lst

// ---------------------------------------

default 0

title Robot OS
root (hd0,0)
kernel /boot/vmlinuz-2.6.8-3-386 root=/dev/hda1 ro quiet splash
initrd /boot/initrd.img-2.6.8-386
quiet
savedefault
boot

// Save and close

root@mattias-laptop:/full_OS/boot/grub/# mount -a
root@mattias-laptop:/full_OS/boot/grub/# chroot /full_OS
root@mattias-laptop:/# apt-get install kernel-image-2.6.8-3-386 // Here i get a question about lilo.conf
root@mattias-laptop:/# exit
root@mattias-laptop:/full_OS/boot/grub/# cd /full_OS/etc/mkinitrd/
root@mattias-laptop:/full_OS/etc/mkinitrd/# gedit mkinitrd.conf

// ---------------------------------------

ROOT=/dev/sda1

// Save and close

root@mattias-laptop:/full_OS/etc/mkinitrd/# umount /full_OS/proc
root@mattias-laptop:/full_OS/etc/mkinitrd/# umount /full_OS/dev
root@mattias-laptop:/full_OS/etc/mkinitrd/# mkdir /stripped_OS
root@mattias-laptop:/full_OS/etc/mkinitrd/# mount /dev/sda1 /stripped_OS/
root@mattias-laptop:/full_OS/etc/mkinitrd/# cp -r /full_OS/* /stripped_OS/
root@mattias-laptop:/full_OS/etc/mkinitrd/# grub-install --root-directory=/stripped_OS/ --no-floppy /dev/sda

-------------------------------------------------------------------------------------------------
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Debootstrap warning Tylerious Debian 3 01-26-2006 05:28 AM
direct installation from network?debootstrap? heleen Debian 1 04-28-2005 08:19 PM
debian installation failed: debootstrap/functions no such file or directory lixy Linux - General 1 01-25-2005 05:55 PM
debootstrap troubles archlyric Debian 9 11-26-2004 03:57 PM
Debootstrap Error pmconway Debian 0 10-14-2004 12:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 01:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration