Template:Copying Alpine to Flash: Difference between revisions

From Alpine Linux
(Changed formatting, added setup-bootable option, added troubleshooting for wrong device name)
Line 1: Line 1:
== Copy Alpine to a {{{1|Flash Medium}}} ==
== Install Alpine to a {{{1|Flash Medium}}} ==
# Boot the computer from the Alpine Linux CD-ROM
# Boot the computer from the Alpine Linux CD-ROM
# Insert the removable {{{1|flash medium (CF or USB stick)}}} into the computer.
# Insert the removable {{{1|flash medium (CF or USB stick)}}} into the computer.
Line 11: Line 11:


=== Format {{{1|Flash Medium}}} ===
=== Format {{{1|Flash Medium}}} ===
Run fdisk (replacing sda with your flash media name):
{{Cmd|fdisk /dev/sda}}
{{Cmd|fdisk /dev/sda}}
* '''p''' Print list of partitions
* '''d''' Delete all partitions (this may take a few steps)
* '''n''' Create a new partition
* '''p''' A primary partition
* '''1''' Partition number 1
** Use defaults for first and last cylinder (just press [Enter] twice).
* '''t''' Change partition type
* '''c''' Type: Win95 FAT32 (LBA)
* '''a''' <big>Make the partition bootable (set boot flag)</big>
* '''1''' Partition number 1
* '''w''' Write your changes to the device


=== Install Syslinux ===
# (''Optional'') - Create new partition table with one FAT32 partition
#* '''d''' Delete all partitions (this may take a few steps)
#* '''n''' Create a new partition
#* '''p''' A primary partition
#* '''1''' Partition number 1
#** Use defaults for first and last cylinder (just press [Enter] twice).
#* '''t''' Change partition type
#* '''c''' Type: Win95 FAT32 (LBA)
#Verify that the primary partition is bootable
#* '''p''' Print list of partitions
#* If there is no '*' next to the first partition, follow the next steps:
#** '''a''' <big>Make the partition bootable (set boot flag)</big>
#** '''1''' Partition number 1
#'''w''' Write your changes to the device
 
=== Install Alpine Linux ===
You can install using the Automated OR Manual steps below:
==== Automated ====
{{Tip|If using Alpine Linux 1.10.4 or newer, you can use this section to complete the install. Otherwise, follow the Manual steps below.}}
# Run the setup-bootable script to install Alpine Linux (replacing sda with your {{{1|flash medium}}} name):
#* {{Cmd|setup-bootable /media/cdrom /dev/sda}}
 
=== Manual ===
{{Note|If the following commands fail due to 'No such file or directory', you may have to remove and reinsert the CF card, or even reboot, to get /dev/sda1 to appear}}
{{Note|If the following commands fail due to 'No such file or directory', you may have to remove and reinsert the CF card, or even reboot, to get /dev/sda1 to appear}}
# Install syslinux and dosfstools. If you have booted from an Alpine CD-ROM, use these commands:
# (''Optional'') - If you created a new partition above, format the {{{1|flash medium}}} with a FAT32 filesystem (replacing sda with your {{{1|flash medium}}} name):
#* {{Cmd|apk add syslinux dosfstools}}
#* {{Cmd|apk add dosfstools<BR>mkdosfs -F32 /dev/sda1}}
#* {{Cmd|{{{|dd if=/usr/share/syslinux/mbr.bin of=/dev/sda}}}}}
# Install syslinux and MBR (replacing sda with your {{{1|flash medium}}} name):
# Format the {{{1|flash medium}}} with a VFAT filesystem:
#* {{Cmd|{{{|dd if=/usr/share/syslinux/mbr.bin of=/dev/sda}}}<BR>apk add syslinux<BR>syslinux /dev/sda1}}
#* {{Cmd|mkdosfs -F32 /dev/sda1}}
#Copy the files to the {{{1|flash medium}}} (replacing sda with your {{{1|flash medium}}} name):
#* {{Cmd|syslinux /dev/sda1}}
#* {{Cmd|mkdir -p /media/sda1<BR>mount -t vfat /dev/sda1 /media/sda1<BR>cd /media/cdrom<BR>cp -a .alpine-release * /media/sda1/<BR>umount /media/sda1}}
#* {{Cmd|mkdir -p /media/sda1}}
#* {{Cmd|mount -t vfat /dev/sda1 /media/sda1}}
#Copy the files to the {{{1|flash medium}}}
#* {{Cmd|cd /media/cdrom}}
#* {{Cmd|cp -a .alpine-release * /media/sda1/ }}


== Troubleshooting ==
== Troubleshooting ==
When your USB device is formatted to other filesystem than fat32, you might have to specify the necessary filesystem modules in boot parameters.
=== Wrong Device Name ===
If you cannot boot from the {{{1|flash medium}}} and you see something like:
Mounting boot media failed.
initramfs emergency recovery shell launched. Type 'exit' to continue boot
then it is likely that the device name in syslinux.cfg is wrong. You should replace the device name in the syslinux.cfg line:
append initrd=/boot/grsec.gz alpine_dev='''usbdisk''':vfat modules=loop,cramfs,sd-mod,usb-storage quiet
with the proper device name.
* For boot from USB, the device name should be 'usbdisk' (as shown above)
* For other options, you can run '''cat /proc/partitions''' to see the available disks (i.e. 'sda' or 'sdb')
 
=== Non-FAT32 Filesystems ===
When your {{{1|flash medium}}} is formatted with a filesystem other than FAT32, you might have to specify the necessary filesystem modules in the boot parameters.


To do so, mount the device, and alter the syslinux.cfg file line from  
To do so, mount the {{{1|flash medium}}} and change the syslinux.cfg file line from  
  append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet
  append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet
to
to
  append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage,ext3 quiet
  append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage''',ext3''' quiet
 
in the case of an ext3 formatted partition. A similar procedure might apply to other filesystems (if they are supported by syslinux and the Alpine Linux kernel).
in case of using ext3 formatted partition. Similar procedure might apply to other filesystems (if they are supported by syslinux or other bootloader of your choice and alpine kernel).


Also, specifying waitusb=X option might help with certain usb devices that take a bit longer to register. X stands for the amount of seconds kernel will wait before looking for the installation media.
=== Slow USB Devices ===
Specifying the 'waitusb=X' option at the end of the syslinux.cfg line might help with certain USB devices that take a bit longer to register. X stands for the amount of seconds kernel will wait before looking for the installation media.
append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet '''waitusb=3'''

Revision as of 09:22, 16 November 2011

Install Alpine to a Flash Medium

  1. Boot the computer from the Alpine Linux CD-ROM
  2. Insert the removable flash medium (CF or USB stick) into the computer.
  3. Determine the name your computer uses for your flash medium. The following step is one way to do this.
    • After inserting the flash medium, run the command:
    • dmesg

    • At the end of this command you should see the name of your flash medium, likely starting with "sd". (For example: "sda").
    • The remainder of this document will assume that your flash medium is called /dev/sda
Warning: Be very careful about this. You do not want to mistakenly wipe your hard drive if it's on /dev/sda


Format Flash Medium

Run fdisk (replacing sda with your flash media name):

fdisk /dev/sda

  1. (Optional) - Create new partition table with one FAT32 partition
    • d Delete all partitions (this may take a few steps)
    • n Create a new partition
    • p A primary partition
    • 1 Partition number 1
      • Use defaults for first and last cylinder (just press [Enter] twice).
    • t Change partition type
    • c Type: Win95 FAT32 (LBA)
  2. Verify that the primary partition is bootable
    • p Print list of partitions
    • If there is no '*' next to the first partition, follow the next steps:
      • a Make the partition bootable (set boot flag)
      • 1 Partition number 1
  3. w Write your changes to the device

Install Alpine Linux

You can install using the Automated OR Manual steps below:

Automated

Tip: If using Alpine Linux 1.10.4 or newer, you can use this section to complete the install. Otherwise, follow the Manual steps below.
  1. Run the setup-bootable script to install Alpine Linux (replacing sda with your flash medium name):
    • setup-bootable /media/cdrom /dev/sda

Manual

Note: If the following commands fail due to 'No such file or directory', you may have to remove and reinsert the CF card, or even reboot, to get /dev/sda1 to appear
  1. (Optional) - If you created a new partition above, format the flash medium with a FAT32 filesystem (replacing sda with your flash medium name):
    • apk add dosfstools
      mkdosfs -F32 /dev/sda1

  2. Install syslinux and MBR (replacing sda with your flash medium name):
    • dd if=/usr/share/syslinux/mbr.bin of=/dev/sda
      apk add syslinux
      syslinux /dev/sda1

  3. Copy the files to the flash medium (replacing sda with your flash medium name):
    • mkdir -p /media/sda1
      mount -t vfat /dev/sda1 /media/sda1
      cd /media/cdrom
      cp -a .alpine-release * /media/sda1/
      umount /media/sda1

Troubleshooting

Wrong Device Name

If you cannot boot from the flash medium and you see something like:

Mounting boot media failed.
initramfs emergency recovery shell launched. Type 'exit' to continue boot

then it is likely that the device name in syslinux.cfg is wrong. You should replace the device name in the syslinux.cfg line:

append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet

with the proper device name.

  • For boot from USB, the device name should be 'usbdisk' (as shown above)
  • For other options, you can run cat /proc/partitions to see the available disks (i.e. 'sda' or 'sdb')

Non-FAT32 Filesystems

When your flash medium is formatted with a filesystem other than FAT32, you might have to specify the necessary filesystem modules in the boot parameters.

To do so, mount the flash medium and change the syslinux.cfg file line from

append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet

to

append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage,ext3 quiet

in the case of an ext3 formatted partition. A similar procedure might apply to other filesystems (if they are supported by syslinux and the Alpine Linux kernel).

Slow USB Devices

Specifying the 'waitusb=X' option at the end of the syslinux.cfg line might help with certain USB devices that take a bit longer to register. X stands for the amount of seconds kernel will wait before looking for the installation media.

append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet waitusb=3