📜 ⬆️ ⬇️

Problems installing a bootloader on a flash drive

The article contains 5 questions and answers on the following topics:

1. Cleaning mbr flash drives in Windows
2. Convert an ISO file to a hybrid ISO file (Linux only)
3. Creating a bootable flash drive with saving changes (Linux, Windows, Mac OS X)
4. Creating a multiboot flash drive (Windows)
5. Restore partition table and loader mbr (Hiren's BootCD).

To use all the solutions described in the article (except 2 - it works only on Linux), Microsoft Windows and Linux (or Mac OS X) operating systems, Windows USB DVD Download Tool and RMPrepUSB (Windows), dd (Linux, Mac OS X) utilities are required. , isohybrid (Linux), Unetbootin (Windows, Linux, Mac OS X), md5sum (Linux, Mac OS X), an empty flash drive of at least 8 GB, as well as a rescue flash drive Hiren's BootCD 15.2.

1. Question. When I got a new job, the first days were devoted to learning. During training, all students were issued a hard disk containing instructions and software. One of the instructions provided an example of using the utility Windows 7 USB / DVD Download tool. With its help, in this example, a special ISO image of the Windows 7 operating system was recorded on a flash drive. In practice, this method did not work. What to do?
')
Answer. Of course, to diagnose and solve the problem. It may be in a faulty ISO file (the md5sum utility will help to check it), a faulty flash drive (does it open in the Windows file manager?) And the wrong mbr code. In the latter case, it is useful to clear mbr before using WUDT. This can be done using the command line using the following commands:

diskpart list disk select disk N clean create partition primary select partition 1 active format FS=FAT32 QUICK assign exit 

Here N is the number of the flash drive in the list of all devices displayed using the list disk command

2. I wanted to install another operating system on my home computer - Mageia4.1. To do this, I downloaded an ISO CD image from the official website and burned it to a USB flash drive using the dd command. But when you try to boot the computer with it, you receive an error message: isolinux.bin is missing or corrupt.

Answer. It looks like the ISO image you downloaded is not a hybrid, i.e. it is intended only for recording on CD and is not suitable for recording on a flash drive. This problem can be solved using the isohybrid utility included with syslinux. It allows you to convert the specified ISO image for CD / Dvd into a hybrid ISO image with the same name.

3. In the night shift there is a time when there is no work and nothing to do. In order to occupy myself somehow, I decided to take Linux-LiveUSB with me in order to use my free time with benefits (which is prohibited by the rules). Writing down with the command

 dd if=elementaryos-0.4-stable-amd64.20160909.iso of=/dev/sdb bs=4096,  /dev/sdb -   

On the USB flash drive, the hybrid ISO image of ElementaryOS 0.4 'Loki', I downloaded this operating system on my computer. Next, I created an empty file in the Documents directory to find out if it will remain after reboot, as was the case with the openSUSE 13.1 GNOME bootable flash drive, created in a similar way, with which I was able not only to create such a file, but also to install the necessary programs that did not disappear after rebooting the computer. But with Elementary OS 0.4 such a trick did not work. Can I make sure that when using a bootable flash drive with Elementary OS 0.4, changes are saved as well as in the case of using openSUSE 13.1 GNOME? Why does it work in openSUSE, but not in Elementary OS?

When you first load an openSUSE flash drive, a new partition is created named hybrid, which contains a file system in which all changes made when working with LiveUSB are saved, including the files created and the installed programs. Elementary OS 0.4 does not know how to do this on its own, but it can be helped in this.

First, you can create such a partition using the Unetbootin utility to write an Elementary OS 0.4 iso-image to a USB flash drive. To do this, you can specify the place used to save the changes after a reboot (only for ubuntu and distributions based on it), for example 4096 MB (see the picture).

image

Image 1. Unetbootin window

The second way is to manually create a second partition on the flash drive with the name “casper-rw” (for example, using GParted) and specify the keyword “persistent” in the kernel boot parameters, as was done in the next answer.

4. I learned how to burn hybrid ISO images of the ElementaryOS 0.4, Mageia4.1 and openSUSE 13.1 GNOME distributions using the dd command, but this method is not suitable for creating a multi-boot flash drive. How to create such a flash drive?

Answer. This can be done by adding a new operating system to the boot menu of the operating system loader installed on the USB flash drive. Such loaders are different, as well as ways to install them on a flash drive. Using the bootloader's configuration file, you can make the selector in the operating system menu transfer control to its kernel and create a temporary file system using its initial ramdisk, and the kernel load the operating system using the operating system iso-image file . To do this, you can copy the iso-image, kernel and initial ram-disk files of this operating system to the USB flash drive. Thus, the number of operating systems loaded using such a flash drive that the boot loader installed on it can load is limited only by its capacity.

Kernel and initial ramdisk files can usually be obtained by unpacking them from an operating system iso-image file using an archiver. In Elementary OS, as well as in Ubuntu, they are called casper / vmlinuz and casper / initrd.lz

One way to install the operating system bootloader on a USB flash drive is to use the RMPrepUSB utility. This utility has a graphical interface and works in Windows. It allows you to install the grub4dos and syslinux loaders, reset the partition table, create a primary partition, format it, and even check the performance of the bootable flash drive in the QEMU emulator.

image

Image 2. RMPrepUSB window

In order to load Elementary OS 0.4 by the grub4dos bootloader installed using RMPrepUSB, you need to add an item to the boot menu that, when selected, starts the loading of this operating system. To do this, create the grub4dos bootloader menu configuration file, which is called menu.lst, and, assuming that the iso image, the kernel files and the initial ramdisk are on a flash drive in the elementaryos directory, we add the following lines to it:

 timeout 10 default 0 title Elementary OS 0.4 'Loki' find --set-root /elementaryos/elementaryos-0.4-stable-amd64.20160909.iso kernel /elementaryos/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper persistent iso-scan/filename=/elementaryos/elementaryos-0.4-stable-amd64.20160909.iso splash initrd /elementaryos/initrd.lz title Reboot reboot 

In openSUSE, the kernel and initial ramdisk files are called boot / i386 / loader / linux and boot / i386 / loader / initrd. To add openSUSE 13.1 to the boot menu, it is enough to add the following lines to the configuration file before the title Reboot line (assuming that the iso image, the kernel files and the initial ramdisk are on a flash drive in the opensuse directory):

 title openSUSE-13.1-GNOME-Live-i686.iso uuid () > nul set UUID=%?% set ISO=openSUSE-13.1-GNOME-Live-i686.iso kernel /opensuse/linux isofrom=/dev/disk/by-uuid/%UUID%:/opensuse/%ISO% isofrom_device=/dev/disk/by-uuid/%UUID% isofrom_system=/opensuse/%ISO% loader=syslinux splash=silent quiet initrd /opensuse/initrd 

In such a boot menu, you can add not only operating systems, but also utilities to check the computer’s RAM, hard disk surface, reset or change Windows password, etc. For example, you can add the MemTest86 + program call to it by copying the memtest.img file to the root directory of the flash drive and adding the following lines to the menu.lst configuration file before the title Reboot:

 title memtest86+ v5.01 find --set-root /memtest.img map /memtest.img (fd0) map --hook chainloader (fd0)+1 rootnoverify (fd0) map --floppies=1 

The memtest.img file can be downloaded from the memtest.org website in a compiled bootable .iso file contained in a zip or gz archive.

5. I used the parted utility to do this to clean the partition table in the mbr flash drives, but I mistakenly cleared the partition table of my hard disk. After reboot, the system did not boot. Fortunately, I had several bootable flash drives containing various Linux distributions. How to restore the system?

Answer. This situation could have been avoided by calling parted immediately by specifying the device with which you will work, for example:

 sudo parted /dev/sdb 

To restore the partition table, you can use the TestDisk utility, which is included with some of the "rescue" Linux distributions, such as Parted Magic LiveCD or SystemRescueCD. Now the Parted Magic distribution is paid, but you can use its free, obsolete version, which is included with Hiren's BootCD. In the Hiren's BootCD menu, it is called “Linux based rescue environment (Parted Magic 2012-10-10)”. Using these distributions, you can restore not only the partition table, but also the mbr loader using the chroot command.

Using chroot to restore the Linux bootloader is quite popular and details about this can be found on various resources on the Internet, including YouTube videos.

Sources used:

1. LiveUSB
2. Multiboot
3. The "Questions and Answers" column in Russian LINUX FORMAT # 203 (12/2015), # 205 (3/2016) and # 207 (5/2016)
4. Installing Linux from an iso image under Windows
5. SDB: Create a Live USB stick using Windows
6. 20 - Add MEMTEST86 + memory test program to your grub4dos menu.lst file
7. LiveCD / Persistence

Source: https://habr.com/ru/post/313730/


All Articles