CentOS 7 XFS disk resizing Rumi, June 4, 2021 Couldn’t find any article that explained step by step how to resize the main disks volume in a CentOS 7 vm. In my example I started witha single disk of 8GB and expanded to 20GB. I have two partitions on disk sda sda1 type Linux for boot sda2 type Linux LVM for the remaining logical volumes Space utilisation as following: [root@vcd-c1-s1 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.8M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/mapper/centos-root 6.2G 1.9G 4.4G 31% / /dev/sda1 1014M 179M 836M 18% /boot tmpfs 783M 0 783M 0% /run/user/0 We basically need to: 1) Check and print the existing partitions fdisk /dev/sda Command (m for help): p 2) Delete the existing lvm partition (sda2) Command (m for help): d Partition number (1-4): 2 3) Create a new LVM partition including the extended new size Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (2-4, default 2): 2 4) Set the new partition to be of type 8e (Linux LVM) Command (m for help): t Partition number (1,2, default 2): 2 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' 5) Check again the changes before writing them to disk Command (m for help): p <REMOVED OUTPUT> 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. 6) Reboot the vm reboot 7) Resize the physical volume to match the size of the partition (sda2) pvresize /dev/sda2 Physical volume "/dev/sda2" changed 1 physical volume(s) resized / 0 physical volume(s) not resized 8) Resize the logical volume to use the new space available lvresize /dev/mapper/centos-root /dev/sda2 Size of logical volume centos/root changed from <6.20 GiB (1586 extents) to <18.20 GiB (4658 extents). Logical volume centos/root successfully resized 9) Finally, resize the file system. Using resize2fs I was getting the following error: resize2fs /dev/mapper/centos-root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblock. So after a bit of Googling found out I had to use xfs_growfs instead, as following: xfs_growfs /dev/centos/root meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=406016 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=1624064, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 1624064 to 4769792 10) Finally check again the file system disk space df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.8M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/mapper/centos-root 19G 1.9G 17G 11% / /dev/sda1 1014M 179M 836M 18% /boot tmpfs 783M 0 783M 0% /run/user/0 Src: https://blog.bertello.org/2019/12/resizing-centos-7-disk/ Related Administrations Configurations (Linux) CentOSCentOS 7LVMXFS
Figthing with FTP Access (Proftpd) May 18, 2008 I came this morning to my office desk, tried to put something into my newly set up blog. God knows, why teh hell did i try to make a small change in my Blog URI settings! Anyway, I tried to create some different URI path with Blog- by Date and… Read More
Assign range of IP addresses to an interface October 2, 2018 For example, you need to assign the IP range 192.168.10.6 – 192.168.10.100 to your eth0 interface. Create a range file in /etc/sysconfig/network-scripts/ifcfg-eth0-range0 as below DEVICE=eth0 BOOTPROTO=static IPADDR_START=192.168.10.6 IPADDR_END=192.168.10.100 NETMASK=255.255.255.0 CLONENUM_START=1 ONBOOT=yes TYPE=Ethernet CLONENUM_START is the number that will be assigned to the first IP alias interface (eth0:1 in this example)…. Read More
Install nginx on virtualmin (GPL) server August 26, 2012 Installing Nginx Support Switching a system from the Apache webserver (installed by default by Virtualmin to Nginx should only be done if no virtual servers with websites have been created yet. Ideally the change should be done on a freshly installed system, running RHEL 6.0, CentOS 6.0 or Debian 6.0… Read More