Prev: Server Location Protocol (SLP) | Next: Gnome Keyring Daemon in Pentagram |
(Index) |
You have a new machine with no optical drive, and you want to put your distro's installer CD or DVD on a USB flash drive and install that way. But your favorite method has stopped working, or you have never been able to get it to work.
I've used unetbootin to make bootable USB flash drives, but it uses a very specific procedure to extract the needed files from the ISO image, and when the distro changes its boot paradigm, chaos can ensue. This is the case for my preferred distro, openSuSE 13.1 (probably started with the 12.x versions). The methods discussed here are tested with openSuSE 13.1, and help info for the live-fat-stick script suggests that they are supposed to work also for Ubuntu, Fedora and Mint.
SuSE has a page on
creating a Live USB Stick
, with sub-pages for doing it under
Microsoft Windows and Mac OS-X.
The procedure is absurdly simple, if you want essentially a copy of the CD/DVD and nothing else. First plug in the flash drive and identify its device name. On a host with one disc, /dev/sdb is typical, but be very careful because you don't want to wipe out one of your other discs. Locate the ISO image, either a downloaded file, or (typically) /dev/sr0 to read directly from the CD drive. Then just do:
dd if=openSUSE-13.1-DVD-x86_64.iso of=/dev/sdb bs=1M
sync
bs=1M
is optional but makes dd
more efficient. For my flash
drive, copying the DVD took about 12 minutes; speeds vary. The final sync
takes some time also. Be sure to do it before removing the drive.
This done, the drive can be booted and behaves the same as the CD or DVD
would.
Since the flash drive now allegedly has turned into a DVD, it is readonly, and it has the disc label and booter that was on the DVD, which for SuSE is a GPT partition table and a EFI-capable version of grub (with a signature that should be accepted). If you want to use the flash drive normally again, you will need to repartition it, and your favorite partitioning tool may or may not give you some grief. If so, wipe the disc label like this:
dd if=/dev/zero of=/dev/sdb bs=1M count=2
sync
This wipes the partition table and the superblock of the first filesystem. (Again, make sure you are doing this to the disc you really want to wipe.) Now the various partition utilities should create a new disc label of the kind you specify.
The SuSE page referenced above has a link to a RPM package called live-fat-stick whose payload is one script of the same name. You need your flash drive to have a partition with a fat32 (VFAT) filesystem on it, big enough to hold the ISO image and about 100 Mbytes in addition. According to the script you can put on several ISO images, but I couldn't figure out how to choose any but the first one. To set it up:
live-fat-stick -l #Prints device path, e.g. /dev/sdb1
live-fat-stick --suse /path/to/openSUSE-filename.iso /dev/sdb1
The script needs an absolute path to the ISO image. When you boot you get two choices: boot from hard disc (doesn't work, see below) and the name of your ISO image. It is booted with no extra parameters, e.g. no rescue system and no network configuration, which is not very useful for a network installer.
Since the ISO image is not findable by the time the OS finishes booting, live-fat-stick would not be too useful either for installationn from local files.
Although the copied DVD image is versatile, I took it as a challenge to overcome the limitations of the live FAT stick. The result was actually useful.
Create one partition for everything. The example below shows how
to re-create the disc label if you've wiped the disc, or how to remove
the existing partition if it's wrong. Be sure to get the correct device.
It's the entire device (no partition number at the end). help
will print a list of commands and help $cmd
(e.g. help mkpart
)
will give help for the individual commands.
parted /dev/sdb
print #Verify that you have the correct device
mklabel msdos #If you wiped the disc and killed the disc label
rm 1 #If there is a non-Linux partition, e.g. iso9660 or fat32
mkpart primary ext4 1MiB 100% #Leave space at the beginning for GRUB
set 1 boot on #Many BIOSes require this to boot the drive
print #Check your work
quit
Put a Linux filesystem on it. I'm using ext4. This time the device path is the specific partition. -L gives the disc label; you can alter it if desired.
mkfs -t ext4 -L SUSE-INSTALL /dev/sdb1
Mount the partition and install grub in it. You mount the partition device (/dev/sdb1) but you install the booter in the raw device (/dev/sdb). The boot directory will be created if not existing.
mount /dev/sdb1 /mnt
grub2-install --boot-directory=/mnt/boot /dev/sdb
Now copy your ISO images into the partition, which is still mounted.
cp openSUSE-13.1-NET-i586.iso openSUSE-13.1-NET-x86_64.iso /mnt
The magic happens in /mnt/boot/grub2/grub.cfg . Edit that file. This is the one I'm using:
# grub.cfg for multi-architecture Linux installer # Author: Jim Carter, 2014-04-27 # don't: set timeout=10 set default=0 # The boot disc usually comes out as (hd0) and we can assume we're in part. 1 # All paths will be relative to this partition's root. insmod part_msdos set root=(hd0,msdos1) load_video set gfxpayload=keep insmod gzio insmod ext2 # Boot from hard disc menuentry "Boot from hard disc" { search --file --no-floppy --set root /boot/vmlinuz echo 'Booting from' $root linux /boot/vmlinuz showopts initrd /boot/initrd } menuentry "OpenSuSE 13.1 Net Installer (i586)" { loopback loop /openSUSE-13.1-NET-i586.iso echo 'Loading installer for 13.1 i586 ...' linux (loop)/boot/i386/loader/linux install=http://192.9.200.194/SuSE/i586/13.1 echo 'Loading installer-s initrd ...' initrd (loop)/boot/i386/loader/initrd } menuentry "OpenSuSE 13.1 Rescue System (i586)" { loopback loop /openSUSE-13.1-NET-i586.iso echo 'Loading rescue system for 13.1 i586 ...' linux (loop)/boot/i386/loader/linux install=http://192.9.200.194/SuSE/i586/13.1 rescue=1 echo 'Loading rescue initrd ...' initrd (loop)/boot/i386/loader/initrd } menuentry "OpenSuSE 13.1 Net Installer (x86_64)" { loopback loop /openSUSE-13.1-NET-x86_64.iso echo 'Loading installer for 13.1 x86_64 ...' linux (loop)/boot/x86_64/loader/linux install=http://192.9.200.194/SuSE/x86_64/13.1 echo 'Loading installer-s initrd ...' initrd (loop)/boot/x86_64/loader/initrd } menuentry "OpenSuSE 13.1 Rescue System (x86_64)" { loopback loop /openSUSE-13.1-NET-x86_64.iso echo 'Loading rescue system for 13.1 x86_64 ...' linux (loop)/boot/x86_64/loader/linux install=http://192.9.200.194/SuSE/x86_64/13.1 rescue=1 echo 'Loading rescue initrd ...' initrd (loop)/boot/x86_64/loader/initrd } menuentry "Memtest86" { loopback loop /openSUSE-13.1-NET-i586.iso echo 'Loading memtest ...' linux16 (loop)/boot/i386/loader/memtest }
Discussion:
It begins with loading Grub modules and setting the root device. All file paths (lacking explicit devices) are sought here. This is mostly copied from the normal OS's grub.cfg.
Boot from hard disc: It searches for the /boot/vmlinuz symlink, but on my test machine fails to find it. Hiss, boo.
For each of the ISO images it creates a loop device for the image. Subsequently, (loop) refers to this device. It loads the kernel off the ISO, appending appropriate parameters to do a network installation -- on my home net it's enough to just give install=URL. It also has to load the initrd, similarly.
The rescue stanza is identical except it needs a command line parameter of rescue=1.
I included a memtest stanza copied from the normal OS's grub.cfg but modified to load the filename actually on the ISO.
This all actually works, and with the preset net URL it is more convenient than configuring the network every time.
Finally unmount the drive, after which you can remove it.
umount /mnt
The SuSE CD and DVD default menu choice is Boot from Hard Disc
,
which automatically happens after 30 seconds or so. Press any key, like
down arrow, to stop the clock. If you do try this menu choice, on my test
machine it would not override the boot device, instead going through the
normal boot order, and booting the flash drive (or CD) again. This must work
on some BIOSes, but definitely it doesn't work on others. In the multi-image
grub.cfg I have a heuristic to overcome this -- which also was ineffective
on my test machine.
Prev: Server Location Protocol (SLP) | Next: Gnome Keyring Daemon in Pentagram |
(Index) |