From Fedora Project Wiki
(→‎Creating a Rootfs Disk Image: added step to run init-rootfs.sh)
(fixed links)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:AArch64]]
Please check [[Architectures/AArch64/FoundationModelQuickStart | Foundation model quick start]] page for ready to use images.
This page describes the process for building a RootFS for the [[Architectures/ARM/AArch64/FoundationModel|Foundation Model]].


== Creating a Rootfs Disk Image ==
#REDIRECT [[Architectures/AArch64/FoundationModelQuickStart]]
If you need to either re-create or substantively modify the rootfs disk image provided, it takes a little doing, but isn't too big a deal.  The first step is to create a file that will contain the disk image:
<pre>
$ dd if=/dev/zero of=rootfs.img bs=1M count=8192
</pre>
This creates an image about 8GB in size; bump it up as needed, of course.  Next, we need to put two partitions into the image using something like fdisk:
<pre>
$ fdisk rootfs.img
</pre>
Create two partitions -- a small, bootable FAT partition (~25-50MB), and the remainder an ext3 partition; I assume here I don't need to provide detailed steps for using fdisk.  When you're done, it'll look something like this:
<pre>
$ fdisk -l fedora17-stage2-armv8.img
 
Disk fedora17-stage2-armv8.img: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders, total 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x093138f0
                    Device Boot      Start        End      Blocks  Id  System
fedora17-stage2-armv8.img1  *        2048      104447      51200    e  W95 FAT16 (LBA)
fedora17-stage2-armv8.img2          104448    8388607    4142080  83  Linux
</pre>
We can use kpartx and some other tools to create block devices for the partitions, put file systems on them, and then mount them in /tmp:
<pre>
$ sudo kpartx -a -v rootfs.img
add map loop0p1 (253:6): 0 106432 linear /dev/loop0 63
add map loop0p2 (253:7): 0 4087808 linear /dev/loop0 106496
$ mkfs.vfat /dev/mapper/loop0p1
...
$ mkfs.ext3 /dev/mapper/loop0p2
...
$ mkdir /tmp/vfat
$ mkdir /tmp/ext3
$ sudo mount /dev/mapper/loop0p1 /tmp/vfat
$ sudo mount /dev/mapper/loop0p2 /tmp/ext3
</pre>
Only one file is needed in the FAT partition; retrieve it and copy it in, then release the partition from use:
<pre>
$ cd ~/armv8
$ wget http://fedorapeople.org/groups/armv8/u-boot.bin
$ sudo cp u-boot.bin /tmp/vfat
$ sudo sync
$ sudo umount /tmp/vfat
</pre>
The ext3 partition is where all the fun stuff is -- it's the actual rootfs with all the interesting ARMv8 executables (not that the kernel is boring, mind you...).  To recreate the image that one could have fetched, we can pull it from git and then use cpio to copy it in properly (NB: note the running of the script <code>init-rootfs.sh</code> which is required to ensure that several empty directories and device files are present since git does not store them):
<pre>
$ cd ~/armv8
$ git clone -b stage2 git://fedorapeople.org/~ahs3/rootfs.git
$ cd rootfs
$ sudo ./init-rootfs.sh
$ sudo sh -c "find . -print | cpio -pdumv /tmp/ext3"
$ sudo sync
$ sudo umount /tmp/ext3
</pre>
And we're all done.
 
To use this file system image, it's simply a matter of replacing the value of the --block-image parameter when running the FM:
<pre>
$ fv8 --image img-foundation.axf --block-device rootfs.img --network=nat
</pre>

Latest revision as of 15:00, 6 November 2014

Please check Foundation model quick start page for ready to use images.

  1. REDIRECT Architectures/AArch64/FoundationModelQuickStart