From Fedora Project Wiki

Creating a Fedora Install Image for ARM Systems

This will track the work to add ARM support to the standard Fedora installation tools (Anaconda/Lorax).

The plan is to initially use livemedia-creator to create disk images that can be stored directly on an SDCard to boot a device (e.g., Trim Slice), or booted via an ARM emulator like QEMU. Since most of these devices do not boot from standard media (CD/DVD), the ultimate goal is to be able to perform network installs via Anaconda after PXE-booting a device. Hopefully, the interim work to add ARM support and create disk images will move us closer to that goal.

Pre-Alpha Quality Code
This is a work in progress and is Pre-Alpha quality code. Do not use this on production systems, as it may break things or destroy your current installation. It is for development and testing only, and has received no formal testing. Use at your own risk!

Creating a Disk Image for Trim Slice

Anaconda and Lorax have been modified to recognize some common ARM systems that we are using and select the appropriate kernel for installation. The livemedia-creator tool can be run on an ARM build host to create a disk image for that target. The installation is controlled by a kickstart configuration file. The image created can be copied directly to an SDCard and used to boot the system, for systems so equipped.

A Trim Slice was used for development and testing of this process because 1) it has an easily accessible SDCard slot, 2) U-Boot is pre-installed on internal storage, so does not have to be set up on the boot media, 3) no special formatting is required for the /boot partition, and ext3 loads are supported, and 4) U-Boot is configured to automatically boot from the SDCard, if present.

The modified versions of Anaconda, Lorax, and grubby are not available from the Fedora-ARM mirrors (changes not committed to F17), so they must be installed from the F17 xpfa repo.


Set Up the Repository

From an F17 ARM system, install the xpfa repo package:

  • get the eXtra Packages for Fedora ARM (xpfa) yum repository definition:
sudo yum --nogpgcheck install http://dmarlin.fedorapeople.org/packages/FedoraArm/RPMS/noarch/xpfa-17-1.noarch.rpm
  • update grubby to get the modified version:
sudo yum --enablerepo=xpfa update grubby
  • make any changes to the U-Boot configuration (if needed):
sudo vi /etc/sysconfig/uboot
  • install Anaconda and Lorax
sudo yum --enablerepo=xpfa install anaconda lorax
Default Change
The default U-Boot directory is changed to /boot in this modified version of grubby. This works fine for the Trim Slice, but may break kernel installs for other boards.


Building the Image

On the target build host, log in as 'root', and perform the following steps.

  • set up a kickstart file

I recommend first using the F17-trimslice.ks file as a test to make sure everything is set up and working as expected. Then use it as a base for creating other kickstart configuration files.

  • run livemedia-creator
livemedia-creator \
  --make-disk --no-virt --image-only --keep-image \
  --ks=/root/F17-trimslice.ks

The disk image is created in /tmp/disk<TempString>.img. When the process completes, the contents of the disk image may be examined by loop-mounting the image file.

The trimslice.ks defines three partitions:

 /boot
 /
 swap

These will be mapped in order, for example:

# kpartx -av <PathToDiskImage>
add map loop0p1 (253:0): 0 522240 linear /dev/loop0 2048
add map loop0p2 (253:1): 0 2621440 linear /dev/loop0 524288
add map loop0p3 (253:2): 0 1046528 linear /dev/loop0 3145728

# ls -l /dev/mapper
total 0
crw------- 1 root root 10, 236 Feb 11 00:46 control
lrwxrwxrwx 1 root root       7 Apr 25 18:49 loop0p1 -> ../dm-0
lrwxrwxrwx 1 root root       7 Apr 25 18:49 loop0p2 -> ../dm-1
lrwxrwxrwx 1 root root       7 Apr 25 18:49 loop0p3 -> ../dm-2

# mkdir -p /mnt/rootfs

# mount -o loop /dev/dm-1 /mnt/rootfs
[108293.766690] EXT4-fs (loop1): mounted filesystem with ordered data mode. Opts: (null)

# mount -o loop /dev/dm-0 /mnt/rootfs/boot
[108293.906412] kjournald starting.  Commit interval 5 seconds
[108293.906531] EXT3-fs (loop2): using internal journal
[108293.906545] EXT3-fs (loop2): mounted filesystem with ordered data mode

# pushd /mnt/rootfs/
/mnt/rootfs ~

# ls -l 
total 74
lrwxrwxrwx   1 root root     7 Apr 25  2012 bin -> usr/bin
dr-xr-xr-x.  4 root root  1024 Apr 25  2012 boot
drwxr-xr-x.  2 root root  4096 Apr 25  2012 dev
drwxr-xr-x  68 root root  4096 Apr 25  2012 etc
drwxr-xr-x   2 root root  4096 Feb 11 00:46 home
lrwxrwxrwx   1 root root     7 Apr 25  2012 lib -> usr/lib
drwx------.  2 root root 16384 Apr 25  2012 lost+found
drwxr-xr-x   2 root root  4096 Feb 11 00:46 media
drwxr-xr-x   2 root root  4096 Feb 11 00:46 mnt
drwxr-xr-x   2 root root  4096 Feb 11 00:46 opt
drwxr-xr-x   2 root root  4096 Apr 25  2012 proc
dr-xr-x---.  2 root root  4096 Apr 25  2012 root
drwxr-xr-x  14 root root  4096 Apr 25  2012 run
lrwxrwxrwx   1 root root     8 Apr 25  2012 sbin -> usr/sbin
drwxr-xr-x   2 root root  4096 Feb 11 00:46 srv
drwxr-xr-x.  2 root root  4096 Apr 25  2012 sys
drwxrwxrwt   2 root root  4096 Apr 25  2012 tmp
drwxr-xr-x  12 root root  4096 Apr 25  2012 usr
drwxr-xr-x  17 root root  4096 Apr 25  2012 var

# ls -l boot/
total 43468
-rw-------  1 root root  1527901 Apr 15 09:36 System.map-3.3.2-2.fc17.armv7hl.tegra
-rw-r--r--  1 root root      225 Apr 25  2012 boot.cmd
-rw-r--r--  1 root root      297 Apr 25  2012 boot.scr
-rw-r--r--  1 root root   107705 Apr 15 09:36 config-3.3.2-2.fc17.armv7hl.tegra
drwxr-xr-x  2 root root     1024 Apr 25  2012 grub
-rw-r--r--  1 root root 10645211 Apr 25  2012 initramfs-3.3.2-2.fc17.armv7hl.tegra.img
-rw-r--r--  1 root root       27 Apr 25  2012 klist.txt
drwx------. 2 root root    12288 Apr 25  2012 lost+found
-rw-r--r--  1 root root  3578336 Apr 25  2012 uImage
-rw-r--r--  1 root root  3578336 Apr 25  2012 uImage-3.3.2-2.fc17.armv7hl.tegra
-rw-r--r--  1 root root 10645275 Apr 25  2012 uInitrd
-rw-r--r--  1 root root 10645275 Apr 25  2012 uInitrd-3.3.2-2.fc17.armv7hl.tegra
-rwxr-xr-x  1 root root  3578272 Apr 15 09:36 vmlinuz-3.3.2-2.fc17.armv7hl.tegra


# cat etc/system-release
Fedora release 17 (Beefy Miracle)

# cat etc/RELEASE 
F17-20120424-livemedia


# popd
~

# umount /mnt/rootfs/boot
# umount /mnt/rootfs

# kpartx -dv <PathToDiskImage>
del devmap : loop0p3
del devmap : loop0p2
del devmap : loop0p1
loop deleted : /dev/loop0

Complete the Process
Please be sure to unmount the disk image partitions and delete the loop device. Failing to do so may leave old allocated devices that are difficult to clean up.

Installing the Image

This disk image is suitable to be copied directly to an SDCard. It could similarly be copied to other media, but only using an SDCard has been tested.

To copy this to an SDCard from my workstation, I plugged the SDCard into a USB adapter, inserted the adapter to an open USB slot, and checked /proc/partitions to see where it was located. For this example, assume it was located on /dev/sdb.

# cat /proc/partitions 
major minor  #blocks  name
   8        0   78150744 sda
   8        1     512000 sda1
   8        2   77637632 sda2
   8       16    7879680 sdb
   8       17    7875584 sdb1

To transfer the image to the device, make sure it is not mounted.

# umount /dev/sdb1

Then copy the disk image to the raw device.

# xzcat <PathToDiskImage> | dd of=/dev/sdb
Data Loss
Make certain the target of the dd command is the location of the SDCard device. All partitions and data on this device will be overwritten, so make sure it contains nothing you wish to keep. Again, ALL DATA WILL BE LOST!
Please Be Patient
Depending on the size and speed of the SDCard, this operation may take a while. Do not interrupt the process before it is complete. Do not remove the SDCard.

Once the transfer completes, the partition table will need to be rescanned and updated.

# partprobe /dev/sdb

The device partitions may then be mounted and the contents examined, or the device may be ejected and moved to test booting on the target system.