Creating an AMI
From Bashlinux
The image created here is based on CentOS Linux.
How to create a File to host the CentOS AMI
A base CentOS Linux installation requires about 1.2 GB, but custom installation for a server environment might require up to 3.0 GB.
- Create a location to place the CentOS AMI
# mkdir -p /usr/local/src/EC2
- Create a file to host the CentOS AMI
# dd if=/dev/zero of=/usr/local/src/EC2/bashlinux-server.fs bs=1M count=3072 3072+0 records in 3072+0 records out 3221225472 bytes (3.2 GB) copied, 118.687 seconds, 27.1 MB/s
How to create a Root File System inside a file
Create an ext3 file system
mke2fs -F -j /usr/local/src/EC2/bashlinux-server.fs mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 393216 inodes, 786432 blocks 39321 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=805306368 24 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 30 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
- Mount the File via the loop device
- Create a mount point in the file system where the image will be attached
# mkdir -p /mnt/EC2-FS
- Mount the file system image
mount -o loop /usr/local/src/EC2/bashlinux-server.fs /mnt/EC2-FS/
- Prepare for the Installation
- Create a /dev directory and populate it with a minimal set of devices. You can ignore the errors in the output
# mkdir -p /mnt/EC2-FS/dev # MAKEDEV -d /mnt/EC2-FS/dev -x console # MAKEDEV -d /mnt/EC2-FS/dev -x null # MAKEDEV -d /mnt/EC2-FS/dev -x zero # mkdir -p /mnt/EC2-FS/etc