XFS is a default file systems type in Red Hat Enterprise Linux 7. It is quite well known to me how to grow file system size when it is on LVM, but when it is not, I was very unsure. Anyway, this worked:
I want to increase root partition size and because the host is actually a virtual machine, it is easy to add more space. So in the VM we are using about 50 GB out of 161 GB available disk space. When using fdisk
, guide advises to switch it to "sectors" mode. That seems to be default, but option is there just to be sure. Note the start sector (5222400 in my case) for the /dev/vda3
partition which hosts root file system:
[root@rhevm ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda3 48G 36G 13G 75% / devtmpfs 11G 0 11G 0% /dev tmpfs 11G 0 11G 0% /dev/shm tmpfs 11G 8.4M 11G 1% /run tmpfs 11G 0 11G 0% /sys/fs/cgroup /dev/vda1 497M 208M 289M 42% /boot tmpfs 2.1G 0 2.1G 0% /run/user/0 [root@rhevm ~]# fdisk -u=sectors -l /dev/vda Disk /dev/vda: 161.1 GB, 161061273600 bytes, 314572800 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: 0x000e38b0 Device Boot Start End Blocks Id System /dev/vda1 * 2048 1026047 512000 83 Linux /dev/vda2 1026048 5222399 2098176 82 Linux swap / Solaris /dev/vda3 5222400 104857599 49817600 83 Linux
If we try to extend XFS file system now, it wont work because it does not have space for the expansion (ignore the actual numbers, as I have taken them after the expansion shown below):
[root@rhevm ~]# xfs_info / meta-data=/dev/vda3 isize=256 agcount=9, agsize=3113600 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 spinodes=0 data = bsize=4096 blocks=26214400, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=6081, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@rhevm ~]# xfs_growfs -D 30000000 / meta-data=/dev/vda3 isize=256 agcount=9, agsize=3113600 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 spinodes=0 data = bsize=4096 blocks=26214400, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=6081, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data size 30000000 too large, maximum is 26214400
So, lets delete the partition and create it again at required size (I want it 100 GB big):
[root@rhevm ~]# fdisk -u=sectors /dev/vda 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): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): p Disk /dev/vda: 161.1 GB, 161061273600 bytes, 314572800 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: 0x000e38b0 Device Boot Start End Blocks Id System /dev/vda1 * 2048 1026047 512000 83 Linux /dev/vda2 1026048 5222399 2098176 82 Linux swap / Solaris /dev/vda3 5222400 104857599 49817600 83 Linux Command (m for help): d Partition number (1-3, default 3): 3 Partition 3 is deleted Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): 3 First sector (5222400-314572799, default 5222400): 5222400 Last sector, +sectors or +size{K,M,G} (5222400-314572799, default 314572799): +100G Partition 3 of type Linux and of size 100 GiB is set Command (m for help): p Disk /dev/vda: 161.1 GB, 161061273600 bytes, 314572800 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: 0x000e38b0 Device Boot Start End Blocks Id System /dev/vda1 * 2048 1026047 512000 83 Linux /dev/vda2 1026048 5222399 2098176 82 Linux swap / Solaris /dev/vda3 5222400 214937599 104857600 83 Linux 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. [root@rhevm ~]# partprobe Error: Partition(s) 3 on /dev/vda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. [root@rhevm ~]# shutdown -r now
After reboot, we are finally ready to grow the file system:
[root@rhevm ~]# xfs_growfs / meta-data=/dev/vda3 isize=256 agcount=4, agsize=3113600 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 spinodes=0 data = bsize=4096 blocks=12454400, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=6081, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 12454400 to 26214400 [root@rhevm ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda3 100G 36G 65G 36% / devtmpfs 11G 0 11G 0% /dev tmpfs 11G 0 11G 0% /dev/shm tmpfs 11G 8.4M 11G 1% /run tmpfs 11G 0 11G 0% /sys/fs/cgroup /dev/vda1 497M 208M 289M 42% /boot tmpfs 2.1G 0 2.1G 0% /run/user/0
No comments:
Post a Comment