Create LVM mount to specified directory under Linux system

Source: Internet
Author: User
Tags uuid

1. Background

In the enterprise sometimes we to facilitate the installation of software, data management, we need to install software, data into a fixed directory, the disk is full of convenient expansion, if you need a/data directory storage data, and mounted separately.

2, the Operation step 2.1 divides the disk

Please refer to (part 1-7)

Http://www.cnblogs.com/heruiguo/p/7943537.html

2.2 Creating PV

[Email protected] ~]# pvcreate/dev/sdb1
Physical volume "/DEV/SDB1" successfully created
Scan system PV can use Pvscan to view new PV

[Email protected] ~]# Pvscan
Pv/dev/sda2 VG VolGroup lvm2 [19.51 gib/0 Free]
PV/DEV/SDB1 lvm2 [10.00 GiB]
Total:2 [29.51 Gib]/in use:1 [19.51 GIB]/in no vg:1 [10.00 GIB]

2.3 Create VG

[Email protected] ~]# vgcreate VGTEST/DEV/SDB1
Volume Group "Vgtest" successfully created

Note: Vgtest is the name of the VG

Scan VG

[Email protected] ~]# Vgscan
Reading all physical volumes. This is a while ...
Found Volume Group "vgtest" using metadata type LVM2
Found Volume Group "VolGroup" using metadata type LVM2

View VG

[Email protected] ~]# Vgdisplay
---Volume Group---
VG Name vgtest
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access Read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
ACT PV 1
VG Size 10.00 GiB
PE Size 4.00 MiB
Total PE 2560
Alloc pe/size 0/0
Free pe/size 2560/10.00 GiB
VG UUID 59Z2ML-CEZB-PIVW-ZNQ9-2KBV-HSCJ-DRFDR9

---Volume Group---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access Read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
ACT PV 1
VG Size 19.51 GiB
PE Size 4.00 MiB
Total PE 4994
Alloc pe/size 4994/19.51 GiB
Free Pe/size 0/0
VG UUID upjdxo-8rjg-muvj-nvnt-hjxi-azvv-uggc2x

2.4 Creating the LV

[Email protected] ~]# lvcreate-l 2560-n lvdata vgtest
Logical volume "Lvdata" created.

2.5 Formatting the created LV

[Email protected] ~]# mkfs-t ext4/dev/vgtest/lvdata
MKE2FS 1.41.12 (17-may-2010)
File System label =
Operating system: Linux
Block size =4096 (log=2)
Chunked size =4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the Super user
First block of data =0
Maximum filesystem blocks=2684354560
Block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing Inode table: complete
Creating Journal (32768 blocks): complete
Writing Superblocks and FileSystem accounting information: Complete

This filesystem'll be automatically checked every mounts or
Whichever comes first. Use Tune2fs-c or-i to override.

2.6 Create a directory and mount it

To create a directory:

[Email protected] ~]# mkdir-p/data

Mount Directory

[Email protected] ~]# Mount/dev/vgtest/lvdata/data

View

[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup-lv_root 18G 4.9G 12G 30%/
Tmpfs 125M 72K 125M 1%/DEV/SHM
/DEV/SDA1 477M 37M 416M 9%/boot
/dev/mapper/vgtest-lvdata 9.8G 23M 9.2G 1%/data

2.7 Setting up boot Mount

[Email protected] ~]# vi/etc/fstab


#
#/etc/fstab
# Created by Anaconda on Sat 3 00:44:14 2018
#
# Accessible filesystems, by reference, is maintained under '/dev/disk '
# See mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for more info
#
/DEV/MAPPER/VOLGROUP-LV_ROOT/EXT4 Defaults 1 1
Uuid=49120546-3d8d-4b2e-8559-448613dc072a/boot EXT4 Defaults 1 2
/dev/mapper/volgroup-lv_swap swap swap defaults 0 0
TMPFS/DEV/SHM TMPFS Defaults 0 0
Devpts/dev/pts devpts gid=5,mode=620 0 0
Sysfs/sys Sysfs Defaults 0 0
PROC/PROC proc Defaults 0 0
/dev/mapper/vgtest-lvdata/data EXT4 Defaults 0 0

Create LVM mount to specified directory under Linux system

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.