How to create LVM for XFS file system under Ubuntu

Foreword

lvm (Logical Volume Manager) Logical volume management can meet the needs of the Linux system to dynamically adjust the size of each partition to meet the needs of the server in different operating periods.

In the past, playing LVM under Linux usually chose ext3 and ext4 file systems. Recently, a MySQL database server was installed and configured under Ubuntu 16.04.5. Then I tested the LVM of the XFS file system. In contrast, the difference is not big, just the difference in file formatting and the adjustment commands of the file system. Many places below do not explain too much, but simply record the test process.

Add a new disk to the test server, as shown below, the new disk is /dec/sdc

root@mylnx12:~# fdisk -l
Disk /dev/sdb:605 GiB,649613803520 bytes,1268776960 sectors
Units: sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disklabel type: dos
Disk identifier:0x2c2c38b3
Device  Boot Start  End Sectors Size Id Type
/dev/sdb1  204812687749111268772864 605G 7 HPFS/NTFS/exFAT
Disk /dev/sda:30 GiB,32212254720 bytes,62914560 sectors
Units: sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disklabel type: dos
Disk identifier:0x6e2369f9
Device  Boot Start  End Sectors Size Id Type
/dev/sda1 *20486291452662912479 30G 83 Linux
Disk /dev/sdc:1023 GiB,1098437885952 bytes,2145386496 sectors
Units: sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disklabel type: dos
Disk identifier:0x030b81c8
Device  Boot Start  End Sectors Size Id Type
/dev/sdc1  204821453864952145384448 1023G 83 Linux
# Create PV
root@mylnx12:~# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
root@mylnx12:~# pvscan
PV /dev/sdc1      lvm2 [1023.00 GiB]
Total:1[1023.00 GiB]/in use:0[0]/in no VG:1[1023.00 GiB]
# Create VG
root@mylnx12:~# vgcreate -s 32M VolGroup01 /dev/sdc1
Volume group "VolGroup01" successfully created
# Add LV
root@mylnx12:~# lvcreate -L +400G -n LogVol00 VolGroup01
WARNING: xfs signature detected on /dev/VolGroup01/LogVol00 at offset 0. Wipe it?[y/n]: y
Wiping xfs signature on /dev/VolGroup01/LogVol00.
Logical volume "LogVol00" created.
root@mylnx12:~# lvscan
ACTIVE   '/dev/VolGroup01/LogVol00'[400.00 GiB] inherit
# format
root@mylnx12:~# mkfs.xfs /dev/VolGroup01/LogVol00
meta-data=/dev/VolGroup01/LogVol00 isize=512 agcount=4, agsize=26214400 blks
=  sectsz=512 attr=2, projid32bit=1=      crc=1  finobt=1, sparse=0
data  =      bsize=4096 blocks=104857600, imaxpct=25=      sunit=0  swidth=0 blks
naming =version 2    bsize=4096 ascii-ci=0 ftype=1
log  =internal log   bsize=4096 blocks=51200, version=2=      sectsz=512 sunit=0 blks, lazy-count=1
realtime =none     extsz=4096 blocks=0, rtextents=0
# Mount point settings
root@mylnx12:~# mkdir /mysql_data
root@mylnx12:~# mount -t xfs /dev/VolGroup01/LogVol00 /mysql_data
root@mylnx12:~# vgdisplay
- - - Volume group ---
VG Name    VolGroup01
System ID    
Format    lvm2
Metadata Areas  1
Metadata Sequence No 2
VG Access    read/write
VG Status    resizable
MAX LV    0
Cur LV    1
Open LV    0
Max PV    0
Cur PV    1
Act PV    1
VG Size    1022.97 GiB
PE Size    32.00 MiB
Total PE    32735
Alloc PE / Size  12800/400.00 GiB
Free PE / Size  19935/622.97 GiB
VG UUID    8kutIc-bjId-rNWK-UCHo-TU2l-xkwa-idBXCj
# Create another LV
root@mylnx12:~# lvcreate -l 19935-n LogVol01 VolGroup01
Logical volume "LogVol01" created.
root@mylnx12:~# mkfs.xfs /dev/VolGroup01/LogVol01
meta-data=/dev/VolGroup01/LogVol01 isize=512 agcount=4, agsize=40826880 blks
=  sectsz=512 attr=2, projid32bit=1=      crc=1  finobt=1, sparse=0
data  =      bsize=4096 blocks=163307520, imaxpct=25=      sunit=0  swidth=0 blks
naming =version 2    bsize=4096 ascii-ci=0 ftype=1
log  =internal log   bsize=4096 blocks=79740, version=2=      sectsz=512 sunit=0 blks, lazy-count=1
realtime =none     extsz=4096 blocks=0, rtextents=0
root@mylnx12:~# mkdir /mysql_backup
root@mylnx12:~# mount -t xfs /dev/VolGroup01/LogVol01 /mysql_backup/
root@mylnx12:~# df -h
Filesystem      Size Used Avail Use% Mounted on
udev        6.9G  06.9G 0%/dev
tmpfs       1.4G 8.6M 1.4G 1%/run
/dev/sda1       30G 2.1G 27G 8% /
tmpfs       6.9G  06.9G 0%/dev/shm
tmpfs       5.0M  05.0M 0%/run/lock
tmpfs       6.9G  06.9G 0%/sys/fs/cgroup
/dev/sdb1      596G 70M 566G 1%/mnt
tmpfs       1.4G  01.4G 0%/run/user/1000/dev/mapper/VolGroup01-LogVol00 400G 441M 400G 1%/mysql_data
/dev/mapper/VolGroup01-LogVol01 623G 668M 623G 1%/mysql_backup

Modify the configuration file /etc/fstab, and add the following configuration information to it, as shown below, for permanent preservation, to ensure that the relevant mount point information will not be lost the next time you boot.

UUID="a72bd3f8-eb2d-40cb-92c3-d5e32c30d5ff"/mysql_data xfs defaults 02
UUID="33325d87-f3f4-4215-abf7-ee795724697e"/mysql_backup xfs defaults 02

In addition, the adjustment command for the ext2/ext3/ext4 file system is resize2fs (both increase and decrease are supported), and the adjustment command for the XFS file system is xfs_growfs (only increase). Of course, if you have to reduce it, you can only reduce it. After the young, re-format the logical partition through the mkfs.xfs command to mount it. In this case, the original data on the logical partition will be lost. It doesn't make much sense.

Reference material:

https://www.zalou.cn/article/148553.htm

to sum up

The above is the entire content of this article. I hope that the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message and exchange. Thank you for your support to ZaLou.Cn.

Recommended Posts

How to create LVM for XFS file system under Ubuntu
How to extend the root directory of LVM under Ubuntu system
How to compile ijkplayer-android under ubuntu
How to install Audacious under Ubuntu
How to install Tensorflow under ubuntu 16.04
How to realize file sharing between Ubuntu and Windows under VMware
How to change MySQL password under Ubuntu
How to install vim editor under Linux (Ubuntu 18.04)
How to use dpkg command in Ubuntu system
How to open the ubuntu system in win10
[Practice] How to install python3.6 on Ubuntu system
Steps to add toolkit for Matlab_Linux under ubuntu
How to configure /var/log/messages in Ubuntu system log
How to enable Mysql remote access under Ubuntu 14.04
How to install gcc compiler faster under Ubuntu
How to upgrade to Ubuntu 20.04
How to upgrade to Ubuntu 20.04
How to use LVM to manage storage devices on Ubuntu 18.04
How to create and use MongoDB backups on Ubuntu 14.04
How to set up Ghost one-click app for Ubuntu 16.04
How to configure DNS for Ubuntu to make it permanent
How to modify time zone and time in ubuntu system
How to install two versions of OpenCV under ubuntu?
How to install theano and keras on ubuntu system
Online expansion of file system by LVM under Centos7
How to create a Python virtual environment in Ubuntu 14.04
How to repair a damaged Ubuntu system without reinstalling
Teach you how to install Ubuntu system enhancement tools
How to open https on nginx server under Ubuntu
How to control the ubuntu system in win10 through ssh
How to build an NFS file sharing server on Ubuntu 16.04
How to set up vsftpd for anonymous downloads on Ubuntu 16.04
How to install JDK and Mysql on Ubuntu 18.04 linux system
How to set up vsftpd for user directories on Ubuntu 16.04
How to create a Sudo user on Ubuntu [Quick Start]
How to upgrade to Ubuntu 16.04 LTS
How to map shared disk to window in linux under Ubuntu
How to fix the problem of missing system settings on Ubuntu 14.04
How to install Helm in Ubuntu
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to use hanlp in ubuntu
How to install VirtualBox on Ubuntu 20.04
Use QQ under Ubuntu 13.10, suitable for 14.10
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to write python configuration file
Deploy the mail system under Ubuntu 19.10
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install mysql in Ubuntu 14.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04