Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've successfully compiled LFS onto a usb drive (as far as I can tell with no errors) and now when I try to boot into the usb drive I get nothing. I've tried to add a manual entry to my host system's GRUB (v.97) and it says that it couldn't mount the partition GRUB error 17.
I've also tried to use this plop boot manager to boot into the USB, but when I try to it just freezes;the keyboard does not work and the screen is stuck on the plop boot manager main screen. I have to power down to recover from this.
I don't seem to get any other errors so I'm stuck as to what is going wrong here.
Here's some info:
(sdb is my usb device)
/dev/sdb1 -> /boot
/dev/sdb2 -> swap
/dev/sdb3 -> /
In fdisk all the partitions show up with id 83. I know sdb1 and sdb3 are ext3 as I did the proper mkfs.ext3 to them in the beginning.
### BEGIN /etc/grub.d/10_linux ###
menuentry "GNU/Linux, with Linux 2.6.37-lfs-6.8" --class gnu-linux --class gnu --class os {
insmod ext2
set root='(hd1,1)'
search --no-floppy --fs-uuid --set 6d76e32e-d827-4990-a4f0-2fece319ec43
echo Loading Linux 2.6.37-lfs-6.8 ...
linux /vmlinux-2.6.37-lfs-6.8 root=/dev/sdb3 ro
}
menuentry "GNU/Linux, with Linux 2.6.37-lfs-6.8 (recovery mode)" --class gnu-linux --class gnu --class os {
insmod ext2
set root='(hd1,1)'
search --no-floppy --fs-uuid --set 6d76e32e-d827-4990-a4f0-2fece319ec43
echo Loading Linux 2.6.37-lfs-6.8 ...
linux /vmlinux-2.6.37-lfs-6.8 root=/dev/sdb3 ro single
}
### END /etc/grub.d/10_linux ###
I am 99% sure that the relevant USB drivers and SCSI drivers are built into the kernel not as modules. I can give the .config file but that is quite large so I'm leaving it out.
What's going on?
Additionally, I ran this boot info script from sourceforge, it outputted this
=> Grub2 (v1.97-1.98) is installed in the MBR of /dev/sdb and looks at sector
1 of the same hard drive for core.img. core.img is at this location and
looks in partition 1 for /grub.
So I think that means that GRUB is installed and is finding things to an extent within my usb drive.
Also, when I try doing the step in 8.4.3 of the V-6.8 LFS book to test my GRUB configuration, I get nowhere. In my host system, which is running legacy GRUB, I type "root (hd1,1)" in grub and it says unknown Filesystem, partition type 0x83. Then if I try to do the kernel line it says cannot mount partition.
Is there some kind of log file maybe that would give more info on any other errors that might help diagnose this problem?
Last edited by unitedfollowers; 08-07-2011 at 04:54 PM.
So I formatted the USB drive, and started over with LFS from chapter 6. This time I only used two partitions:
/dev/sdb1 --> /
/dev/sdb2 --> swap
I made my new fstab accordingly. I've gotten all the way back to the point I was with my first try. Then when I tried to use GRUB to boot into the USB drive with the root as (hd1,1) I got the same error as before. Then I changed it to (hd1,0) to see what would happen and I got somewhere. Then I got a kernel panic.
Code:
VFS: Unable to mount root fs via NFS, trying floppy
VFS: Cannot open root device "sdb1" or unknown block (2,0)
Please eppend a correct "root=" boot option here are available partitions:
0800 sda driver:sd
0801 sda1
0802 sda2
0803 sda3
0b00 sr0 driver:sr
kernel panic - not syncing, unable to mount root fs on unknown block (2,0)
My Legacy GRUB menu.lst looks like this for LFS:
Code:
title LFS
root (hd1,0)
kernel /boot/vmlinux-2.6.37-lfs-6.8 root=/dev/sdb1 ro
I've looked around on these forums and seen other's problems with kernel panic. They've tried things like changed the sd to hd but I've tried the root line with sdb1,sdb,and hdb1 with no result. I know sdb1 IS ext3 and I know the kernel has ext3 compatibility built in.
It seems that it really does not like my partition for some reason.
Also something that is perplexing me, GRUB seems to consider (hd1,0) ext2fs and hd1,1 as unknown. This is strange as hd1,1 (or sdb1) is ext3 by cfdisk and other utilites. I also have ext2 build into the kernel.
Any tips?
Last edited by unitedfollowers; 08-13-2011 at 03:16 PM.
Are you sure you need to use sdb in your configuration files?
I've never created or used a bootable USB device, but looking at the info you posted it looks like it is picked up as sda (which sounds kinda logical):
Code:
.
Please eppend a correct "root=" boot option here are available partitions:
0800 sda driver:sd
0801 sda1
0802 sda2
0803 sda3
.
With root still as (1,0), I've changed the GRUB root line to use sda1, sda2, and sda3. This confirmed my suspicion that these partitions were of my host system's hard-drive, and not of the USB, as sda1 was reported as NTFS (my windows partition), sda2 as unknown (as it was the LVM), and sda3 as the /boot for my fedora system. That was a good thought though, but still I only made two partitions on the USB drive that filled up the entire capacity so there was no way it could have been sda with three partitions.
I did change the fstab accordingly when I used the sda partitions.
Maybe I did something wrong when I set up the USB device?
First I unmounted the USB storage (as its automounted upon detection) and then ran fdisk on /dev/sdb (my USB device). Here I created two primary partitions, one 3GB sized, and the other approx. 0.7GB. I then made sure that both were type 83 (a linux partition) and then made the 3GB partition bootable.
I then wrote the changes and left fdisk.
At this point the 3GB partition is the / and the .7 is for the swap.
Next, I used mke2fs -jv /dev/sdb1 (I also used mkfs.ext3 /dev/sdb1 on a previous attempt). Both gave no errors and completed themselves. Then I used mkswap on /dev/sdb2. No error there.
Finally, I mounted /dev/sdb1 to /mnt/lfs and followed the book to get to the point where I am now and also used swapon on /dev/sdb2.
I'm starting to guess my USB drive is one of those that just don't work with this type of thing. Strange thing though, as I've used this universal USB installer from pendrivelinux and put Ubuntu on this same USB device before and gotten it to be able to boot (though it stopped working a couple boots after).
A further thing, when I verify the partition table in fdisk on /dev/sdb currently it gives me this:
Code:
Partition 1: previous sectors 6293503 disagrees with total 6289728
Partitions 2: cylinder 1018 greater than maximum 1017
Partition 2: previous sectors 7823295 disagrees with total 7820134
Remaining 2047 unallocated 512-byte sectors
I haven't played with partitions since I originally used fdisk to set the device up in the beginning. Maybe this is where the partitions problems are arising due to weird allocation of the sectors? (just shooting in the dark here, I have no real idea what the above means)
Last edited by unitedfollowers; 08-14-2011 at 08:03 PM.
As I stated in one of my previous replies, I never tried to make a bootable USB device.....
If I do a quick search on creating a bootable USB device I do notice that it isn't as simple as installing an OS and setting up a bootloader (grub in this case). For one your BIOS must be able to handle this (which it probably does, you do mention running Ubuntu from an USB device). And I do believe you need to create an image that is put on the USB device.
Finally got somewhere I believe, three weeks later (I've been busy so...) So I think I found out that the fdisk verify errors I got were a factor on why LFS on bootup detected my sdb partition as unknown. I think the problem was that the partition allocations didn't match up to the cylinder and cylinders designated to one partition ran into the next, resulting in a messed up boot up process. So I redid my partitions with Gparted and aligned to cylinders, and now on LFS boot up I get further, I think. I still get a kernel panic, but at least now the list of available partitions shows my sdb1 and sdb2 (/ and swap respectively) partitions. I also get a ton more output to the boot up screen, talking about USB devices (keyboard and mouse) and talking about the USB mass storage device that holds LFS. However, I'm still getting kernel panics; When supplied with root=/dev/sdb1 and root as (1,0) it can't mount the rootfs or block (2,0). What I don't get is why its saying block 2,0...I'm on 1,X am I not? Or is this something else?
I've also seen that others have posted about LFS and USB sticks. The two summaries I've deduced is to make a bootable image like druuna linked to or make an initrd and pass it to GRUB (there was one poster that said he got LFS to work on a USB but the key part was getting the initrd right).
I'd like to give making an initrd a try, as the image is mostly read only with write operations complicating the matter.
So I've looked into what it takes to make an initrd, and it seems similar to an image in that it encompasses a copy of your system. But I am stuck on how to create the initrd. I've read that there's scripts available but you need to compile Busybox to make the scripts work, which I'm not so sure is necessary. Is there a way to make an initrd without busybox-related scripts?
I'd like to give making an initrd a try, as the image is mostly read only with write operations complicating the matter.
So I've looked into what it takes to make an initrd, and it seems similar to an image in that it encompasses a copy of your system. But I am stuck on how to create the initrd. I've read that there's scripts available but you need to compile Busybox to make the scripts work, which I'm not so sure is necessary. Is there a way to make an initrd without busybox-related scripts?
This doesn't seem to be LFS specific and I would suggest you post a new thread which contains this in Linux - General to get the exposure it deserves.
Hope this helps.
PS: There is a LFS hint about initrd, but it does use busybox: initrd for LFS
Ehm, just idea, have you tried to add "rootdelay=nn" as your kernel parameter into your boot loader? "nn" is number in seconds. It will delay your boot just when it about to reach root filesystem root pivoting/mounting.
I read many times that distros like Tiny core use that trick to allow Linux kernel USB subsystem to completely finish USB initialization before proceeding into loading Linux (in this, tiny core is installed in USB flash disk)
I have finally managed to get into my LFS system on my USB stick thanks to the help of posters! It turns out the last piece I needed was to add rootdelay=10 to the kernel line in GRUB to allow the USB stick to settle and initialize and it worked! Thanks for your time in helping me out! I just have a linux console fail error which I can resolve rather quickly.
Just as a recap...
My first problem was that when I used fdisk the partitions didn't align to the cylinder so one partition ran into another. This is probably what caused my partition to be unknown during bootup time. This maybe just relevant to my USB stick.
The second problem was that I needed to add rootdelay to the kernel line in GRUB so that the USB drive could settle and thus the rootfs could then be found.
Also, in my case, my fstab needed to be sdb and not sda as even when I booted into LFS it still saw sda as my host system's hdd and sdb as my USB stick LFS drive.
This was done without images or an initrd.
Special Thanks to mulyadi for saving from going to extra lengths to get my system to boot!
Last edited by unitedfollowers; 09-06-2011 at 11:09 PM.
Glad you made it Well sometimes we could borrow knowledge from other distros....and sometimes that could be very valuable.
Regarding device name, I suggest to use label or UUID instead of names like "sda". That way, no matter how your storages are configured, it would be the same. AFAIK, to support block name laballing, you would need blkid. There could be more.....
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.