Creating your own CentOS 6.2 x86_64 EBS AMI on Amazon with pv-grub kernel.

Creating your own CentOS 6.2 x86_64 EBS AMI on Amazon with pv-grub kernel.

This article assumes you have a running CentOS 6.2 system with ec2-ami-tools installed and setup.

1. Create an EBS volume in AWS and attach it to the S3 instance

2. Create a partition on the volume:
fdisk /dev/xvd{DRIVE_LETTER}

3. Create filesystem on the volume:
mkfs.ext4 /dev/xvd{DRIVE_LETTER}1

4. Create mount point and mount volume:
mkdir /mnt/ebs ; mount /dev/xvd{DRIVE_LETTER}1 /mnt/ebs

5. Rsync all the files from the S3 instance: (exclude commands are double dashes)
rsync -avH –exclude /dev –exclude /mnt –exclude /sys –exclude /proc /* /mnt/ebs/

6. Create system folders and devices:
mkdir /mnt/ebs/proc
mkdir /mnt/ebs/dev
mkdir /mnt/ebs/sys
MAKEDEV -d /mnt/ebs/dev -x zero
MAKEDEV -d /mnt/ebs/dev -x console
MAKEDEV -d /mnt/ebs/dev -x urandom
MAKEDEV -d /mnt/ebs/dev -x null

7. Change Grub to point to the first partition (hd0,0)
vi /mnt/ebs/boot/grub/grub.conf
default=0
timeout=3
title EC2
root (hd0,0)
kernel /boot/vmlinuz-2.6.32.x86_64 ro root=/dev/xvde1
initrd /boot/initramfs-2.6.32.x86_64.img

8. Unmount and disconnect volume from S3 instance
umount /mnt/ebs

9. Create snapshot of volume

10. Register snapshot as an AMI:
ec2-register –kernel aki-b4aa75dd -b “/dev/sda=”$snap”::true” –root-device-name “/dev/sda” -n “CentOS 6.2 Image” -a x86_64

About these ads

6 thoughts on “Creating your own CentOS 6.2 x86_64 EBS AMI on Amazon with pv-grub kernel.

  1. Hi, I’ve followed the steps you mentioned here and the machine is not accessible:

    Cannot ping
    Cannot get System Log – returns empty window.

    How can I debug this?
    I’ve created the machine with default “kernel” and default memory disk..

    Any ideas?

  2. I’ve tried your changes and now I have another errors:

    I’ve tried to put into grub/fstab, both
    /dev/sda1, /dev/xvde1, /dev/xvda1 without success. When tried xvde3, said it’s swapspace and not mountable.

    If i put /dev/sda1, I get:
    xlblk_init: register_blkdev major: 202
    blkfront: xvde: barriers disabled
    xvde: xvde1
    blkfront: xvde3: barriers disabled
    dracut Warning: No root device “block:/dev/sda1″ found
    dracut Warning: Boot has failed. To debug this issue add “rdshell” to the kernel command line.
    dracut Warning: Signal caught!

    Full error log:

    Xen Minimal OS!
    start_info: 0xce2000(VA)
    nr_pages: 0x6a400
    shared_inf: 0xbecf5000(MA)
    pt_base: 0xce5000(VA)
    nr_pt_frames: 0xb
    mfn_list: 0×990000(VA)
    mod_start: 0×0(VA)
    mod_len: 0
    flags: 0×0
    cmd_line: root=/dev/sda1 ro 4
    stack: 0x94f860-0x96f860
    MM: Init
    _text: 0×0(VA)
    _etext: 0x5ffbd(VA)
    _erodata: 0×78000(VA)
    _edata: 0x80ae0(VA)
    stack start: 0x94f860(VA)
    _end: 0x98fe68(VA)
    start_pfn: cf3
    max_pfn: 6a400
    Mapping memory range 0×1000000 – 0x6a400000
    setting 0×0-0×78000 readonly
    skipped 0×1000
    MM: Initialise page allocator for 103e000(103e000)-6a400000(6a400000)
    MM: done
    Demand map pfns at 6a401000-206a401000.
    Heap resides at 206a402000-406a402000.
    Initialising timer interface
    Initialising console … done.
    gnttab_table mapped at 0x6a401000.
    Initialising scheduler
    Thread “Idle”: pointer: 0x206a402010, stack: 0x13b0000
    Initialising xenbus
    Thread “xenstore”: pointer: 0x206a4027c0, stack: 0x13c0000
    Dummy main: start_info=0x96f960
    Thread “main”: pointer: 0x206a402f70, stack: 0x13d0000
    “main” “root=/dev/sda1″ “ro” “4″
    vbd 2049 is hd0
    ******************* BLKFRONT for device/vbd/2049 **********

    backend at /local/domain/0/backend/vbd/581/2049
    Failed to read /local/domain/0/backend/vbd/581/2049/feature-barrier.
    Failed to read /local/domain/0/backend/vbd/581/2049/feature-flush-cache.
    104857600 sectors of 512 bytes
    **************************
    vbd 2051 is hd1
    ******************* BLKFRONT for device/vbd/2051 **********

    backend at /local/domain/0/backend/vbd/581/2051
    Failed to read /local/domain/0/backend/vbd/581/2051/feature-barrier.
    Failed to read /local/domain/0/backend/vbd/581/2051/feature-flush-cache.
    1835008 sectors of 512 bytes
    **************************
    Thread “kbdfront”: pointer: 0x206a530010, stack: 0x13e0000
    ******************* FBFRONT for device/vfb/0 **********

    ******************* KBDFRONT for device/vkbd/0 **********

    Failed to read device/vfb/0/backend-id.
    Failed to read device/vkbd/0/backend-id.
    Error ENOENT when reading the backend path device/vkbd/0/backend
    Thread “kbdfront” exited.
    Error ENOENT when reading the backend path device/vfb/0/backend

    Press `ESC’ to enter the menu… 4
    Press `ESC’ to enter the menu… 3
    Press `ESC’ to enter the menu… 2
    Press `ESC’ to enter the menu… 1
    Press `ESC’ to enter the menu… 0
    [H
    [J Booting 'CentOS 6.2 (2.6.32-220.el6.x86_64)'

    root (hd0,0)

    Filesystem type is ext2fs, partition type 0x83

    kernel /boot/vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/xvda1 rd_NO_LUKS rd_NO_

    LVM rd_NO_MD rhgb rd_NO_DM rd_NO_PLYMOUTH selinux=0 console=hvc0 loglvl=all syn

    c_console console_to_ring earlyprintk=xen nomodeset

    initrd /boot/initramfs-2.6.32-220.el6.x86_64.img

    close blk: backend at /local/domain/0/backend/vbd/581/2049
    close blk: backend at /local/domain/0/backend/vbd/581/2051
    (early) Initializing cgroup subsys cpuset
    (early) Initializing cgroup subsys cpu
    (early) Linux version 2.6.32-220.el6.x86_64 (mockbuild@c6b18n3.bsys.dev.centos.org) (gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) #1 SMP Tue Dec 6 19:48:22 GMT 2011
    (early) Command line: ro root=/dev/xvda1 rd_NO_LUKS rd_NO_LVM rd_NO_MD rhgb rd_NO_DM rd_NO_PLYMOUTH selinux=0 console=hvc0 loglvl=all sync_console console_to_ring earlyprintk=xen nomodeset
    (early) KERNEL supported cpus:
    (early) Intel GenuineIntel
    (early) AMD AuthenticAMD
    (early) Centaur CentaurHauls
    (early) ACPI in unprivileged domain disabled
    (early) released 0 pages of unused memory
    (early) BIOS-provided physical RAM map:
    (early) Xen: 0000000000000000 - 00000000000a0000 (usable)
    (early) Xen: 00000000000a0000 - 0000000000100000 (reserved)
    (early) Xen: 0000000000100000 - 000000006a400000 (usable)
    (early) bootconsole [xenboot0] enabled
    (early) DMI not present or invalid.
    (early) last_pfn = 0x6a400 max_arch_pfn = 0×400000000
    (early) init_memory_mapping: 0000000000000000-000000006a400000
    (early) RAMDISK: 0202d000 – 0447d000
    (early) No NUMA configuration found
    (early) Faking a node at 0000000000000000-000000006a400000
    (early) Bootmem setup node 0 0000000000000000-000000006a400000
    (early) NODE_DATA [0000000000008000 - 000000000003bfff]
    (early) bootmap [000000000003c000 - 000000000004947f] pages e
    (early) (7 early reservations) ==> bootmem [0000000000 - 006a400000]
    (early) #0 [0000000000 - 0000001000] BIOS data page(early) ==> [0000000000 - 0000001000]
    (early) #1 [00047d2000 - 00047fb000] XEN PAGETABLES(early) ==> [00047d2000 - 00047fb000]
    (early) #2 [0000006000 - 0000008000] TRAMPOLINE(early) ==> [0000006000 - 0000008000]
    (early) #3 [0001000000 - 000200c7e4] TEXT DATA BSS(early) ==> [0001000000 - 000200c7e4]
    (early) #4 [000202d000 - 000447d000] RAMDISK(early) ==> [000202d000 - 000447d000]
    (early) #5 [000447d000 - 00047d2000] XEN START INFO(early) ==> [000447d000 - 00047d2000]
    (early) #6 [0000100000 - 0000429000] PGTABLE(early) ==> [0000100000 - 0000429000]
    (early) Zone PFN ranges:
    (early) DMA 0×00000001 -> 0×00001000
    (early) DMA32 0×00001000 -> 0×00100000
    (early) Normal 0×00100000 -> 0×00100000
    (early) Movable zone start PFN for each node
    (early) early_node_map[2] active PFN ranges
    (early) 0: 0×00000001 -> 0x000000a0
    (early) 0: 0×00000100 -> 0x0006a400
    (early) SFI: Simple Firmware Interface v0.7 http://simplefirmware.org
    (early) SMP: Allowing 1 CPUs, 0 hotplug CPUs
    (early) No local APIC present
    (early) APIC: disable apic facility
    (early) PM: Registered nosave memory: 00000000000a0000 – 0000000000100000
    (early) Allocating PCI resources starting at 6a400000 (gap: 6a400000:95c00000)
    (early) Booting paravirtualized kernel on Xen
    (early) Xen version: 3.4.3-2.6.18 (preserve-AD)
    (early) NR_CPUS:4096 nr_cpumask_bits:1 nr_cpu_ids:1 nr_node_ids:1
    (early) PERCPU: Embedded 30 pages/cpu @ffff880004831000 s92696 r8192 d21992 u122880
    (early) pcpu-alloc: s92696 r8192 d21992 u122880 alloc=30*4096(early)
    (early) pcpu-alloc: (early) [0] (early) 0 (early)
    (early) Xen: using vcpu_info placement
    (early) Built 1 zonelists in Node order, mobility grouping on. Total pages: 428341
    (early) Policy zone: DMA32
    (early) Kernel command line: ro root=/dev/xvda1 rd_NO_LUKS rd_NO_LVM rd_NO_MD rhgb rd_NO_DM rd_NO_PLYMOUTH selinux=0 console=hvc0 loglvl=all sync_console console_to_ring earlyprintk=xen nomodeset
    (early) PID hash table entries: 4096 (order: 3, 32768 bytes)
    (early) Checking aperture…
    (early) No AGP bridge found
    (early) Memory: 1654220k/1740800k available (5084k kernel code, 388k absent, 86192k reserved, 7229k data, 1244k init)
    (early) Hierarchical RCU implementation.
    (early) NR_IRQS:33024 nr_irqs:256
    (early) Console: colour dummy device 80×25
    (early) Initializing cgroup subsys cpuset
    (early) Initializing cgroup subsys cpu
    (early) Linux version 2.6.32-220.el6.x86_64 (mockbuild@c6b18n3.bsys.dev.centos.org) (gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) #1 SMP Tue Dec 6 19:48:22 GMT 2011
    (early) Command line: ro root=/dev/xvda1 rd_NO_LUKS rd_NO_LVM rd_NO_MD rhgb rd_NO_DM rd_NO_PLYMOUTH selinux=0 console=hvc0 loglvl=all sync_console console_to_ring earlyprintk=xen nomodeset
    (early) KERNEL supported cpus:
    (early) Intel GenuineIntel
    (early) AMD AuthenticAMD
    (early) Centaur CentaurHauls
    (early) ACPI in unprivileged domain disabled
    (early) released 0 pages of unused memory
    (early) BIOS-provided physical RAM map:
    (early) Xen: 0000000000000000 – 00000000000a0000 (usable)
    (early) Xen: 00000000000a0000 – 0000000000100000 (reserved)
    (early) Xen: 0000000000100000 – 000000006a400000 (usable)
    (early) bootconsole [xenboot0] enabled
    (early) DMI not present or invalid.
    (early) last_pfn = 0x6a400 max_arch_pfn = 0×400000000
    (early) init_memory_mapping: 0000000000000000-000000006a400000
    (early) RAMDISK: 0202d000 – 0447d000
    (early) No NUMA configuration found
    (early) Faking a node at 0000000000000000-000000006a400000
    (early) Bootmem setup node 0 0000000000000000-000000006a400000
    (early) NODE_DATA [0000000000008000 - 000000000003bfff]
    (early) bootmap [000000000003c000 - 000000000004947f] pages e
    (early) (7 early reservations) ==> bootmem [0000000000 - 006a400000]
    (early) #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000]
    (early) #1 [00047d2000 - 00047fb000] XEN PAGETABLES ==> [00047d2000 - 00047fb000]
    (early) #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000]
    (early) #3 [0001000000 - 000200c7e4] TEXT DATA BSS ==> [0001000000 - 000200c7e4]
    (early) #4 [000202d000 - 000447d000] RAMDISK ==> [000202d000 - 000447d000]
    (early) #5 [000447d000 - 00047d2000] XEN START INFO ==> [000447d000 - 00047d2000]
    (early) #6 [0000100000 - 0000429000] PGTABLE ==> [0000100000 - 0000429000]
    (early) Zone PFN ranges:
    (early) DMA 0×00000001 -> 0×00001000
    (early) DMA32 0×00001000 -> 0×00100000
    (early) Normal 0×00100000 -> 0×00100000
    (early) Movable zone start PFN for each node
    (early) early_node_map[2] active PFN ranges
    (early) 0: 0×00000001 -> 0x000000a0
    (early) 0: 0×00000100 -> 0x0006a400
    (early) SFI: Simple Firmware Interface v0.7 http://simplefirmware.org
    (early) SMP: Allowing 1 CPUs, 0 hotplug CPUs
    (early) No local APIC present
    (early) APIC: disable apic facility
    (early) PM: Registered nosave memory: 00000000000a0000 – 0000000000100000
    (early) Allocating PCI resources starting at 6a400000 (gap: 6a400000:95c00000)
    (early) Booting paravirtualized kernel on Xen
    (early) Xen version: 3.4.3-2.6.18 (preserve-AD)
    (early) NR_CPUS:4096 nr_cpumask_bits:1 nr_cpu_ids:1 nr_node_ids:1
    (early) PERCPU: Embedded 30 pages/cpu @ffff880004831000 s92696 r8192 d21992 u122880
    (early) pcpu-alloc: s92696 r8192 d21992 u122880 alloc=30*4096
    (early) pcpu-alloc: [0] 0
    (early) Xen: using vcpu_info placement
    (early) Built 1 zonelists in Node order, mobility grouping on. Total pages: 428341
    (early) Policy zone: DMA32
    (early) Kernel command line: ro root=/dev/xvda1 rd_NO_LUKS rd_NO_LVM rd_NO_MD rhgb rd_NO_DM rd_NO_PLYMOUTH selinux=0 console=hvc0 loglvl=all sync_console console_to_ring earlyprintk=xen nomodeset
    (early) PID hash table entries: 4096 (order: 3, 32768 bytes)
    (early) Checking aperture…
    (early) No AGP bridge found
    (early) Memory: 1654220k/1740800k available (5084k kernel code, 388k absent, 86192k reserved, 7229k data, 1244k init)
    (early) Hierarchical RCU implementation.
    (early) NR_IRQS:33024 nr_irqs:256
    (early) Console: colour dummy device 80×25
    (early) console [tty0] enabled
    console [hvc0] enabled, bootconsole disabled
    (early) console [hvc0] enabled, bootconsole disabled
    allocated 14680064 bytes of page_cgroup
    please try ‘cgroup_disable=memory’ option if you don’t want memory cgroups
    installing Xen timer for CPU 0
    Detected 2266.746 MHz processor.
    Calibrating delay loop (skipped), value calculated using timer frequency.. 4533.49 BogoMIPS (lpj=2266746)
    pid_max: default: 32768 minimum: 301
    Security Framework initialized
    SELinux: Disabled at boot.
    Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
    Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)
    Mount-cache hash table entries: 256
    Initializing cgroup subsys ns
    Initializing cgroup subsys cpuacct
    Initializing cgroup subsys memory
    Initializing cgroup subsys devices
    Initializing cgroup subsys freezer
    Initializing cgroup subsys net_cls
    Initializing cgroup subsys blkio
    Initializing cgroup subsys perf_event
    CPU: CPU feature constant_tsc disabled on xen guest
    CPU: Unsupported number of siblings 16
    alternatives: switching to unfair spinlock
    SMP alternatives: switching to UP code
    Freeing SMP alternatives: 33k freed
    ftrace: converting mcount calls to 0f 1f 44 00 00
    ftrace: allocating 20776 entries in 82 pages
    Performance Events: unsupported p6 CPU model 26 no PMU driver, software events only.
    NMI watchdog disabled (cpu0): hardware events not enabled
    Brought up 1 CPUs
    devtmpfs: initialized
    Grant table initialized
    regulator: core version 0.5
    NET: Registered protocol family 16
    PCI: Fatal: No config space access function found
    bio: create slab at 0
    ACPI: Interpreter disabled.
    xen_balloon: Initialising balloon driver.
    last_pfn = 0x6a400 max_arch_pfn = 0×400000000
    vgaarb: loaded
    SCSI subsystem initialized
    usbcore: registered new interface driver usbfs
    usbcore: registered new interface driver hub
    usbcore: registered new device driver usb
    PCI: System does not support PCI
    PCI: System does not support PCI
    NetLabel: Initializing
    NetLabel: domain hash size = 128
    NetLabel: protocols = UNLABELED CIPSOv4
    NetLabel: unlabeled traffic allowed by default
    Switching to clocksource xen
    pnp: PnP ACPI: disabled
    NET: Registered protocol family 2
    IP route cache hash table entries: 65536 (order: 7, 524288 bytes)
    TCP established hash table entries: 262144 (order: 10, 4194304 bytes)
    TCP bind hash table entries: 65536 (order: 8, 1048576 bytes)
    TCP: Hash tables configured (established 262144 bind 65536)
    TCP reno registered
    NET: Registered protocol family 1
    Trying to unpack rootfs image as initramfs…
    Freeing initrd memory: 37184k freed
    platform rtc_cmos: registered platform RTC device (no PNP device found)
    audit: initializing netlink socket (disabled)
    type=2000 audit(1335462262.621:1): initialized
    HugeTLB registered 2 MB page size, pre-allocated 0 pages
    VFS: Disk quotas dquot_6.5.2
    Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
    msgmni has been set to 3303
    alg: No test for stdrng (krng)
    ksign: Installing public key data
    Loading keyring
    - Added public key 3A25C209CBB1D210
    - User ID: CentOS (Kernel Module GPG key)
    Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
    io scheduler noop registered
    io scheduler anticipatory registered
    io scheduler deadline registered
    io scheduler cfq registered (default)
    pci_hotplug: PCI Hot Plug PCI Core version: 0.5
    pciehp: PCI Express Hot Plug Controller Driver version: 0.4
    acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
    Non-volatile memory driver v1.3
    Linux agpgart interface v0.103
    crash memory driver: version 1.1
    Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
    brd: module loaded
    loop: module loaded
    input: Macintosh mouse button emulation as /devices/virtual/input/input0
    Fixed MDIO Bus: probed
    ehci_hcd: USB 2.0 ‘Enhanced’ Host Controller (EHCI) Driver
    ohci_hcd: USB 1.1 ‘Open’ Host Controller (OHCI) Driver
    uhci_hcd: USB Universal Host Controller Interface driver
    PNP: No PS/2 controller found. Probing ports directly.
    mice: PS/2 mouse device common for all mice
    rtc_cmos: probe of rtc_cmos failed with error -16
    cpuidle: using governor ladder
    cpuidle: using governor menu
    usbcore: registered new interface driver hiddev
    usbcore: registered new interface driver usbhid
    usbhid: v2.6:USB HID core driver
    TCP cubic registered
    Initializing XFRM netlink socket
    NET: Registered protocol family 17
    registered taskstats version 1
    XENBUS: Device with no driver: device/vbd/2049
    XENBUS: Device with no driver: device/vbd/2051
    XENBUS: Device with no driver: device/vif/0
    XENBUS: Device with no driver: device/console/0
    drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
    Initalizing network drop monitor service
    Freeing unused kernel memory: 1244k freed
    Write protecting the kernel read-only data: 10240k
    Freeing unused kernel memory: 1040k freed
    Freeing unused kernel memory: 1760k freed
    dracut: dracut-004-256.el6
    udev: starting version 147
    xlblk_init: register_blkdev major: 202
    blkfront: xvde1: barriers disabled
    blkfront: xvde3: barriers disabled

    dracut Warning: No root device “block:/dev/xvda1″ found

    dracut Warning: Boot has failed. To debug this issue add “rdshell” to the kernel command line.

    dracut Warning: Signal caught!

    dracut Warning: Boot has failed. To debug this issue add “rdshell” to the kernel command line.
    Kernel panic – not syncing: Attempted to kill init!
    Pid: 1, comm: init Not tainted 2.6.32-220.el6.x86_64 #1
    Call Trace:
    [] ? panic+0×78/0×143
    [] ? do_exit+0×852/0×860
    [] ? fput+0×25/0×30
    [] ? do_group_exit+0×58/0xd0
    [] ? sys_exit_group+0×17/0×20
    [] ? system_call_fastpath+0×16/0x1b

  3. Pingback: How to create CentOS 6.2 64-bit EBS AMI Image from scratch | romanescu.ro

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s