6

I just created an Amazon AWS EC2 instance running RHEL7:

[root@ip-10-184-161-46 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.0 (Maipo)
[root@ip-10-184-161-46 ~]# 

And even though I selected 10GB as my storage capacity, for whatever reason I'm only seeing 6GB that's available for me to use right away:

[root@ip-10-184-161-46 ~]# mount | grep xfs | grep -v selinux
/dev/xvda1 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
[root@ip-10-184-161-46 ~]# df -h | grep xvda
/dev/xvda1      6.0G  2.2G  3.9G  37% /
[root@ip-10-184-161-46 ~]# fdisk -l /dev/xvda

Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos
Disk identifier: 0x0000b85c

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048    12584959     6291456   83  Linux
[root@ip-10-184-161-46 ~]# 

this is what I did:

[root@ip-10-164-175-246 ~]# fdisk -l /dev/xvda

Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos
Disk identifier: 0x0000b85c

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048    12584959     6291456   83  Linux
/dev/xvda2        12584960    20971519     4193280   83  Linux
[root@ip-10-164-175-246 ~]# xfs_growfs /
meta-data=/dev/xvda1             isize=256    agcount=4, agsize=393216 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=1572864, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@ip-10-164-175-246 ~]# df -h | grep xvda
/dev/xvda1      6.0G  2.3G  3.8G  38% /
[root@ip-10-164-175-246 ~]# 

Where are my other 4GB? I thought running xfs_growfs / will increase the size of my xfs partition.

What am I doing wrong?

8

Funny, I just did exactly this the other day after finding my RHEL instance on EC2 only had 6GB or so of the 10GB space allocated to it...

[root@ip-172-31-20-177 ~]# xfs_info /
meta-data=/dev/xvda1             isize=256    agcount=4, agsize=393216 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=1572864, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

The problem here is that you created a second partition.

Instead, you should resize the first partition.

So, you will use fdisk to delete the second partition, then delete and re-create the first partition at the same time. The fdisk default values will cause it to fill the disk (and be correctly aligned).

Start fdisk and delete the partition:

[root@ip-172-31-20-177 ~]# fdisk /dev/xvda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos
Disk identifier: 0x0000b85c

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

Command (m for help): d
Selected partition 1
Partition 1 is deleted

Now re-create the partition with all default values, which will maximize its size:

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-20971519, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): 
Using default value 20971519
Partition 1 of type Linux and of size 10 GiB is set

Command (m for help): p

Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos
Disk identifier: 0x0000b85c

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1            2048    20971519    10484736   83  Linux

Save the new partition table:

Command (m for help): w
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.

When you reboot, the filesystem should automatically be resized for you by cloud-init. If not, you can use xfs_growfs / to grow the filesystem manually.

[root@ip-172-31-20-177 ~]# xfs_info /
meta-data=/dev/xvda1             isize=256    agcount=7, agsize=393216 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=2621184, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@ip-172-31-20-177 ~]# df
Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/xvda1      10474496 818560   9655936   8% /
  • Try running partprobe on the disk and it avoids the need to reboot. – Matthew Ife Jul 8 '14 at 18:43
  • 1
    @MatthewIfe Not always. When I did this a few days ago, partprobe continued to complain and I had to reboot anyway. – Michael Hampton Jul 8 '14 at 18:48
  • @MikeScott it IS possible to use fdisk to delete and then create partition and only then commit changes to disk. I'll try that in a little bit. – alexus Jul 8 '14 at 19:05
  • 2
    @MichaelHampton, there is one thing that you missed and I want to comment on this so whoever will be following this instruction won't fail on that) you have to use a after you re-create partition, which marks it bootable otherwise it won't boot. – alexus Sep 8 '14 at 21:08
0

You've divided your 10GB disk, xvda, into two partitions: xvda1 is 6GB and xvda2 is 4GB. So your other 4GB is in xvda2, and you can mount it somewhere if you want to use it.

  • right, that part i figured)) i need to increase / mount point, so i need to edit partition, increase blocks and then i gotta xfs_growfs. – alexus Jul 8 '14 at 15:42
  • You're going to have problems. First, you can't edit a mounted partition, so you'll need to use another AWS instance to edit the partition. And second, parted doesn't support xfs. If you're very very careful you might be able to delete both partitions and then create a new one starting at the same sector. If you're not very very careful, you'll lose all your data. – Mike Scott Jul 8 '14 at 15:46
  • Here are some instructions for doing what you want. Use them at your own risk. powelltechconsulting.com/?p=224 – Mike Scott Jul 8 '14 at 15:48
  • Thanks, I cannot open your site though, so I'll try it again later. – alexus Jul 8 '14 at 19:07

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.