LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Make LFS bootable (https://www.linuxquestions.org/questions/linux-from-scratch-13/make-lfs-bootable-4175578795/)

avanish321 05-01-2016 10:43 PM

Make LFS bootable
 
1 Attachment(s)
Hi All,

I have currently setup LFS ( LFS 7.9 ) with custom modules and all looks fine so far. But needed assistance in making it bootable.

Since I am running it in a virtual machine ( OpenSuse 13.2 ), I can break, crash , restore n number of times.

I am unable to make it boot.
Goal here is to boot the machine, and have grub give me an option to boot into LFS and actual host installation ( dual boot ).

Quote:

linux-upri:/boot/grub2 # fdisk -l ( AS seen on host machine )

Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0007fcd0

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 2248703 2246656 1.1G 82 Linux swap / Solaris
/dev/sda2 * 2248704 23230463 20981760 10G 83 Linux
/dev/sda3 23230464 41943039 18712576 8.9G 83 Linux

Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00021b05

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 4196351 4194304 2G 82 Linux swap / Solaris
/dev/sdb2 * 4196352 35653631 31457280 15G 83 Linux
Here, sdb2 is where I have built LFS.


fstab ( as seen when logged into chroot )

Quote:

oot:/etc# cat fstab
# Begin /etc/fstab

# file system mount-point type options dump fsck
# order

/dev/sdb2 / ext4 defaults 1 1
/dev/sdb1 swap swap pri=1 0 0
proc /proc proc nosuid,noexec,nodev 0 0
sysfs /sys sysfs nosuid,noexec,nodev 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /run tmpfs defaults 0 0
devtmpfs /dev devtmpfs mode=0755,nosuid 0 0

# End /etc/fstab


root:/# cat /boot/grub/grub.cfg
Quote:

# Begin /boot/grub/grub.cfg
set default=0
set timeout=5

insmod ext2
set root=(hd1,2)

menuentry "GNU/Linux, Linux 4.4.2-lfs-7.9" {
linux /boot/vmlinuz-4.4.2-lfs-7.9 root=/dev/sdb2 ro
}
root:/#
Grub has been installed on /dev/sdb


So, the problem with this is, I dont have menu entry during boot to choose the lfs installation.

I have tried booting into HD2 directly but it gives error as shown in attachment.

weibullguy 05-01-2016 11:09 PM

When in your chroot, is vmlinuz-4.4.2-lfs-7.9 in /boot?

avanish321 05-01-2016 11:14 PM

yes

Quote:

root:/boot# ls -la
total 9436
drwxr-xr-x 3 root root 4096 May 2 07:49 .
drwxr-xr-x 23 root root 4096 Apr 29 23:08 ..
-rw-r--r-- 1 root root 102905 May 2 07:38 config-4.4.2
drwxr-xr-x 5 root root 4096 May 2 07:51 grub
-rw-r--r-- 1 root root 3370294 May 2 07:38 System.map-4.4.2
-rw-r--r-- 1 root root 6168992 May 2 07:38 vmlinuz-4.4.2-lfs-7.9

avanish321 05-01-2016 11:27 PM

Probably booting directly into HD2 will not work because of the way how fstab has been updated ( guessing ). So my main goal as of now is to update the entry of lfs so that when I reboot, I get to choose Opensuse + LFS .

weibullguy 05-01-2016 11:30 PM

OpenSUSE is installed on /dev/sda in the vm? Presumably, grub was installed on /dev/sda when you installed OpenSUSE and /dev/sda is probably the default boot device. Thus, you would need to add the menu entry to the grub.cfg on /dev/sda2.

avanish321 05-01-2016 11:58 PM

Quote:

Originally Posted by weibullguy (Post 5539304)
OpenSUSE is installed on /dev/sda in the vm? Presumably, grub was installed on /dev/sda when you installed OpenSUSE and /dev/sda is probably the default boot device. Thus, you would need to add the menu entry to the grub.cfg on /dev/sda2.

Yes, you are right, Opensuse is installed on /dev/sda and this is the default boot device.

I managed to update the entry by following method


edit this file on opensuse : /etc/grub.d/40_custom
with

menuentry "GNU/Linux, Linux 4.4.2-avanish-7.9" {
savedefault
insmod ext2
set root='(hd1,2)'
linux /boot/vmlinuz-4.4.2-lfs-7.9 root=/dev/sdb2 ro
}

and run this command as root.

grub2-mkconfig -o /boot/grub/grub.cfg

By doing this, I was able to get the entry updated in grub. But ended up with another error. This time kernel panic when booting into LFS.

VFS: unable to mount root fs on unknown block(0,0)
Any idea whhat went wrong here?

spiky0011 05-02-2016 01:58 AM

Did you see this
http://www.linuxfromscratch.org/~kre...sic-kernel.txt

Code:

  # Optional, required for VMware virtual machines
  # Begin here
  Misc devices  --->
      <*> VMware VMCI Driver
  # End here

Code:

# Optional, required for VMware virtual machines
  # Begin here[*] SCSI low-level drivers  --->
        <*>  BusLogic SCSI support (used by older VMware virtual solutions, can be optionally selected)
        <*>  VMware PVSCSI driver support (used by vSphere I think, but not by default, can be used by Player and Workstation too)
  # End here

Also I not sure but maybe you have to have "Additions" for usb in VMware?.

You also said you are using "opensuse grub" to boot They tend to use alot of modules and an intrid to boot there systems.

When using lfs grub sdb

set root=(hd1,2) should be set root=(hd0,2) IF booting from 2nd/usb drive. As grub see it as the 1st drive mbr (sda) with the root on 2nd drive sdb2

avanish321 05-02-2016 02:27 AM

Quote:

Originally Posted by spiky0011 (Post 5539328)
Did you see this
http://www.linuxfromscratch.org/~kre...sic-kernel.txt

Code:

  # Optional, required for VMware virtual machines
  # Begin here
  Misc devices  --->
      <*> VMware VMCI Driver
  # End here

Code:

# Optional, required for VMware virtual machines
  # Begin here[*] SCSI low-level drivers  --->
        <*>  BusLogic SCSI support (used by older VMware virtual solutions, can be optionally selected)
        <*>  VMware PVSCSI driver support (used by vSphere I think, but not by default, can be used by Player and Workstation too)
  # End here

Also I not sure but maybe you have to have "Additions" for usb in VMware?

I installed grub by running
grub-install /dev/sda ( I did this purposefully )

I believe I managed to fix it by installing the low level drivers. So now, when I log into lfs ( My first custom built Linux yipeeee !! ), I am getting bash 4.3 prompt. None of the credentials are working. The only one that seemed to work is the one when I configured Shadow. Is this normal?

I need some assistance here now.

1. I reverted the changes made so far back to the time when I began Chapter 8. Making the LFS System Bootable. Reason : I wanted dual boot option. So I guess, I must configure grub. I am no longer able to achieve this. Can you help me on this please?
If I run grub-install /dev/sda in my chroot environment, I only get to log into my LFS system. My opensuse host is lost.

spiky0011 05-02-2016 02:32 AM

Yes do Ch1,2,3 of BLFS 1st. Then move on to what you need/want.

yes the bash prompt is correct at 1st.

spiky0011 05-02-2016 02:40 AM

For my other OS,s I just copy from there grub.cfg and put it in lfs grub.
Code:

menuentry "Centos" {
          insmod ext2
          set root='(hd0,7)'
          echo 'Loading Centos'
          linux /boot/vmlinuz-2.6.32-358.14.1.el6.i686 ro root=/dev/sda7 quiet splash nomodeset VGA=792
          initrd /boot/initramfs-2.6.32-358.14.1.el6.i686.img
}

UUID dont work in lfs grub so I use /dev/sda7. Dont for get initrd for OS.

You can install "os prober" that will assit in locating OS,s.

If you want to use opensuse grub you could build an initrd
http://www.linuxfromscratch.org/blfs...initramfs.html

avanish321 05-02-2016 07:47 AM

Thanks.

This is just beginning. There's still lot more to compile in BLFS. I am specifically interested in configuring GUI. Might need all of your assistance when it comes to it and I am sure members here would be there to back me up when time comes. :)

Closing this thread! :)


All times are GMT -5. The time now is 02:01 AM.