Create a Root File System Inside the File
There are several variations on the generic mkfs utility that can be used to create a file system inside
my-image.fs. Typical Linux installations default to ext2 or ext3 file systems. Create an ext3 file
system by issuing the following command:
# mke2fs -F -j my-image.fs
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
131072 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Mount the File via Loopback
The loopback module allows you to use a normal file as if it were a raw device. In this manner you get a
file-system in a file. Mounting a file system image file via loopback presents it as part of the normal file
system. You can then modify it using your favourite file management tools and utilities. Create a mount
point in the file system where the image will be attached and then mount the file system image, as
# mkdir /mnt/ec2-fs
# mount -o loop my-image.fs /mnt/ec2-fs
Prepare for the Installation
Before the operating system installation can proceed, some basic files have to be created and prepared
on the newly created root file system.
Create /dev
Create a /dev directory and populate it with a minimal set of devices (you can ignore the errors in the
# mkdir /mnt/ec2-fs/dev
# /sbin/MAKEDEV -d /mnt/ec2-fs/dev -x console
MAKEDEV: mkdir: File exists
MAKEDEV: mkdir: File exists
MAKEDEV: mkdir: File exists
# /sbin/MAKEDEV -d /mnt/ec2-fs/dev -x null
MAKEDEV: mkdir: File exists
MAKEDEV: mkdir: File exists
MAKEDEV: mkdir: File exists
# /sbin/MAKEDEV -d /mnt/ec2-fs/dev -x zero
MAKEDEV: mkdir: File exists
Amazon EC2
Developer Guide
MAKEDEV: mkdir: File exists
MAKEDEV: mkdir: File exists
Create /etc
Create an /etc directory:
# mkdir /mnt/ec2-fs/etc
Create /mnt/ec2-fs/etc/fstab and add the following entries to it:
/dev/sda1 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
Create yum-xen.conf
Create a temporary yum configuration file that will ensure all the required basic packages and utilities
are installed. This configuration file can be created anywhere on your main file system, but for now we'll
assume that you create it in your working directory. Just to clarify, it does not need to be created in the
loopback file system. It is used only during installation of the loopback file system. Create
yum-xen.conf with the following content:
name=Fedora Core 4 - $basearch - Base
name=Fedora Core 4 - $basearch - Released Updates
Mount proc
Due to a bug in the groupadd utility from the shadow-utils package (versions prior to 4.0.7-7), the
new proc file system needs to be mounted by hand at this point.
# mkdir /mnt/ec2-fs/proc
# mount -t proc none /mnt/ec2-fs/proc
Install the Operating System
At this stage all the basic directories and files have been created and you are ready to do the operating
system installation. This process might take a while depending on the speed of the host and the network
link to the repository.
# yum -c yum-xen.conf --installroot=/mnt/ec2-fs -y groupinstall Base
Amazon EC2
Developer Guide
Previous Page Next Page