LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This 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


Reply
  Search this Thread
Old 12-13-2011, 08:04 AM   #1
nivwusquorum
LQ Newbie
 
Registered: Dec 2011
Posts: 14

Rep: Reputation: Disabled
Booting LFS on separate USB HDD + separate /boot parition


Hi,

I have just finished my first LFS. I keep all the files on separate usb hdd (I only have one internal and one external hdd, listed as sda and sdb respectively in my host system).
I have separate swap, boot and home partitions. I gave priority to external hdd's in bios. When I try to boot my system, grub loads fine, but when I select lfs entry I get:

Quote:
error: no kernel specified
error: unknown command '/boot/vmlinux-3.1-lf
Anybody have some ideas how to fix this? I already tried changing root= in grub.cfg to different letter, but it does not work. Thanks very much for any help!!

Below is output of some commands that you might ask for:
  • ls -ls /boot
    Code:
    config-3.1  grub  lost+found  System.map-3.1  vmlinuz-3.1-lfs-7.0
  • cat /etc/fstab
    Code:
    # Begin /etc/fstab
    
    # file system  mount-point  type   options         dump  fsck
    #                                                        order
    
    /dev/sdb4      /            ext4   defaults        1     1
    /dev/sdb2      swap         swap   pri=1           0     0
    /dev/sdb1      /boot        ext4   defaults        0     0
    /dev/sdb5      /home        ext4   defaults        0     0
    proc           /proc        proc   defaults        0     0
    sysfs          /sys         sysfs  defaults        0     0
    devpts         /dev/pts     devpts gid=4,mode=620  0     0
    tmpfs          /run         tmpfs  defaults        0     0
    # End /etc/fstab
  • cat /boot/grub/grub.cfg
    Code:
    # Begin /boot/grub/grub.cfg
    set default=0
    set timeout=5
    insmod ext2
    set root=(hd2,1)
    menuentry "GNU/Linux, Linux 3.1-lfs-7.0" {
    linux
    /boot/vmlinuz-3.1-lfs-7.0 root=/dev/sdb1 ro
    }
  • command I use for mounting
    Code:
    function lfsmount {
            if [ $1 == "" ]; then
                    echo "Usage lfsmount <disk>"
            else
                    sudo mount -v /dev/$11 $LFS/boot &&
                    sudo mount -v /dev/$15 $LFS/home &&
                    sudo mount -v --bind /dev $LFS/dev &&
                    sudo mount -vt devpts devpts $LFS/dev/pts &&
                    sudo mount -vt tmpfs shm $LFS/dev/shm &&
                    sudo mount -vt proc proc $LFS/proc &&
                    sudo mount -vt sysfs sysfs $LFS/sys
            fi
    }
  • cat device.map
    Code:
    cat device.map
    (hd0)	/dev/disk/by-id/mmc-SD04G_0x0c69194c
    (hd1)	/dev/disk/by-id/ata-TOSHIBA_MK3252GSX_88IFP1XAT
    (hd2)	/dev/disk/by-id/usb-TOSHIBA_USB_2.5_-HDD_000a9945-0:0

Last edited by nivwusquorum; 12-14-2011 at 11:27 AM. Reason: solved + more accurate topic
 
Old 12-13-2011, 11:48 AM   #2
Bertical
Member
 
Registered: Oct 2008
Location: Kingdom of Mercia
Distribution: Slackware
Posts: 83

Rep: Reputation: 14
Looks like you've broken a one line command into two.

Code:
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5
insmod ext2
set root=(hd2,1)
menuentry "GNU/Linux, Linux 3.1-lfs-7.0" {
linux
/boot/vmlinuz-3.1-lfs-7.0 root=/dev/sdb1 ro
}
Should be

Code:
linux /boot/vmlinuz-3.1-lfs-7.0 root=/dev/sdb1 ro
 
Old 12-13-2011, 12:22 PM   #3
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Have you loaded grub on the usb drive hd2 or in the hd0,If it is all on the usb hd2 then you need to. Set root to hd0,1 and try adding root delay.
Code:
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5
insmod ext2
set root=(hd2,1)
menuentry "GNU/Linux, Linux 3.1-lfs-7.0" {
linux
/boot/vmlinuz-3.1-lfs-7.0 root=/dev/sdb1 ro
}
Code:
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5
insmod ext2
set root=(hd0,1)
menuentry "GNU/Linux, Linux 3.1-lfs-7.0" {
linux /boot/vmlinuz-3.1-lfs-7.0 root=/dev/sdb1 rootdelay=10 ro
}
The reason for the root delay is to give usb time to be recognized and load
 
Old 12-13-2011, 12:44 PM   #4
nivwusquorum
LQ Newbie
 
Registered: Dec 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thanks for both answers. Both of this things were an issue and I fixed them now.

@spiky0011 Why is it the case that I have to change hd2 to hd0? Device map outputs hd2 fo my usb hdd on which I have both grub and the system. Besides following that reasoning shouldn't I change /dev/sdb to /dev/sdX for some other X? If yes how determine which one? Is my thinking correct that the order can be random, so I should add some udev rules?

Second issue is that unfortunately this still doesn't work grub say's it's booting, but then it outputs, really helpful error:
Quote:
error: file not found
 
Old 12-13-2011, 12:49 PM   #5
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Am i correct you have set grub on the usb when it boots it,s then hd0 as this is the drive loading.
 
Old 12-13-2011, 12:56 PM   #6
nivwusquorum
LQ Newbie
 
Registered: Dec 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
To make it perfectly clear

I have (naming from my host system):
/dev/sdb4 which corresponds to /
/dev/sdb1 which corresponds /boot
I made /dev/sdb1 bootable and installed grub on it. I also have another grub on my main harddrive, but it does not matter LFS is completely separate from that and my main hard drive is not used. I posted output of cat device.map generated by grub while chrooted into LFS on my host system in my first post.

Thanks
 
Old 12-13-2011, 01:01 PM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

If the hd that holds a complete independent LFS installation, including grub and this hd is seen during start as your primary boot device it will be seen as sda, not sdb.

As pointed out by spiky, you should adjust you grub.cfg and fstab file accordingly. It might be wise to looking into using UUID's instead of device names (UUID's are unique, devices name are not) wherever possible.

Hope this helps.
 
Old 12-13-2011, 01:02 PM   #8
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
That is how mine is setup I boot lfs from sdb1 grub installed in sdb1 /boot.
As you mentioned it dose matter where the usb gets loaded if it switches to hd1 then it wont boot,
The usb is it an external harddrive or a pendrive/memory stick?
 
Old 12-13-2011, 01:03 PM   #9
nivwusquorum
LQ Newbie
 
Registered: Dec 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
@druuna: Thank you very much for your answer. Is it possible to use UUID's in grub and fstab. I was trying to google this kind of solution, because it seems much better, but I couldn't find anything.

@spiky: it is external harddrive.

Last edited by nivwusquorum; 12-13-2011 at 01:07 PM.
 
Old 12-13-2011, 01:12 PM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,
Quote:
Originally Posted by nivwusquorum View Post
@druuna: Thank you very much for your answer. Is it possible to use UUID's in grub and fstab. I was trying to google this kind of solution, because it seems much better, but I couldn't find anything.
UUID's can be used for mounting (fstab): Linux by examples - fstab with uuid (search with fstab uuid and get a ton of hits)

And although I never tried using UUID's and grub myself, have a look at this LQ thhread: [SOLVED] how to use UUID on fstab and grub

Hope this helps.
 
Old 12-13-2011, 01:17 PM   #11
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Just a note mine wont boot if there is a pendrive in a strange quirk
 
Old 12-13-2011, 01:42 PM   #12
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Just another thing when I boot fromm 2nd drive I use F12 which which shows all harddrives to boot they must be in the correct order I,E sdb must be 2nd harddrive inlist, if it,s the 3rd position it wont boot

example
HD0 ubuntu
cd drive
lan
HD1 lfs7
HD2 lfs 6.7
if lfs7 and lfs 6.7 swap places they wont boot
 
Old 12-13-2011, 01:57 PM   #13
nivwusquorum
LQ Newbie
 
Registered: Dec 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
I did some experiments and reached some conclusions:
1. I removed all /dev/sdX rubbish from fstab and grub.cfg to do this we replace /dev/sdX with UUID=<DEVICE_UUID> in fstab and by /dev/disk/by-uuid/<DEVICE_UUID> in grub.cfg.
2. (hdX,Y) is also dependant on hardware you have plugged in. For example in my case if I have memory card inserted i get different number for harddrives that if I didn't have it.

As now I am using UUIDs everywhere, the thing the might be wrong is (hdX,Y). Launched grub and typed ls in grub console. The output I got is:
Code:
(hd0) (hd0,msdos5) (hd0,msdos4) (hd0,msdos2) (hd0,msdos1) (hd1) (hd1,msdos7) (hd1,msdos6) (hd1,msdos4) (hd1,msdos2) (hd1,msdos1)
As my external usb hdd (the one with LFS) has exactly 5 partitions and internal excactly 7 I deduced that hd0 is the disk I am looking for. Also I noticed grub is adding this weird msdos prefixes, so finally I deduced that correct value must be:
(hd0,msdos1)!

After a brief moment of excitement I got:
Quote:
error: file not found
I am gradually starting to think that us government is involved.
 
Old 12-13-2011, 02:23 PM   #14
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
I didn,t have to do that this is my grub.cfg
Code:
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5
set gfxpayload=795


insmod ext2
set root=(hd0,1)

menuentry "Planet-Spike7" {
        linux   /boot/vmlinuz-3.1-lfs-7.0 root=/dev/sdb1 rootdelay=10 ro
}
This boots, it did need the root delay
 
Old 12-13-2011, 02:43 PM   #15
nivwusquorum
LQ Newbie
 
Registered: Dec 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
Well it does not work for me. Small question - do I have to reexectute any grub related commands when updating grub.cfg and fstab? And are my /boot directory contents ok (in the first post)? Thanks very much for all answers!
 
  


Reply

Tags
boot, disks, grub, lfs



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
Suse 11 - problem with booting from external HDD orangina Linux - Newbie 28 10-01-2011 02:38 PM
never used cfdisk before, small HDD as well. ejames82 Linux - Newbie 4 08-12-2009 11:38 AM
Booting problem on HDD addition having ext3 partitions. learner786 Linux - Newbie 6 04-07-2009 08:44 AM
booting machine with linux on an external HDD without HDD connected drsoum Linux - Newbie 2 07-22-2007 03:47 AM
Damn Small Linux...booting problem dip_xp3 Linux - General 2 11-28-2006 06:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 05:51 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
Open Source Consulting | Domain Registration