缩小 aws ec2 实例根卷(ubuntu 14.4)

缩小 aws ec2 实例根卷(ubuntu 14.4)

我从一些链接读到并应用了这些内容

lsblk
xvda 202:0 0 32G 0 disk /   = this disk attahced to new instance from old one
xvdb 202:16 0 80G 0 disk /mnt
xvdc 202:32 0 80G 0 disk
xvdg 202:96 0 32G 0 disk - this volume makes from snapshot of root volume
xvdh 202:112 0 18G 0 disk  - this is use for after all data copied to old instance as /dev/sda1

df -h
/dev/xvda 32G 12G 19G 39% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 7.4G 12K 7.4G 1% /dev
tmpfs 1.5G 380K 1.5G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 7.4G 0 7.4G 0% /run/shm
none 100M 0 100M 0% /run/user

cat /etc/fstab
LABEL=cloudimg-rootfs / ext4 defaults 0 0
#/dev/md0 /mnt auto defaults,nobootwait,noatime 0 2
/dev/ephemeral/mnt /mnt auto defaults,nobootwait,noatime 0 2
/mnt/swap/swapfile swap swap defaults 0 1
/dev/xvdb /mnt auto defaults,nobootwait,comment=cloudconfig 0 2
/dev/xvdb 79G 56M 75G 1% /mnt

从这里开始:

1 - e2fsck -f /dev/xvdg
e2fsck 1.42.9 (4-Feb-2014)
cloudimg-rootfs: recovering journal
Clearing orphaned inode 24877 (uid=0, gid=0, mode=0100640, size=1050)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (5211700, counted=5224390).
Fix<y>? yes
Free inodes count wrong (1777738, counted=1777494).
Fix<y>? yes
cloudimg-rootfs: ***** FILE SYSTEM WAS MODIFIED *****
cloudimg-rootfs: 319658/2097152 files (0.4% non-contiguous), 3164218/8388608 blocks

2- resize2fs -M -p /dev/xvdg
resize2fs 1.42.9 (4-Feb-2014)
Resizing the filesystem on /dev/xvdg to 3096164 (4k) blocks.
Begin pass 2 (max = 3886)
Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 256)
Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 47495)
Updating inode references XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/xvdg is now 3096164 blocks long.

3096164 * 4 / (16 * 1024). = 755 (i will keep 757)

3 - make file system= mkfs -t ext4 /dev/xvdh
4 - 

    dd bs=16M if=/dev/xvdg of=/dev/xvdh count=757
    757+0 records in
    757+0 records out
    12700352512 bytes (13 GB) copied, 599.676 s, 21.2 MB/s

5- e2fsck -f /dev/xvdh
e2fsck 1.42.9 (4-Feb-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
cloudimg-rootfs: 319658/778240 files (0.4% non-contiguous), 3080438/3096164 blocks
6- resize2fs -p /dev/xvdh
resize2fs 1.42.9 (4-Feb-2014)
Resizing the filesystem on /dev/xvdh to 4718592 (4k) blocks.
The filesystem on /dev/xvdh is now 4718592 blocks long.

7- stop the instance
8 - now detached /dev/xvdg and dev/xvdh 
9 - attach /dev/xvdh to old instance

blkid - from new machine..

/dev/xvda: LABEL="cloudimg-rootfs" UUID="aa697099-062b-4b53-976e-f2ac573effd9" TYPE="ext4"
/dev/xvdb: UUID="6dfa91c5-14de-4c59-983e-e851e7dc6ead" SEC_TYPE="ext2" TYPE="ext3"
/dev/xvdc: UUID="6dfa91c5-14de-4c59-983e-e851e7dc6ead" SEC_TYPE="ext2" TYPE="ext3"
/dev/xvdg: LABEL="cloudimg-rootfs" UUID="aa697099-062b-4b53-976e-f2ac573effd9" TYPE="ext4"
/dev/xvdh: LABEL="cloudimg-rootfs" UUID="aa697099-062b-4b53-976e-f2ac573effd9" TYPE="ext4"

但是我将旧实例附加为 dev/sda1,但它显示空白屏幕日志,make ami 后不显示任何日志,启动机器后显示状态检查失败。请有人建议如何解决这个问题。

相关内容