无法在 EC2 centos 上调整根分区的大小 [英] unable to resize root partition on EC2 centos

查看:12
本文介绍了无法在 EC2 centos 上调整根分区的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Centos 6.3 x64 的社区映像创建了我的 EC2 机器.我添加了一个 35 GB 的磁盘.现在当我做 #df -h

i created my EC2 Machine using Community Image of Centos 6.3 x64. i have added a 35 GB disk. Now when i do #df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1            7.9G  1.2G  6.4G  16% /
tmpfs                 7.3G     0  7.3G   0% /dev/shm

我的磁盘是 35GB,但它在 root 中显示为 8GB,在 tmpfs 中显示为 7.

my disk is 35GB but its showing 8 GB in root and 7 as tmpfs.

我尝试使用 resize2fs 但它在 centos 上不起作用.磁盘有 ext4 分区..

i tried to use resize2fs but it didnt work on centos. disk has ext4 partation..

# resize2fs /dev/xvda
resize2fs 1.41.12 (17-May-2010)
resize2fs: Device or resource busy while trying to open /dev/xvda
Couldn't find valid filesystem superblock.

或者即使我尝试 resize2fs/dev/xvda1 它也说设备无关紧要.

or even if i tried resize2fs /dev/xvda1 it says device has nothing to do.

任何想法或其他方式,它是我的根磁盘(/).所以不能卸载它.

any idea or other way, its my root disk(/). so cant unmount it.

推荐答案

我找到了一种方法来做到这一点,resize2fs 不起作用,以防不确定原因,但它说设备或资源繁忙.我在 resizedisk 上找到了一篇非常好的文章,使用 fdisk 我们可以通过删除和创建它来增加块大小并使分区可启动.它所需要的只是重新启动.如果您使用相同的启动气缸,它不会影响您的数据.

i found a way to do that, resize2fs not working in case not sure why but it says device or resource busy. i found a very good article on resizedisk using fdisk we can increase block size by deleting and creating it and Make the partition bootable. all it requires is a reboot. it wont effect your data if you use same start cylinder.

# df -h  <<1>>

Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      6.0G  2.0G  3.7G  35% / 
tmpfs            15G     0   15G   0% /dev/shm

# fdisk -l  <<2>>

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
97 heads, 17 sectors/track, 25435 cylinders
Units = cylinders of 1649 * 512 = 844288 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b587

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           2        7632     6291456   83  Linux

# fdisk /dev/xvda  <<3>>

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): u  <<4>>
Changing display/entry units to sectors

Command (m for help): p  <<5>>

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
97 heads, 17 sectors/track, 25435 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b587

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048    12584959     6291456   83  Linux

Command (m for help): d  <<6>>
Selected partition 1

Command (m for help): n  <<7>>
Command action
   e   extended
   p   primary partition (1-4)
p  <<8>>
Partition number (1-4): 1  <<9>>
First sector (17-41943039, default 17): 2048  <<10>>
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): <<11>>
Using default value 41943039

Command (m for help): p <<12>>

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
97 heads, 17 sectors/track, 25435 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b587

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1            2048    41943039    20970496   83  Linux

Command (m for help): a  <<13>>
Partition number (1-4): 1  <<14>>


Command (m for help): w  <<15>>
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

# reboot  <<16>>

<wait>

# df -h  <<17>>
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       20G  2.0G   17G  11% / 
tmpfs            15G     0   15G   0% /dev/shm

# resize2fs /dev/xvda1  <<18>>
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 5242624 blocks long.  Nothing to do!

这篇关于无法在 EC2 centos 上调整根分区的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆