4.4. Preparando os Arquivos para a Inicialização usando o Memory Stick USB

Para preparar a memória stick USB, será necessário um sistema onde o GNU/Linux já esteja sendo executado e que tenha suporte a USB. Tenha certeza que o módulo do kernel usb-storate está carregado ( modprobe usb-storage) e tente achar o dispositivo SCSI que recebeu a associação com a memória stick USB (neste exemplo será usado o dispositivo /dev/sda). Para gravar em sua memória stick primeiro desative a proteção contra gravação.

Note que a memória stick USB deverá ter pelo menos 128MB de tamanho (tamanhos menores são possíveis se seguir os passos em Seção 4.4.2, “Copiando os arquivos — o método flexível”).

4.4.1. Copiando os arquivos — o método fácil

Existe um arquivo tudo em um chamado hd-media/boot.img.gz que contém todos os arquivos do programa de instalação (incluindo o kernel) também como o SYSLINUX e seu arquivo de configuração. Você terá somente que descompacta-lo diretamente para sua memória stick USB:

# zcat boot.img.gz > /dev/sda

É claro que isto destruirá qualquer coisa que já esteja no dispositivo, assim tenha cuidado de usar o nome de dispositivo correto em sua memória stick USB.

Após isto, monte a memória stick USB (mount /dev/sda /mnt), que agora terá um sistema de arquivos FAT dentro dele e copie a imagem ISO Debian netinst ou cartão de visita para lá. Note que o nome de arquivo deverá finalizar em .iso. Desmonte a memória stick (umount /mnt) e você terá concluído.

4.4.2. Copiando os arquivos — o método flexível

Se quiser mais flexibilidade ou apenas deseja saber o que está acontecendo, você deverá usar o seguinte método para armazenar os arquivos em sua memória stick.

4.4.2.1. USB stick partitioning on Intel x86

We will show how to setup the memory stick to use the first partition, instead of the entire device.

Nota

Since most USB sticks come pre-configured with a single FAT16 partition, you probably won't have to repartition or reformat the stick. If you have to do that anyway, use cfdisk or any other partitioning tool for creating a FAT16 partition and then create the filesystem using:

# mkdosfs /dev/sda1

Take care that you use the correct device name for your USB stick. The mkdosfs command is contained in the dosfstools Debian package.

In order to start the kernel after booting from the USB stick, we will put a boot loader on the stick. Although any boot loader (e.g. LILO) should work, it's convenient to use SYSLINUX, since it uses a FAT16 partition and can be reconfigured by just editing a text file. Any operating system which supports the FAT file system can be used to make changes to the configuration of the boot loader.

To put SYSLINUX on the FAT16 partition on your USB stick, install the syslinux and mtools packages on your system, and do:

# syslinux /dev/sda1

Again, take care that you use the correct device name. The partition must not be mounted when starting SYSLINUX. This procedure writes a boot sector to the partition and creates the file ldlinux.sys which contains the boot loader code.

Mount the partition (mount /dev/sda1 /mnt) and copy the following files from the Debian archives to the stick:

  • vmlinuz (kernel binary)

  • initrd.gz (initial ramdisk image)

  • syslinux.cfg (SYSLINUX configuration file)

  • Optional kernel modules

If you want to rename the files, please note that SYSLINUX can only process DOS (8.3) file names.

The syslinux.cfg configuration file should contain the following two lines:

default vmlinuz
append initrd=initrd.gz ramdisk_size=12000 root=/dev/rd/0 init=/linuxrc rw

Please note that the ramdisk_size parameter may need to be increased, depending on the image you are booting. If the boot fails, you can try adding devfs=mount,dall to the “append” line.

4.4.2.2. Adicionando uma imagem ISO

Agora você deverá colocar qualquer imagem ISO da Debian (businesscard, netinst ou até mesmo uma completa) em sua memória stick (caso couber em seu espaço livre). O nome de arquivo da imagem deverá ser finalizado em .iso.

Se quiser instalar através da rede, sem usar uma imagem ISO, você deverá, é claro, pular o passo anterior. Ainda em tempo, voce deverá usar um disco de memória ram inicial do diretório netboot ao invés do que se encontra em hd-media, porque o hd-media/initrd.gz não possui suporte a rede.

Quando terminar, desmonte a memória stick USB (umount /mnt) e ative sua proteção contra gravação.

4.4.2.3. Inicialização através da memória stick USB

Atenção

Caso seu sistema se recusar em inicializar a partir da memória stick, ela poderá conter uma MBR inválida (master boot record). Para corrigir isto, use o comando install-mbr que vem no pacote mbr:

# install-mbr /dev/sda