Installing Alpine on Compact Flash

From Alpine Linux

Jump to: navigation, search

Contents

Creating a bootable Alpine Linux Compact Flash (CF)

This process applies to Alpine Linux 1.9.0 or later, and results in a run-from-ram style installation.

Requirements

In order to follow this document, you will need:

Boot Alpine Linux CD-ROM

  1. Insert the Alpine Linux CD-ROM into a computer.
  2. Boot the computer from the Alpine Linux CD-ROM.
    • This step may require changes to the BIOS settings to select booting from CD.
  3. Login with the username root. No password is needed.

Determine the Device Name of the CF Card

Determine the name your computer uses for your CF Card. The following step is one way to do this.

  1. After inserting the CF Card, run the command:
    • dmesg

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

Format CF Card

Run fdisk (replacing sda with your CF Card 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

Add Alpine Linux to the CF Card

To boot from your CF Card you need to copy the contents of the CDROM to the CF Card and make it bootable. Those two operations can be automated with the setup-bootable tool or can be done manually.

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

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 add Alpine Linux to the CF Card and make it bootable (replacing sda with your CF Card name):

    setup-bootable /media/cdrom /dev/sda1

Tango-dialog-warning.png
Warning: If you are installing to a USB Stick, the setup-bootable script will not use usbdisk in the syslinux.cfg file. You should modify it to say usbdisk as described below, or you will face possible problems booting and definite problems with the package cache.

Manual

  1. (Optional) - If you created a new partition above, format the CF Card with a FAT32 filesystem (replacing sda with your CF Card name):

    apk add dosfstools
    mkdosfs -F32 /dev/sda1

  2. Install syslinux and MBR (replacing sda with your CF Card name):

    apk add syslinux
    dd if=/usr/share/syslinux/mbr.bin of=/dev/sda
    syslinux /dev/sda1

  3. Copy the files to the CF Card (replacing sda with your CF Card 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 CF Card 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.

Non-FAT32 Filesystems

When your CF Card 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 CF Card 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).

DMA Support

Many CF card readers don't support DMA correctly, so you may need to add nodma to the append line of the syslinux.cfg file.

See Also

Alpine Linux has some special applications that helps you to use it in the way you want.
Some of the first scripts you are suggested to use is:

Note: Just type any of the above commands on your console and hit Enter to execute the script.

Other useful pages

Personal tools
Namespaces
Variants
Actions
Welcome
Services
Wiki
Toolbox