Create and Extend XFS filesystem based on LVM: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 102: | Line 102: | ||
This mount will disappear on reboot, to make it permanent use /etc/fstab file. | This mount will disappear on reboot, to make it permanent use /etc/fstab file. | ||
==Extend the size of xfs file system== |
Revision as of 08:53, 16 August 2019
Create XFS filesystem on LVM
Create a partition using fdisk
Run this command and set the options as below obviously changing the bits that are unique to your setup (i.e size):
fdisk /dev/sdb
[root@james-test ~]# fdisk /dev/sdb 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. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x26d678c7. 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): 1 First sector (2048-104857599, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +40G Partition 1 of type Linux and of size 40 GiB is set Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Create LVM components : pvcreate, vgcreate and lvcreate
pvcreate /dev/sdb1
[root@james-test ~]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created.
vgcreate vg_xfs /dev/sdb1
[root@james-test ~]# vgcreate vg_xfs /dev/sdb1 Volume group "vg_xfs" successfully created
lvcreate -L +6G -n xfs_db vg_xfs
[root@james-test ~]# lvcreate -L +6G -n xfs_db vg_xfs Logical volume "xfs_db" created.
Create XFS file system on lvm parition “/dev/vg_xfs/xfs_db”
mkfs.xfs /dev/vg_xfs/xfs_db
[root@james-test ~]# mkfs.xfs /dev/vg_xfs/xfs_db meta-data=/dev/vg_xfs/xfs_db isize=512 agcount=4, agsize=393216 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=1572864, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
Mount the xfs file system
Create a directory named as xfs_test under /root and mount it using mount command.
mkdir /root/xfs_test
mount /dev/vg_xfs/xfs_db/ root/xfs_test/
Check by running:
df -h
[root@james-test /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 50G 1.5G 49G 3% / 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/sda1 1014M 189M 826M 19% /boot /dev/mapper/centos-home 42G 33M 42G 1% /home tmpfs 783M 0 783M 0% /run/user/0 /dev/mapper/vg_xfs-xfs_db 6.0G 33M 6.0G 1% /root/xfs_test
This mount will disappear on reboot, to make it permanent use /etc/fstab file.