Linux-ISO-Boot von USB

Inhaltsverzeichnis

Bearbeiten von Linux-ISO-Boot von USB

Einführung

grub2 ist in der Lage, ISO-Abbilder per loopback zu mounten. Dies ermöglicht das Lesen vom Linux-Kernel bzw. Initial-RAM-Disk (initrd), was wiederum das Booten des Linuxkernels der Live-CDs ermöglicht.

Voraussetzung

Man benötigt grub2 in Version >= 0.98, einen USB-Stick mit genügend Speicherkapazität (1-4GB). Unter Debian muss man den grub2 aus testing verwenden (grub-pc, grub-common, grub2). Der USB-Stick wird beim Einstecken unter Linux als /dev/sdb erkannt (in unserem Beispiel wird von /dev/sdb ausgegangen).

ACHTUNG bitte vorher unbedingt sicherstellen, dass auch das richtige Gerät verwendet wird (z.B. mit dmsg). Anderenfalls droht Datenverlust!

Erstellung

  • USB-Stick partitionieren

Hierbei sind alle Partitionen zu löschen und eine neue Partition mit FA16 anzulegen.

fdisk /dev/sdb

Um die vorhandenen Partitionen anzuzeigen kann man p verwenden und mit d dann die Partion(en) löschen:

Command (m for help): p

Disk /dev/sdb: 4043 MB, 4043309056 bytes
125 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 7750 * 512 = 3968000 bytes
Disk identifier: 0xbcaf8ed9

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1         258      999719    6  FAT16
/dev/sdb2             259        1018     2945000   83  Linux

Command (m for help): d
Partition number (1-4): 1

Command (m for help): d 2
Selected partition 2

Nun kann man die neue Partition anlegen:

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1018, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1018, default 1018):
Using default value 1018
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      41  PPC PReP Boot   85  Linux extended  c7  Syrinx
 5  Extended        42  SFS             86  NTFS volume set da  Non-FS data
 6  FAT16           4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility
 8  AIX             4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 61  SpeedStor       a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS
 17  Hidden HPFS/NTF 65  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 75  PC/IX           bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 80  Old Minix       be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1
Hex code (type L to list codes): 6
Changed system type of partition 1 to 6 (FAT16)

Nun muss die Partition bootbar gemacht werden:

Command (m for help): a
Partition number (1-4): 1

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional information.
Syncing disks.

Nach dem Erstellen der Partition kann diese dann formatiert werden:

mkfs.msdos /dev/sdb1
mkfs.msdos 3.0.6 (04 Oct 2009)

Nun muss die Partition gemountet werden:

mount /dev/sdb1 /mnt

Nun noch den Bootloader installieren:

grub-install --no-floppy --root-directory=/mnt /dev/sdb
Installation finished. No error reported.

für die Konfiguration des Bootloaders müssen jetzt noch 2 Dateien angepasst werden. Die Datei /mnt/boot/grub/grub.cfg enthält die Menüeinträge für den grub:


### BEGIN /etc/grub.d/00_header ###
#set default=0
#set timeout=0
#set root=(hd0,0)
#search --fs-uuid --set de979549-a90d-4e50-86a9-1d46dcfa24bf
#if font /usr/share/grub/ascii.pff ; then
#  set gfxmode=1024x768
#  insmod gfxterm
#  insmod vbe
#  terminal gfxterm
#fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

menuentry "Linux Mint 8.0 (LinuxMint-8.iso)" {
        loopback loop /LinuxMint-8.iso
        linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/LinuxMint-8.iso file=(loop)/preseed/mint.seed quiet splash lang=de noeject noprompt --
       initrd (loop)/casper/initrd.lz
}

menuentry "Debian 5.02a Netinst (debian-502a-i386-netinst.iso)" {
        loopback loop /debian-502a-i386-netinst.iso
        linux (loop)/install.386/vmlinuz boot=install iso-scan/filename=/debian-502a-i386-netinst.iso file=(loop)/preseed/debian502a.seed quiet splash lang=de noeject noprompt --
        initrd (loop)/install.386/initrd.gz
}
   
menuentry "Memory Test (LinuxMint-8.iso)" {
        loopback loop /LinuxMint-8.iso
        linux (loop)/isolinux/memtest
}

Zur Erklärung: linux (loop)/install.386/vmlinuz das ist das Kernel-Abbild auf der CD boot=install das ist der Menüeintrag von der CD, der gebootet werden soll initrd (loop)/install.386/initrd.gz das ist die initrd die beim Booten vom Abbild benutzt werden soll

Man muss bei anderen CDs diese per loop mounten und den Kernel, initrd bzw. Menüeintrag suchen:

mount -o loop debian-502a-i386-netinst.iso /media/cdrom
find /media/cdrom -type f -name 'vmlinuz*'
find /media/cdrom -type f -name 'initrd*'

Das Label von der CD lautet meistens linux oder install.

Diese Werte kann man dann in der grub.cfg eintragen.

Das LinuxMint ISO gibts übrigens hier (http://ftp.heanet.ie/pub/linuxmint.com/stable/8/LinuxMint-8.iso) ;)

Die Datei /boot/grub/device.map die Zuordnungen der Geräte. Hier darf nur ein Eintrag stehen (hd0,0) /dev/sda1.

echo "(hd0,0) /dev/sda1" > /mnt/boot/grub/device.map"


Abschließen können jetzt die ISO-Abbilder auf den Stick kopiert werden:

cp debian-502a-i386-netinst.iso /mnt/
cp LinuxMint-8.iso /mnt/

Nun nur noch den Stick aushängen:

umount /dev/sdb1

Nun setht einer Nutzung des Live-CD-USB-Sticks nichts mehr im Wege.

Von "http://www.lug-wr.de/wiki/index.php/Linux-ISO-Boot_von_USB"

Diese Seite wurde bisher 11351 mal abgerufen. Diese Seite wurde zuletzt geändert um 13:13, 25. Mär 2010. Inhalt ist verfügbar unter der GNU Free Documentation License 1.2.