LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Boot Linux from external hard drive?? (https://www.linuxquestions.org/questions/slackware-14/boot-linux-from-external-hard-drive-517934/)

wootletootle 01-10-2007 02:48 AM

Boot Linux from external hard drive??
 
Is it possible?

I installed Slack 11.0 on /dev/sdb2 of an external (USB)
hard drive, configured as master. I made a boot floppy.
Lilo was installed into the root partition superblock.

When I booted from the floppy I got a certain distance
into the boot and then got a kernel panic. Specifically:

.....
Linux IP multicast router 0.06 plus PIM-SM
NET4: Unix domain sockets
NFS: Cannot open root device "sdb2" or 08:12
Please append a current "root=" boot option
Kernel panic: VFS: Unable to mount root fs on 08:12

I tried various boot options and other procedures
using a boot manager (Ranish) but always get kernel panic.
Linux fdisk correctly identifies /dev/sdb and /dev/sdb2
is bootable. I can mount /dev/sdb2 from another Linux OS
and the partition appears to be OK.

Any suggestions as to what to do next?

Thanks.

sadiqdm 01-10-2007 03:16 AM

Which boot image did you use? this sounds like it doesn't have SB support.

wootletootle 01-10-2007 03:50 AM

> Which boot image did you use?
> this sounds like it doesn't have SB support.

Good point. I used the default sata.i.
What would be a better choice?

gbowden 01-10-2007 09:34 AM

You will probably need to make a initrd. See this.

wootletootle 01-11-2007 02:14 AM

Thanks for that pointer, gbowden.
Very informative. I tried to use it as
a basis for booting to the USB partition
using a boot loader (Ranish).

I booted to the Slack11 CD and installed the default
Linux on /dev/sdb2. Then

# mount /dev/sdb2 /mnt
# cd /mnt/boot
# chroot /mnt /usr/sbin/mkinitrd -c -k 2.4.33.3 -m jbd:ext3
-f ext3 -r /dev/sdb2
# cd /mnt/etc
edit lilo.conf to include the lines:
image=/boot/vmlinux
initrd=/boot/initrd.gz
root=/dev/sdb2
label=Linux
Save file then
# chroot /mnt /sbin/lilo

When I select the partition /dev/sdb2 through the boot loader
this happens:

......
/boot/initrd.gz: Loading kernel modules from initrd image
Using /lib/modules/2.4.33.3/jbd.o.gz
insmod: not an ELF file
insmod: could not load the module
mount: Mounting /dev/sdb2 on /mnt failed: No such file or directory
ERROR: mount returned error code 1. Trouble ahead
mount: mounting /dev/sdb2 on /mnt failed: Invalid argument
/boot/initrd.gz: exiting

I guess there is something I am doing wrong, but what?
Is the mkinitrd command correct?

Thanks for your help...

Fluxx 01-11-2007 03:37 AM

Here you can find a way like I did it ...

http://www.linuxquestions.org/questi...=usb+initrd.gz

Fluxx.

wootletootle 01-11-2007 05:01 AM

Thanks Fluxx. I'm gradually getting it all together.

I must be fairly close. I can boot the usb partition through
my boot loader and the usb modules are installed. Then I get:

Attached scsi disk sdb at scsi2, channel0, ide0, lun0
SCSI device sdb: 234441648 512-byte hdwr sectors (120034 MB)
sdb: sdb1 sdb2
mount: Mounting /dev/sdb2 on /mnt failed: No such file or directory
ERROR: mount returned error code 1. Trouble ahead.
mount: Mounting /dev/sdb2 on /mnt failed: Invalid argument.
/boot/initrd.gz: exiting

What is going on here? Why does the device fail to mount?

wootletootle 01-11-2007 06:06 AM

GOT IT! The trick was *not* to set the boot device in the
initrd config file rootdev. With /dev/sdb2 removed from
rootdev I was able to boot to the external USB HD through
my boot loader (Ranish).

In summary I used the Slack 11.0 boot disk and Ranish
to install the default kernel (2.4.33.3) in the partition
/dev/sdb2 of the USB drive, and then to boot Linux from this
partition. The procedure was:

(1) Boot to the Slack CD and format the partition. Install
Linux into /dev/sdb2 (use ext2 fs) and put lilo in the superblock.

(2) With the CD still in place make sure /dev/sdb2 is mounted
on /mnt.

(3) Set up the initial ramdisk

# cd /mnt/boot
# chroot /mnt /usr/sbin/mkinitrd -k 2.4.33.3

(4) Copy usb modules to the initrd-tree/lib/modules/2.4.33.3
These are
USB_MODULE_PATH/usbcore.o.gz,
USB_MODULE_PATH/storage/usb-storage.o.gz
USB_MODULE_PATH/host/ehci-hcd.o.gz,
USB_MODULE_PATH/host/uhci.o.gz
where
USB_MODULE_PATH = /mnt/lib/modules/2.4.33.3/kernel/drivers/usb
The files should be gunzipped after transfer.

(5) Insmod the usb modules in /mnt/boot/initrd-tree/load-kernel-modules.
Use the vi editor to insert them in this order:
insmod /lib/modules/$(uname -r)/usbcore.o
insmod /lib/modules/$(uname -r)/ehci-hcd.o
insmod /lib/modules/$(uname -r)/uhci.o
insmod /lib/modules/$(uname -r)/usb-storage.o
Other modules may be inserted as desired (eg if using
ext3 or reiserfs instead of ext2)
Make sure the file is executable
(chmod 755 load-kernel-modules)

(6) Use vi to insert the line "sleep 10" in
/mnt/boot/initrd-tree/linuxrc
after the lines
......
done
unset module
fi
fi
.......
sleep 10
......
Make sure linuxrc is executable (chmod 755 linuxrc)

(7) Make sure /mnt/boot/initrd-tree/rootdev is empty

(8) chroot /mnt /usr/sbin/mkinitrd

(9) Run lilo
# cd /mnt/etc
Edit lilo.conf with vi and insert the lines
image=/boot/vmlinuz
initrd=/boot/initrd.gz
root=/dev/sdb2
label=Linux
# chroot /mnt /sbin/lilo

(10) Reboot

(11) If using Ranish select /dev/sdb2 as a boot item
and boot to the USB partition.

BORELLI 01-13-2007 10:33 PM

Mandriva?
 
I Am Working On This Same Project But With Mandriva
The Exact Same Thing Happens When The System Tries To Mount Root
Will I Be Able To Use The Same Technique That Was Just Used Here?
I Wonder If I'll Have A Problem Editing These Files If I Have My Usb Drive Plugged Into My Machine That Is Running Mandriva.
Kernel Is 2.6.17

wootletootle 01-19-2007 05:46 AM

I don't know Mandriva, but it is probably worth a try.
You need a bootable CD and then you must install the OS
(in basic form) on the USB drive. You also need some
utilities on the boot CD such as chroot and an editor,
and of course you need mkinitrd either on the CD or
from the installed OS. The correct USB modules must be
available, and insmodded in the correct order. If you
get this wrong then you will have those nasty error messages.

Also you need some sort of boot manager which allows you
to set the bootable partition.

I can't see why you should have any problem editing the
files on the USB partition. If you can mount it then
you can treat it like any other partition.

There's nothing wrong with experimenting, since you will
still have your main Mandriva partition there if things
go wrong. I had to to try quite a few times before I got it
right.....

Cheers,
Wootle.


All times are GMT -5. The time now is 12:52 AM.