Jump to content











Photo
* * * - - 1 votes

USB HDD booting Linux on different machines


  • Please log in to reply
16 replies to this topic

#1 ktp

ktp

    Silver Member

  • Advanced user
  • 758 posts

Posted 26 March 2008 - 10:48 AM

Hello all,

Booting Linux (e.g. Unbuntu) from an external USB HDD is not a problem. You simply install Ubuntu to the USB HDD,
then afterwards Ubuntu boots very well on from the USB HDD. It is much easier than with XP/Vista, no Blue Screen of Death (BSOD) 0x7B problem.

My question is: is it possible to boot this same USB HDD on another machine (different hardware, chispet)?
I did try this and it did not work (hang at initialization time). I would like very much to be able to have an external
USB HDD that can boot e.g. Ubuntu on different machines with different hardwares. XP/Vista has HAL and different drivers
either in OEMPnpPath or Devicepath I believe. Can the "universal" external USB HDD bootability be achieved with Linux ?
If yes, how can I proceed?

Thank you.

#2 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 26 March 2008 - 12:25 PM

Found a tutorial with some info:

USB Ubuntu installation tutorial:

1. Download the Ubuntu 6.10 Edgy ISO and burn it to a CD
2. Reboot your computer into Ubuntu from the Live CD
3. Insert a 1GB or larger USB flash drive
4. Open a terminal window and type sudo su
5. Type fdisk -l to list available drives/partitions. Note which device is your flash drive (example: /dev/sda) Throughout this tutorial, replace x with your flash drive letter. For example, if your flash drive is sdb, replace x with b.
6. Type umount /dev/sdx1
7. Type fdisk /dev/sdx

  • type p to show the existing partition and d to delete it
  • type p again to show any remaining partitions (if partitions exist, repeat the previous step)
  • type n to make a new partition
  • type p for primary partition
  • type 1 to make this the first partition
  • hit enter to use the default 1st cylinder
  • type +700M to set the partition size
  • type a to make this partition active
  • type 1 to select partition 1
  • type t to change the partition filesystem
  • type 6 to select the fat16 file system
  • type n to make another new partition
  • type p for primary partition
  • type 2 to make this the second partition
  • hit enter to use the default cylinder
  • hit enter again to use the default last cylinder
  • type w to write the new partition table

8. Type umount /dev/sdx1 to ensure the 1st partition is unmounted
9. Type mkfs.vfat -F 16 -n usb /dev/sdx1 to format the first partition
10. Type umount /dev/sdx2 to ensure the 2nd partition is unmounted
11. Type mkfs.ext2 -b 4096 -L casper-rw /dev/sdx2 to format the second partition
12. Remove and Re-insert your flash drive
13. Back at the terminal, type sudo apt-get install syslinux mtools
14. Type syslinux -sf /dev/sdx1
15. Download this custom usyslinux.tar file using the archive manager and extract the syslinux.cfg file to your "USB" stick
16. Type cd /cdrom
17. Type cp -rf casper disctree dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines ubuntu.ico casper/vmlinuz casper/initrd.gz install/mt86plus /media/usb/
18. Reboot your computer and set your system BIOS to boot from USB-HDD or USB-ZIP. Also set the boot priority if necessary.

If everything has gone as it should, you should now be able to boot Ubuntu from the USB flash device and it should save your changes, restoring them on boot.

Notes: If your having trouble getting Ubuntu to boot, your memory stick may have a corrupted mbr. To repair the mbr of your USB device, at the terminal type sudo apt-get install lilo then type lilo -M /dev/sdx (replacing x with the letter of your flash device)


Look on step 15, would the customized usyslinux.tar archive be relevant to your success?

http://www.pendrivel...or-linux-users/
----

Off Topic:

Also found a reference to syslinux.exe mentioning it could be used for making USB bootable pendisks thought MSDOS/Win32 - I wonder if it could be used to launch Grub and the regular Windows boot loader? :thumbsup:

Install syslinux:

  • The last step: copy the syslinux.exe file from the downloaded zip archive to the root directory of your hard disk. I suggest to C:\ .
  • Open a shell. In Total Commander, navigate to the directory where syslinux.exe is and type cmd in the command line. Otherwise, navigate to the start menu, click on run program, and type cmd.
  • In the shell, make sure that you are in the right drive. Type C: and hit ENTER if syslinux.exe is located on drive c:
  • In the shell, make sure that you are in the right directory. Type dir and hit ENTER. You should see a list of files, including syslinux.exe.
  • Now you have to know the drive letter of your USB drive. I assume it is F: for this example.
  • In the shell, type syslinux F: and hit ENTER.
  • * If no error message appears, you can close the shell, remove the CD-ROM and push the RESET button of your computer. Wolvix should now boot from the USB drive.


http://wiki.wolvix.o...ashDriveInstall

----

Good luck.

:tabletalk:

#3 ktp

ktp

    Silver Member

  • Advanced user
  • 758 posts

Posted 26 March 2008 - 01:11 PM

@Nuno Brito
Thank you for your information, but as I said, I have no problem booting Linux (Ubuntu) from USB HDD on my machine.
Ubuntu 7.10 very easily installs on USB HDD, no need for the procedure you mentioned.
The problem is that the same USB HDD cannot boot entirely when booting from different machine (different hardware then the one it was installed first time).
Live CD like Knopix is OK, it is transferable to USB HDD and like BartPE can be booted in different machines.
But what I want is a full blown (not live cd) Ubuntu booting from USB HDD AND booting on different machines.

#4 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 26 March 2008 - 01:41 PM

I meant using the syslinux file mentioned on step 15, I'm not sure on the contents but it may indicate ubuntu to launch in hardware discovery mode.. :thumbsup:

#5 ktp

ktp

    Silver Member

  • Advanced user
  • 758 posts

Posted 26 March 2008 - 04:48 PM

I meant using the syslinux file mentioned on step 15, I'm not sure on the contents but it may indicate ubuntu to launch in hardware discovery mode.. :thumbsup:


I did experiment a little with ithis, in fact it is a change to make Ubuntu LiveCD persistent by writing changed stuff to special parition (capser-rw) on the key. The main kernel is still the squashfilesystem for Live CD. So it is not what I initially want, since the same equivalence can be also got with Puppy Linux or Knoppix (keeping changed data).

So I have to search again. Maybe orther person could have do this already ?

#6 ktp

ktp

    Silver Member

  • Advanced user
  • 758 posts

Posted 26 March 2008 - 07:18 PM

After some Google search, finally I think the way Nuno Brito pointed out is the good one. LiveCD by definition can run on different hardware, it lacks only writeability that can be solved with "persistence" mode (substituing write to ramdrive by write to partition or container file). So all updates, patches, customization will be preserved. Very good ! Edit: I believe it is equivalent to XP FWBF (file write based filter) so all changes in RAM are stored in fact to disk).

Apparently there are two possible sotlutions: one with specific partitions (ext2/ext3), and one with single file (loopback file) on existing FAT/FAT32 partition. The latter is more compatible and easier for USB key (and easier to increase the size or to backup). I will look at these 2 solutions in more details and experiment with them. If this works (it should since there are lot of existing tutorials), I can have a multiboot USB key/HDD booting DOS/XP/Vista/Linux in both LiveCD form (BartPE/VistaPE/Linux LiveCD) or in full blown OS, booting from different hardwares !

Thank you Nuno :-).

#7 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 26 March 2008 - 07:36 PM

Glad to have helped somehow.

Will you write a small tutorial afterwards you manage to boot properly to show others how it can be done?

I would really like to learn how to make this possible.

:thumbsup:

#8 ktp

ktp

    Silver Member

  • Advanced user
  • 758 posts

Posted 26 March 2008 - 08:36 PM

I just try the entire process, it is in fact very easy, and the persistence by container file (loopback file, apparently same idea as used by Puppy Linux) is very practical. A tutorial link :
https://help.ubuntu....veCDPersistence

It keeps my settings like Firefox bookmark etc... I need in the future to check for the updates of package, but it should work.
Add the persistence Ubuntu boot is easy since my key used already grub4dos, and converting syslinux.cfg (as mentioned by many tutorials) to grub4dos menu.lst is very easy.

I will try in the future to put some documentation, but there is plenty already (Google). For now the steps are:

1- copy the directories inside the Ubuntu 7.10 iso to the root of the USB key/HDD.
2- follow the tutorial from the above link to create casper-rw loopback file to house the changes (persistence). This is at the root of your key.
3- Add this entry to your grub4dos menu.lst :

title   Start Ubuntu 7.10 in persistent mode (French keyboard/language)

find	  --set-root /casper/vmlinuz

kernel	/casper/vmlinuz file=preseed/ubuntu.seed boot=casper locale=fr_FR bootkbd=fr console-setup/layoutcode=fr console-setup/variantcode=nodeadkeys persistent quiet splash --

initrd	/casper/initrd.gz

title   Start Ubuntu 7.10 in persistent mode (US keyboard/language)

find	  --set-root /casper/vmlinuz

kernel	/casper/vmlinuz file=preseed/ubuntu.seed boot=casper persistent quiet splash --

initrd	/casper/initrd.gz

Note: at boot time there is an (initramfs) prompt. I have no idea yet, but I just type exit then Enter (one or twice) then it continues to boot correctly. I guess this is the step to add/change some parameters dynamically. To be investigate/understand later.

#9 ktp

ktp

    Silver Member

  • Advanced user
  • 758 posts

Posted 27 March 2008 - 06:11 AM

OK I succeeded.
This is the tutorial on booting full Ubuntu with persistence from an USB key (or USB HDD) that will run on every machine.
(persistence = all changes like customizations, files, bookmarks, software updates... are preserved on disk).
Additionally you can also use the key to install Ubuntu to another hard disk (icon menu from Ubuntu desktop).

Pre-requisites :

1) You have already a bootable USB key, with grub4dos (menu.lst) operational, either directly
from grub MBR, or by other mean (ntldr/boot.ini etc..., refer to other tutorial).

2) The Ubuntu 7.10 (Gutsy Gibbon) ubuntu-7.10-desktop-i386.iso file (695 MB), or the associated CD.

Steps :

1) Copy the following directories and files from Ubuntu iso/CD to the root of your USB key:
Directories :

	 \.disk 

	 \casper 

	 \disctree 

	 \dists 

	 \install 

	 \pics 

	 \pool 

	 \preseed 

   Files:

	 \md5sum.txt 

	 \ubuntu 

	 \README.diskdefines 

	 \ubuntu.ico

2) You plug in your USB key, then boot Ubuntu from the CD. At initial screen choose F2 to select your language, the keyboard
will then be determined automatically. This allows easier typing some commands later.

3) From Ubuntu desktop, select the menu Applications, accessories, terminal.
Type the command:
df -h
This shows the path of your USB key, e.g. /media/your_usb_key (your mileage may vary). In my case, "your_usb_key"
is apparently my USB disk label as seen under XP/Vista.

4) Create a 1GB casper-rw file in the root of your key by typing the command:

dd if=/dev/zero of=/media/your_usb_key/casper-rw bs=1M count=1024
(note: 1 GB-size is necessary to use 80+ updates to Ubuntu later on, if you want to update Ubuntu. Also substitute "your_usb_key" string with the real string found in step 3).

5) Format (ext3) the loopback file created in step 4) with the command

mkfs.ext3 -L casper-rw /media/your_usb_key/casper-rw
(answer yes on question /media/hda1/casper-rw is not a blocked device).
Again: substitute "your_usb_key" string with the real string found in step 3).

6) Edit your menu.lst file in the root of your USB key to add one of the following entry:

(for US keyboard)
#

title   Ubuntu 7.10 (persistent mode)

find	  --set-root /casper/vmlinuz

kernel	/casper/vmlinuz file=preseed/ubuntu.seed boot=casper persistent quiet splash --

initrd	/casper/initrd.gz

(for French keyboard)
#

title   Ubuntu 7.10 (persistent mode)

find	  --set-root /casper/vmlinuz

kernel	/casper/vmlinuz file=preseed/ubuntu.seed boot=casper locale=fr_FR bootkbd=fr console-setup/layoutcode=fr console-setup/variantcode=nodeadkeys persistent quiet splash --

initrd	/casper/initrd.gz

7) That's all. Reboot and remove your Ubuntu CD. Change your BIOS order to boot from USB key.
Select your Ubuntu entry from grub4dos menu.lst. At one moment you could get back to BusyBox shell (ash, initramfs).
Just type exit then press Enter. (could be prompted twice). Then Ubuntu continues to boot successfully. Good luck!

#10 mihi

mihi

    Newbie

  • Members
  • 29 posts
  •  
    Germany

Posted 31 March 2008 - 10:13 PM

My question is: is it possible to boot this same USB HDD on another machine (different hardware, chispet)?
I did try this and it did not work (hang at initialization time).


could you give more detail about that "hang at initialization time" thing? I did it some/many years ago to install Linux to an external drive (in that case it was a Zip drive and Ubuntu did not exist yet; that was in Linux-2.2 times) and I had no problems with it. Just make sure that you install the bootloader (GRUB) really to the USB and not to your local HD and use some /disk/by-uuid stuff or similar for the root device (when you have SATA or your kernel uses libata for IDE, your USB disk will no longer be /dev/sda, but sdb or later; in old ZIP drive times, zip drives could be either internal (/dev/hda*) or external (dev/sda*). If you want access to the hard disks as non-root, you might need to write a script that rebuilds /etc/fstab every time (or steal one from a live CD *g*).

But it could be that due to the more complex Initramfs of latest Ubuntu (they integrate software suspend and some other nice goodies that make the boot process more complicated) it indeed does not work any longer (do not have two sufficiently different machines available here atm to test myself).

In fact, as you already found a solution to your problem, I don't really want to fix it, but I'd like to know what was the cause (before the bootloader, just after loading the kernel, somewhen after INIT) so that I can avoid it if I ever need to build something like that myself *g*.

mihi

#11 ktp

ktp

    Silver Member

  • Advanced user
  • 758 posts

Posted 01 April 2008 - 08:59 AM

I did not remember the problem, but they are many. Of course no problem for me to set in BIOS to boot on my HDD USB first (hd0). Then I got the usual GRUB menu from the external HDD USB (no other GRUB or Ubuntu inside my internal HDD). The it boots few steps then strang things happen etc... not ne normal procedure, progression bar etc...

The problem might be due to the Ubuntu was installed on an old machine (2001) with IDE HDD, while the new machine (2007) Ubuntu is booting from HDD USB has SATA, turbomemory, fingerprint, bluetooth etc...

I think the surest way to follow is to use persistent Live CD method, since per construction the Live CD can run on most hardwares.

#12 Mikorist

Mikorist

    ▂ ▃ █ ▅ ▆

  • Advanced user
  • 771 posts
  •  
    United Nations

Posted 01 April 2008 - 03:18 PM

For systems that won't boot from a USB device and/or don't even provide HDD/FDD emulation for USB devices in the BIOS,
KBoot might be an option - it uses the Linux kernel itself as a boot loader. For example, you could burn a KBoot CD that could boot a kernel stored on a USB mass storage device.

An installation guide for KBoot:
http://www.webalice....disk/index.html

#13 was_jaclaz

was_jaclaz

    Finder

  • Advanced user
  • 7100 posts
  • Location:Gone in the mist
  •  
    Italy

Posted 01 April 2008 - 03:30 PM

For systems that won't boot from a USB device and/or don't even provide HDD/FDD emulation for USB devices in the BIOS,
KBoot might be an option - it uses the Linux kernel itself as a boot loader. For example, you could burn a KBoot CD that could boot a kernel stored on a USB mass storage device.

An installation guide for KBoot:
http://www.webalice....disk/index.html


Interesting :tabletalk:, it should be something like the kexecloader we were discussing here :thumbsup::
http://www.boot-land...?...ic=4307&hl=

jaclaz

#14 Mikorist

Mikorist

    ▂ ▃ █ ▅ ▆

  • Advanced user
  • 771 posts
  •  
    United Nations

Posted 01 April 2008 - 03:34 PM

Interesting :D, it should be something like the kexecloader we were discussing here :thumbsup::
http://www.boot-land...?...ic=4307&hl=

jaclaz


:tabletalk:

"Kboot is a proof-of-concept implementation of a Linux boot loader based on kexec. Kboot uses a boot loader like LILO or GRUB to load a regular Linux kernel as its first stage. Then, the full capabilities of the kernel can be used to locate and to access the kernel to be booted.
kboot integrates the various components needed for a fully featured boot loader, and demonstrates their use. While the main focus is on basic technical functionality, kboot can serve as a starting point for customized boot environments offering additional features."

Papers

http://kboot.sourceforge.net/

#15 Cadillac

Cadillac
  • Members
  • 1 posts
  •  
    Azerbaijan

Posted 06 April 2008 - 11:16 AM

There is a great site about installing Linux on external drives:
http://www.pendrivelinux.com/

#16 ktp

ktp

    Silver Member

  • Advanced user
  • 758 posts

Posted 14 August 2008 - 02:36 PM

I found the following useful links with explanations and tools to easily create Live
USB. You can adapt them to integrate with your existing Multiboot USB HDD.

Live USB:
http://en.wikipedia.org/wiki/Live_USB

UNetbootin Universal Netboot installer:
UNetbootin (Universal Netboot Installer) is a cross-platform utility that can
create Linux Live USB drives and can load a variety of system utilities or
install various Linux distributions and other operating systems without a CD.
http://en.wikipedia....wiki/UNetbootin
http://unetbootin.sourceforge.net/

mk-boot-usb: a Script to Create Multiple-Bootable USB Sticks
http://people.ofset....t-usb/index.php

#17 ktp

ktp

    Silver Member

  • Advanced user
  • 758 posts

Posted 15 August 2008 - 07:08 AM

Unfortunately, under Ubuntu the kernel can only handle 15 partitions :
https://answers.laun... question/41786

So this limits the number OS multi-boot capability that can be put on an USB HDD.

Edit: so you might want to put all Linux logical partitions first, then afterwards other OSes like XP/Vista (which has limitation of A-Z drive letter numbering up to 26-2=24 partitions, but you are not forces to assign drive letter if not needed).

A little off-topic here but could be useful:
ext2/ext3 IFS driver for NT/2K/XP/Vista:
http://www.fs-driver.org/index.html




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users