LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 07-04-2007, 07:19 PM   #1
Neil-
LQ Newbie
 
Registered: Jul 2007
Distribution: Slackware 12.1
Posts: 16

Rep: Reputation: 1
Guide - Installing Slack 12.0 To a USB Drive


If, like me, you want to try a few different linux distros to see which you prefer - however don't want to risk turning your main system and files to toast, a perfect solution is to install the OS's to a USB Harddisk (or USB Stick), and just plug it in when you want to boot to it (obviously ensuring the correct boot order is selected in the BIOS).

The majority of mainstream `linuxes` I tried would boot from the USB Harddisk perfectly after installation, however Slackware 12.0 refused to do this.

Thanks to the_crowbar's guide at [linuxquestions-address-here]/questions/showthread.php?t=539732 for the baseline to this guide, I've tweaked it so it works for me. This should draw together partial guides from around the net to make this work.


============
1. Partition and install Slack to your usb drive, noting that they appear as scsi (/sdx) devices. Mine was /dev/sda, where /dev/sda1 is a 10 gig partition I'm using for root, /, and /dev/sda2 is 50 gigs and is being used for /home. /dev/sda3 is the swap space.

2. Boot to the install cd, press through until the screen invites you to type 'setup' to start setup,and you are sitting at a command prompt #.

3. Mount your partitions - for me this was:
mount /dev/sda1 /mnt
mount /dev/sda2 /mnt/home
swapon /dev/sda3
mount -o bind /proc /mnt/proc

Then chroot:
chroot /mnt /bin/bash

4. Run uname -r to print out your kernel version - Mine is 2.6.21.5-smp.

5. You now need to create the first version of your initrd, which will load the usb and filesystem modules enabling booting from a generic kernel. See the readme in /boot for further details and a few examples.

The basic command, assuming you use ext3, and your root mount is /dev/sda1, is:
mkinitrd -c -k 2.6.21.5-smp -m usbcore:ehci-hcd:uhci-hcd:ohci-hcd:usb-storage:ext3 -f ext3 -r /dev/sda1

-k specifies kernel version, -m the modules needed (swap out ext3 if needed), -f specifies file system (again, swap out if needed), and -r specifies the root.

6. We have now created an initrd in /boot/initrd.gz, however, the system still fails to load. This is due to the fact the system tries to boot from usb before the modules for it fully initialise. To fix this, you must edit file called `init` in /boot/initrd-tree.

Find the line '# Initialize LVM:' in it, and above this, but after the previous block, add these lines:
echo "Sleeping to allow USB Init."
sleep 10

7. Now run the command 'mkinitrd' without any arguments, to regenerate the initrd file with this change included.

8. All thats left now is to edit your /etc/lilo.conf file, adding the line 'initrd=/boot/initrd.gz' to the boot line of the slackware install.

9. Now, run lilo -v -t, check for any /errors/ (warnings usually ok), if it's fine, run lilo -v to commit the changes, and reboot into your new slack system!


Please point out any mistakes or misgivings, hope this helps someone!
 
Old 07-07-2007, 10:17 AM   #2
samac
Senior Member
 
Registered: Mar 2004
Location: Westray, Orkney
Distribution: Slackware64-14.1 (multi-lib) KDE 4.11.4
Posts: 1,422

Rep: Reputation: 137Reputation: 137
An addendum to the tutorial above.

If you do not want to install lilo to the master boot record and your computer doesn't boot from USB, you can make a boot CD like this.

Boot using the install disk or a live distro with good USB detection, and follow the instructions to allow you to chroot to your installed system.

Quote:
3. Mount your partitions - for me this was:
mount /dev/sda1 /mnt
mount /dev/sda2 /mnt/home
swapon /dev/sda3
mount -o bind /proc /mnt/proc

Then chroot:
chroot /mnt /bin/bash
1. In boot as root
Code:
mkinitrd -m ext3
Or mkinitrd as per the instructions on the install CD, depending on your chosen file system.

2. Edit initrd-tree/init
Quote:
Find the line '# Initialize LVM:' in it, and above this, but after the previous block, add these lines:
echo "Sleeping to allow USB Init."
sleep 10
3. Run mkinitrd again

4. Make a temporary directory eg. /bootcd

5. Copy initrd.gz to /bootcd/initrd.img
Copy vmlinuz-huge-smp-2.6.21.5-smp to /bootcd/linux
Copy isolinux.bin from the installcd or /usr/lib/syslinux/ to /bootcd

6.
Code:
echo "DEFAULT linux initrd=initrd.img ro root=/dev/sda5" > /bootcd/isolinux.cfg
(subsitute your root directory for /dev/sda5)

7. In the /bootcd directory

Code:
mkisofs -o bootcd.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -hide-rr-moved -R .
8. Burn the ISO to a CD with either cdrecord or K3B.

Samac
 
Old 07-18-2007, 10:27 AM   #3
gbowden
Member
 
Registered: Dec 2003
Location: Spain
Distribution: Slackware 14.1
Posts: 146

Rep: Reputation: 27
Lightbulb Another way

After using an initrd for some time to boot my USB Hard Drive, I was told about the rootdelay option which can be passed to the kernel. (Thanks to Khelban on ##slackware)


Instead of creating an initrd, you can compile the ehci-hcd, ohci-hcd, uhci-hcd and usb-storage modules into your kernel (You might also need to compile your filesystem modules into the kernel as well, depending on your setup).

Code:
CONFIG_USB_EHCI_HCD=m
---
CONFIG_USB_OHCI_HCD=m
---
CONFIG_USB_UHCI_HCD=m
---
CONFIG_USB_STORAGE=m
You use the rootdelay option by adding:

Code:
append="rootdelay=10"
(10 is the number of seconds to wait before mounting the root filesystem)

to the global section of your lilo.conf

Run lilo and reboot to see the results.


Notes:

If you get errors such as these on boot:

Code:
kobject_add failed for uhci_hcd with -EEXIST, don't try to register things with the same name in the same directory.
 [<c0210665>] kobject_shadow_add+0x115/0x1b0
 [<c013bcb4>] mod_sysfs_setup+0x24/0xc0
 [<c013d4f2>] sys_init_module+0x15c2/0x18c0
 [<c015489d>] do_mmap_pgoff+0x57d/0x7c0
 [<c0102a82>] syscall_call+0x7/0xb
 [<c0380000>] __inet6_check_established+0x3c0/0x440
 =======================
then you will have to either blacklist these modules in /etc/modprobe.d/blacklist I had to blacklist the ehci-hcd, ohci-hcd, uhci-hcd and usb-storage modules.

This is also covered in the CHANGES_AND_HINTS.TXT file on the Slackware 12.0 CD's/DVD.
 
Old 07-19-2007, 06:59 AM   #4
Neil-
LQ Newbie
 
Registered: Jul 2007
Distribution: Slackware 12.1
Posts: 16

Original Poster
Rep: Reputation: 1
Scary, I was about to post this, I think we chat in #slackware at the same time!

How low has anybody been able to get their delay? Although my 10sec delay doesn't seem to actually last 10 seconds, I would obviously like to trim boot time as much as possible
 
Old 07-19-2007, 07:09 AM   #5
gbowden
Member
 
Registered: Dec 2003
Location: Spain
Distribution: Slackware 14.1
Posts: 146

Rep: Reputation: 27
Anything below 10 seconds for me doesn't work. I've tried 5, 6, 7, 8, and 9 seconds.
 
Old 04-06-2008, 02:33 PM   #6
mcnalu
Member
 
Registered: Dec 2006
Location: Glasgow, UK
Distribution: Slackware 13.37 and 13.1
Posts: 393

Rep: Reputation: 63
Reviving an old, but very useful thread...

rootdelay was ignored in my Slackware 12.0 installed on a USB flash drive, but the above approach worked a treat.

I tried rootdelay=10 on slackware-current (rc1) installed on another usb flash key and it did pause for 10s and I saw /sda appear during the pause, but the root filesystem failed to mount because of errors like "reset high speed usb device".

I read that in other distros using 32 sectors/track, e.g.
http://http://www.damnsmalllinux.org...r_USB_Pendrive
helped troublesome USB flash keys, but that made no difference in my case.

After some experimenting I found success using an initrd. The
differences to the approach described by samac were:
  • I didn't use the -m option to mkinitrd as all I needed was built into the huge-smp kernel
  • I didn't add the sleep 10 line - just used rootdelay=10

That worked, but I can't really see why as the initrd doesn't seem to be doing anything!
 
Old 07-08-2008, 09:28 AM   #7
anbaric
LQ Newbie
 
Registered: Jul 2008
Location: Bristol, UK
Distribution: slackware
Posts: 1

Rep: Reputation: 0
Failing to boot from USB drive

And another revival...

I'm trying to get slack 12.0 to boot from a USB drive. I partitioned and installed slack 12.0 to my USB drive (/dev/sda1) ok, but of course it doesn't boot on CTRL+ALT+DEL on PC (call it A). I also have slack 12.0 on another PC (B) and I've mounted the USB drive there to check that the install is all there. It is.

Instead of

Quote:
Originally Posted by Neil- View Post

5. You now need to create the first version of your initrd, which will load the usb and filesystem modules enabling booting from a generic kernel. See the readme in /boot for further details and a few examples.

The basic command, assuming you use ext3, and your root mount is /dev/sda1, is:
mkinitrd -c -k 2.6.21.5-smp -m usbcore:ehci-hcd:uhci-hcdhci-hcd:usb-storage:ext3 -f ext3 -r /dev/sda1

-k specifies kernel version, -m the modules needed (swap out ext3 if needed), -f specifies file system (again, swap out if needed), and -r specifies the root.
I found out about the problems of booting from USB from alien [at] slackware and have been trying an approach based on:
mkinitrd_command_generator.sh

which generates the suggested mkinitrd command on my B PC as follows:
mkinitrd -c -k 2.6.21.5-smp -f ext3 -r /dev/sda1 -m ata_generic:mptbase:mptscsih:mptspi:mbcache:jbd:ext3 -w 15 -o /boot/initrd.gz

I've modified this for the A PC with the USB drive mounted at /media/disk as follows:
mkinitrd -c -k 2.6.21.5-smp -f ext3 -r /dev/sda1 -m usb-storage:usbcore:ata_generic:mptbase:mptscsih:mptspi:mbcache:jbd:ext3 -w 15 -o /media/disk/boot/initrd.gz

Usefully, it reveals the -w argument which seems to be the way to get a pause (I've chosen 15 seconds just in case USB on PC A is really slow), and I've added usbcore and usb-storage.

I've then edited the /etc/lilo.conf file on the USB drive so that it uses the initrd.gz by adding initrd= as follows:

# LILO configuration file
# generated by 'liloconfig'
#
# Start LILO global section
append="rootdelay=10"
boot = /dev/sda1
message = /boot/boot_message.txt
prompt
timeout = 5
# Override dangerous defaults that rewrite the partition table:
change-rules
reset
# Normal VGA console
vga = normal
# End LILO global section
# Linux bootable partition config begins
image = /boot/vmlinuz
initrd = /boot/initrd.gz
root = /dev/sda1
label = Linux
read-only
# Linux bootable partition config ends

which all should work! Except of course, it doesn't.

I've tried following
Quote:
Originally Posted by Neil- View Post
1.
...
9.
but for reasons I don't get at all, chroot /mnt /bin/bash fails.

I assume that my mkinitrd command with the -w 15 argument fulfills the same purpose as in step 6, editing the file init in /boot/initrd-tree?

Also I'm not sure about step 9. I've not done this step but I'm trying to work out how I can from PC B with the USB drive mounted. Is it possible to run lilo on one PC using the /etc/lilo.conf file on a mounted USB drive? I'm guessing not, but then how do you run lilo on PC A when you can't get it to boot?

Any help on this would be great.
 
Old 01-08-2009, 06:03 PM   #8
SiegeX
Member
 
Registered: Jul 2004
Location: Silicon Valley, CA
Distribution: Slackware
Posts: 171

Rep: Reputation: 38
Revive, I command thee!

Has anybody had any success with this now that we are on 12.2?
 
  


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
Installing Debian on USB Hard Drive/USB Jump Drive kushalkoolwal Debian 10 02-26-2009 01:46 PM
A guide to USB pen drive, mounting device in mdv2007 Emmanuel_uk Mandriva 7 12-10-2006 12:45 PM
Ultimate Slack Server Guide::Installing Apache2, PHP4, MySQL4, Webmin1.2, phpMyAdmin Eric45008 Slackware - Installation 9 04-25-2005 11:59 PM
Missing libs that fluxbox uses after installing slack 8.1 via guide datamin0r Amigo 2 09-28-2004 03:31 PM
Installing Slack 9.0 on an external USB hard drive Elohist Slackware 5 08-03-2004 07:41 AM


All times are GMT -5. The time now is 04:53 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration