0% found this document useful (0 votes)
42 views9 pages

Boot de ISO

how to boot from a ISO file

Uploaded by

dojai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views9 pages

Boot de ISO

how to boot from a ISO file

Uploaded by

dojai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Em junho 2024: https://www.linuxdescomplicado.com.

br/2015/09/usar-um-sistema-linux-live-
diretamente-do-disco-a-partir-de-uma-imagem-iso.html

Saiba como usar um sistema Linux Live


diretamente do disco a partir de uma imagem
ISO (ver 2º artigo, logo após este, sobre USB)
9 de setembro de 2015

O gerenciador de boot do Linux, o GRUB 2, pode inicializar arquivos de imagem ISO diretamente
do disco rígido do seu computador. Esse recurso, permite você inicializar (“dar boot“) um sistema
LiveCD sem a necessidade de um pendrive ou CD/DVD para queimar a imagem ISO. Além disso, é
possível instalar um sistema Linux, em uma outra partição do disco rígido já particionada, sem
queimar em um disco ou iniciar a partir de um pendrive.
Embora seja fácil de queimar arquivos ISO em um disco USB ou CD/DVD; em certos casos, pode-
se querer executar a mesma imagem ISO muitas vezes ou executar diferentes sistemas
Live regularmente. Com o GRUB 2 é possível configurar de modo que você não precise queimar as
imagens ISOs constantemente ou usar uma unidade USB. Basta executar usar um sistema Linux
Live diretamente do disco a partir de uma imagem ISO.

Ambiente de Teste
Realizamos este processo no Ubuntu 14.04 – Ubuntu e distribuições Linux baseada no Ubuntu tem
um bom suporte para isso. Outras distribuições Linux deve funcionar de forma semelhante.

Mão na massa
1 – Obtendo a imagem ISO
Para obter uma imagem ISO, você deverá visitar o site da distribuição desejada e fazer download de
qualquer imagem que seja compatível com a sua configuração. Se a imagem pode ser iniciada a
partir de um pendrive, ela deve ser capaz de iniciar a partir do menu GRUB também.
No no nosso caso, escolhi a imagem ISO do Fedora.

2 – Determinando o caminho da partição do disco rígido


O GRUB usa uma notação diferente do sistema Linux para referenciar o dispositivo de disco. Em
um sistema Linux, /dev/sda1 é a primeira partição no primeiro disco rígido. No GRUB, (hd0,1) é
equivalente a /dev/sda1. O 0 (“zero”) significa o primeiro disco rígido, já o 1 (“hum”) significa a
primeira partição desse disco.
Você pode usar o comando fdisk -l para exibir essas informações. No Ubuntu, abra um terminal e
execute o seguinte comando:
$ sudo fdisk -l
Você verá uma lista de caminhos de dispositivo do Linux, que você pode alterar para nomes de
dispositivo do GRUB. Por exemplo, abaixo podemos ver a partição do sistema é /dev/sda1 – de
modo que (hd0,1) será usado para o GRUB.
Disco /dev/sda: 500.1 GB, 500107862016 bytes
255 cabeças, 63 setores/trilhas, 60801 cilindros, total de 976773168 setores
Unidades = setores de 1 * 512 = 512 bytes
Tamanho do setor (lógico/físico): 512 bytes / 512 bytes
Tamanho da E/S (mínimo/ideal): 512 bytes / 512 bytes
Identificador do disco: 0x359d0186

Dispositivo Boot Início Fim Blocos Id Sistema


/dev/sda1 * 2048 206847 102400 83 Linux
/dev/sda3 411525118 976771071 282622977 5 Estendida
/dev/sda6 970915840 976771071 2927616 82 Linux swap / Solaris
3 – Verificando o conteúdo da imagem ISO
Uma etapa importante é verificar o caminho correto dos principais arquivos que inicializam o
sistema e carregam o kernel; initrd e vmlinuz, respectivamente.
Depois de baixada a imagem ISO, verifique seu conteúdo usando o recurso gráfico do Ubuntu –
botão direito sobre a imagem e gerenciador de arquivos/pacotes. Algo similar a imagem abaixo:

Normalmente, esses arquivos encontram-se na pasta casper. Contudo, no caso do Fedora (baixado
no exemplo) o caminho é diferente: pasta isolinux. Na próxima etapa, as duas últimas linhas que
serão adicionadas, no arquivo do GRUB, indicarão esse caminho.

4 – Configurando o GRUB 2
A maneira mais fácil para adicionar uma entrada de inicialização personalizada é editar o arquivo
/etc/grub.d/40_custom. Este arquivo é projetado para entradas de inicialização personalizados
adicionados pelo usuário.
Após editar esse arquivo, o conteúdo do arquivo /etc/defaults e dos arquivos /grub, /etc/grub.d/
serão alterados para criar o arquivo /boot/grub/grub.cfg – você não deve editar esse arquivo
manualmente.
Ele foi projetado para ser gerado automaticamente a partir de configurações que você especificar
nesses outros arquivos.
Agora, você vai precisar para abrir o arquivo /etc/grub.d/40_custom para edição com privilégios
de root. No Ubuntu, você pode fazer isso abrindo uma janela de terminal e executando o seguinte
comando:
$ sudo gedit /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.

Para iniciar o Fedora Live a partir da imagem ISO pelo GRUB, adicione o seguinte trecho ao final
do conteúdo mostrado à cima:
menuentry "FEDORA LIVE ISO" {
set isofile="/home/ricardo/Fedora-Live-Workstation-x86_64-22-3.iso"
loopback loop (hd0,1)$isofile
linux (loop)/isolinux/vmlinuz0 boot=isolinux iso-scan/filename=${isofile} quiet
splash
initrd (loop)/isolinux/initrd0.img
}

Salve o arquivo quando concluir. Por fim, retorne para a janela do Terminal e execute o seguinte
comando:
$ sudo update-grub
A próxima vez que você iniciar seu computador, você verá a entrada de inicialização do arquivo
ISO. Assim, você poderá escolhê-lo para inicializar diretamente pela imagem ISO. Quando iniciar o
PC, segure a tecla Shift durante a inicialização para aparacer a tela de GRUB.

Onde Encontrei
How to Run ISO Files Directly From the HDD with GRUB2
How to Boot Linux ISO Images Directly From Your Hard Drive
Exemplos de várias entradas no GRUB – diversas distros

EXEMPLOS PRONTOS
NÃO ESTÃO FUNCIONANDO

#LOCAL – inicio#

# o arquivo ISO não pode estar em /media jah que esse caminho exige login

menuentry "antiX ISO via home 0,1" {


set isofile="/home/dojai/Downloads/ISOs/MX-23.3_ahs_x64.iso"
loopback loop (hd0,1)$isofile
linux (loop)/antiX/vmlinuz boot=isolinux iso-scan/filename=${isofile} quiet splash
initrd (loop)/antiX/initrd.gz
}

menuentry "antiX ISO via sdb1 1,1" {


set isofile="/ISOs/MX-23.3_ahs_x64.iso"
loopback loop (hd1,1)$isofile
linux (loop)/antiX/vmlinuz boot=isolinux iso-scan/filename=${isofile} quiet splash
initrd (loop)/antiX/initrd.gz
}

#LOCAL – fim#
em junho 2024: https://pendrivelinux.com/boot-multiple-iso-from-usb-via-grub2-using-linux/

Boot Multiple ISO from USB via GRUB2


Updated by Lance • July 12, 2022
Boot Multiple ISO from USB using GRUB2 from Linux. Here is one way to manually create a
Multiboot USB Flash Drive (Multiboot ISOs) from a running Linux environment. Allowing you to
store and run Multiple ISO files from one single USB drive.

More Grub2 Bootable ISO files will be added to the grub.cfg file as I find time to test them. Contact
me to submit your working Bootable Linux ISO grub.cfg entries for inclusion.

UPDATE: There is now an updated method to boot Multiple ISO from USB from an exFAT
formatted flash drive. <- This method includes a grub.cfg that makes it possible to simply drag and
drop ISO files onto the USB drive and then boot from them.

If you have access to a Windows machine, the YUMI – exFAT Multiboot USB Maker Software
Tool completely automates this process.

Eventually you might find the need to pick up a larger external storage device in order to include
every bootable ISO entry. Here are some of the Fastest USB flash drives that I personally use and
recommend.
How to Boot Multiple ISO from USB using GRUB2
I. Format a USB Flash Drive to use a Single Partition

The following assumes you are already up and running from a Linux desktop with your flash drive
plugged in. Ubuntu was used for this tutorial. Most Debian based systems will also work.

1. First you need to open a terminal. To do this press ctrl+alt+t


2. To gain root access, type the following and then press Enter.

sudo su

3. Next, to find out which device belongs to your usb, type

fdisk -l

4. Note which device belongs to your usb flash drive.


Use fdisk -l to locate usb device - Boot Multiple ISO from USB
5. Now you need to allow fdisk to access the device.
To allow fdisk access to modify the device, type the following (making sure to replace x with your
actual usb device).

fdisk /dev/sdx

WARNING any data on the partition will be wiped clean in step 6.


6. Next, type d (to delete the existing partition)
7. Then, type n (to create a new partition)
8. Type p (for primary partition)
9. Type 1 (to create the first partition)
10. Press Enter (to use the first cylinder)
11. Press Enter again (to use the default value as the last cylinder)
12. Type a (to mark the first partition active "bootable")
13. Type t (for partition type)
14. Type c (to use fat32 partition)
15. Type w (to write the changes and close fdisk)
II. Create a Fat32 Filesystem on a USB Flash Drive

For the following steps, replace x with your usb device.

1. First, you might have to unmount the mounted partition (it may or may not be mounted). To
unmount, type the following and press Enter.

umount /dev/sdx1

2. Then to format the partition as fat32, type

mkfs.vfat -F 32 -n MULTIBOOT /dev/sdx1

III. Install Grub2 on a USB Flash Drive

Important Note:
Old versions of grub used --root-directory=/mnt/USB
while current versions use --boot-directory=/mnt/USB/boot

If you use the wrong syntax, you will receive an error stating "Installation is impossible. Aborting"

Again, for the following steps replace x with your actual usb device.

1. First, you need to remount your usb device partition to make it accessible to Grub for install.

To remount the partition, type

mkdir /mnt/USB && mount /dev/sdx1 /mnt/USB

2. Next, use ONE of the steps below to install Grub2 on the USB device.
a.) If Grub2 64 bit UEFI x86_64-efi is used on the Linux host, then type

grub-install --force --removable --no-floppy --target=x86_64-efi --boot-directory=/mnt/USB/boot --


efi-directory=/mnt/USB

b.) If Grub2 32 bit UEFI i386-efi is used on the Linux host, then type

grub-install --force --removable --no-floppy --target=i386-efi --boot-directory=/mnt/USB/boot --efi-


directory=/mnt/USB

c.) If Grub2 BIOS i386-pc is used on the Linux host, then type

grub-install --force --removable --no-floppy --target=i386-pc --boot-directory=/mnt/USB/boot


/dev/sdx
3. Then you want to change to the grub directory so that you can add a configuration file.
To change to the grub directory, type

cd /mnt/USB/boot/grub

4. Finally, to download a Multiboot ISO grub2 configuration file, type

wget pendrivelinux.com/downloads/multibootlinux/grub.cfg

This example configuration uses grub2 loopback mounting for the ISO files.↑
IV. Adding Bootable ISO files to USB

1. First, you want to change to the root directory of your USB.

This step assumes your USB is still mounted... else repeat section III. (part 1)

To change to the root directory of the mounted USB, type

cd /mnt/USB

2. Next, from the tabs below, simply follow the instructions for each ISO Distro you would like to
add to make bootable from USB.

For USB Ubuntu, type the following in the terminal, and press Enter.

wget "http://releases.ubuntu.com/groovy/ubuntu-20.10-desktop-amd64.iso" -O ubuntu.iso

Alternately you can rename an existing ISO to ubuntu.iso and copy it to the USB device.

For USB Debian Live, type the following in the terminal, and press Enter.

wget "https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-10.6.0-
amd64-gnome.iso" -O debian.iso

For USB Linux Mint, type the following in the terminal, and press Enter.

wget "http://mirrors.gigenet.com/linuxmint/iso/stable/20/linuxmint-20-cinnamon-64bit.iso" -O
linuxmint.iso

Or rename your existing ISO to linuxmint.iso and copy it to your drive.

For USB dban, type the following in the terminal, and press Enter.

wget "downloads.sourceforge.net/project/dban/dban/dban-2.3.0/dban-2.3.0_i586.iso" -O dban.iso

Or rename your existing ISO to dban.iso and copy it to your flashdrive.

For USB TinyCore, type the following in the terminal, and press Enter.

wget "distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/release/tinycore-current.iso" -O
tinycore.iso
Or rename your existing ISO to tinycore.iso and copy it to your external drive.

For MemTest86+, type the following in the terminal, and press Enter.

wget memtest.org/download/5.31b/memtest86+-5.31b.bin.zip

To unzip, type the following in the terminal, and press Enter.

unzip memtest86+-5.31b.bin.zip

Then to copy, type the following in the terminal, and press Enter.

cp memtest86+-5.31b.bin memtest86+.bin

Or extract the contents of your existing memtest86+ zip file. Rename the bin to memtest86+.bin and
copy it to your USB device

Adding an Unlisted ISO: To try ISO Files that are not yet listed, use the existing menuentry
examples in /boot/grub/grub.cfg and append any options normally found in the distributions
syslinux.cfg file on the "append" line to the "linux" line of the menu entry.

Please inform me of entries you get to work and I will add them to the list, so that others may
benefit as well.
V. Test that your computer can Boot Multiple ISO from USB

Reboot your Computer, and enter your BIOS or Boot Menu. Set the Boot Order to boot from the
USB Device. Save your changes and then Reboot.

If all went well, you should be presented with a Grub2 Boot Menu containing the USB bootable
entries you previously added. Concluding How to create a Multiboot USB which can be used to
Boot Multiple ISO from USB.

You might also like