KVM-based XFS disk resizing

Source: Internet
Author: User
1. Preface

According to our current requirements, we have not enough disk space for the previously planned GB. Here we will demonstrate the resizing of The XFS file system. Because I am using KVM, we will also demonstrate the KVM resizing method.

2. KVM disk resizing

Before resizing, you must back up the data or take snapshots to avoid data corruption.

[[Email protected] img] # qemu-IMG info c7_data_g2.raw # <-- View original disk information image: c7_data_g2.rawfile format: rawvirtual size: 100g (107374182400 bytes) disk size: 100g [[email protected] img] # qemu-IMG resize c7_data_g2.raw + 200g # <-- increase by 200 gimage resized. [[email protected] img] # qemu-IMG info c7_data_g2.rawimage: c7_data_g2.rawfile format: rawvirtual size: 300g (322122547200 bytes) # <-- increase disk size: 100g

The modification is complete. You need to restart the KVM virtual machine to take effect.

3. Restart the KVM host.
[[Email protected] ~] # Virsh shutdown kvm-node-1 domain kvm-node-1 is closed [[email protected] ~] # Virsh start kvm-node-1 domain kvm-node-1 started
4. XFS disk resizing

Step 1: remove the disk

[[email protected] ~]# umount /data[[email protected] ~]# lsblkNAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTsr0     11:0    1 1024M  0 rom  vda    253:0    0   40G  0 disk └─vda1 253:1    0   40G  0 part /vdb    253:16   0  300G  0 disk └─vdb1 253:17   0  100G  0 part 

Step 2: Adjust the partition table size

Adjusting the partition table size does not actually modify the data, similar to revising the book directory;Note that the starting position must be consistent.Here, use the default value. The default value is 2048, so press Enter.

[[Email protected] ~] # Fdisk/dev/vdbwelcome 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 # <-- print partition information disk/dev/vdb: 322.1 GB, 322122547200 bytes, 629145600 sectorsunits = sectors of 1*512 = 512 bytessector size (logical/physical): 512 bytes/512 bytesi/o size (minimum/optimal): 512 bytes/512 bytesdi SK label type: dosdisk identifier: 0x60f8f320 device boot start end blocks ID system/dev/vdb1 2048 209715199 104856576 83 linuxcommand (M for help ): d # <-- delete the partition selected partition 1 partition 1 is deletedcommand (M for help): N # <-- create a partition. The rest is basically when you press enter for the partition type: P primary (0 primary, 0 extended, 4 free) e extendedselect (default P): ppartition number (1-4, default 1): 1 first sector (2048-6291455 99, default 2048): Using default value 2048 last sector, + sectors or + size {K, M, g} (2048-629145599, default 629145599 ): using default value 629145599 partition 1 of Type Linux and of size 300 Gib is setcommand (M for help): WQ # <-- save partition information the partition table has been altered! Calling IOCTL () to re-read Partition Table. syncing disks.

Step 3: Online resizing

[[email protected] ~]# xfs_growfs /dev/vdb1meta-data=/dev/vdb1              isize=512    agcount=4, agsize=6553536 blks         =                       sectsz=512   attr=2, projid32bit=1         =                       crc=1        finobt=0 spinodes=0data     =                       bsize=4096   blocks=26214144, imaxpct=25         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1log      =internal               bsize=4096   blocks=12799, version=2         =                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0data blocks changed from 26214144 to 78642944[[email protected] ~]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/vda1        40G  2.3G   38G   6% /devtmpfs         12G     0   12G   0% /devtmpfs            12G     0   12G   0% /dev/shmtmpfs            12G  8.5M   12G   1% /runtmpfs            12G     0   12G   0% /sys/fs/cgrouptmpfs           2.4G     0  2.4G   0% /run/user/0/dev/vdb1       300G  100G  201G  34% /data

In the test, if the XFS file system is not mounted for expansion, the system prompts that it is not an XFS file system.

KVM-based XFS disk resizing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.