Environment and Requirements:
1. The AMI root partition now has 25G
2 25G a bit more, so want to reduce 25G to 12G
3. View disk Information
# df-h
FileSystem Size Used Avail use% mounted on
/DEV/XVDA1 17G 1.5G 15G 9%/
Tmpfs 498M 0 498M 0%/dev/shm
Operation Steps:
1. Mount a new 12G plate (/DEV/XVDF)
2. Partition and format new disks
# fdisk-l
Device Boot Start End Blocks Id System
/DEV/XVDF1 1 1045 8393931 Linux
/DEV/XVDF2 1046 1566 4184932+ Linux Swap/solaris
# MKFS.EXT4/DEV/XVDF1
3. mount a new disk
# mkdir/new
# mount/dev/xvdf1/new
# DF |grep New
/DEV/XVDF1 7.9G 1.2G 6.4G 16%/new
4. Synchronize data (copy/lower all data to new disk)
# RSYNC-AUV/–exclude= "/new/*"/new
5. Volume Label processing
View each disk volume label
# E2LABEL/DEV/XVDA1
/
# E2LABEL/DEV/XVDF1 (this one has no label, so it's empty)
Add a volume label to a new disk
E2LABEL/DEV/XVDF1 ROOT
Mkswap-l SWAP/DEV/XVDF2
(# E2LABEL/DEV/XVDA1 ""//delete label can be like this)
6. Modify and view/new/etc/fstab (label root mount to swap for/,label)
# Cat/new/etc/fstab
LABEL=ROOT/EXT4 Defaults 1 1
Label=swap Swap Defaults 0 0
Tmpfs/tmp TMPFS Defaults 0 0
Devpts/dev/pts devpts gid=5,mode=620 0 0
Sysfs/sys Sysfs Defaults 0 0
PROC/PROC proc Defaults 0 0
7. Modify and view the/new/boot/grub/grub.conf (boot from label root)
Default=0
Timeout=5
Splashimage= (hd0,0)/boot/grub/splash.xpm.gz
Hiddenmenu
Title CentOS (2.6.32-431.3.1.el6.x86_64)
Root (hd0,0)
kernel/boot/vmlinuz-2.6.32-431.3.1.el6.x86_64 ro root=label=root console=ttys0 crashkernel=auto SYSFONT= Latarcyrheb-sun16 Lang=en_us. UTF-8 Keytable=us
Initrd/boot/initramfs-2.6.32-431.3.1.el6.x86_64.img
8. Make sure the network card is DHCP
# Cat/new/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0
Onboot=yes
Bootproto=dhcp
Type=ethernet
9. Create Snapshot
Snapshot
Take a name for snapshot.
Snapshot2
Pending takes a while (depending on the size of the disk), remember the ID of the snapshot created, followed by
9. After the creation completes, registers an AMI based on this snapshot
# ec2-register-n "centos6.5-x64-base-12g"-D "centos6.5-x64-base-12g"-a x86_64–root-device-name/dev/sda-b/dev/sda=s Nap-f13d641e:12:true–kernel aki-503e7402–region ap-southeast-1--virtualization-type HVM
-O akixxxxxxxxxxxxx-w xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
10. Remark:
To run the Ec2-register command, you need to install the Java environment and the AWS-API package, as detailed in the official order:
Http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-RegisterImage.html
-b/dev/sda=snap-f13d641e:12:true said the SDA was cloned by snap-f13d641e, the snapshot,
12 is disk capacity
–kernel aki-503e7402 different regions and not the number of system digits used Aki name is not the same, more Aki see the following links
Http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UserProvidedKernels.html#AmazonKernelImageIDs
-O akixxxxxxxxxxxxx-w xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Create a user that authorizes the Ec2-register command to be executed and remembers its key