Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to add disk to create LVM under Linux

Shulou Source: shulou.com Published: 2022-06-01 02:58:23 09月22日 Update

This article is about how to add disks to create LVM under Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Shell > fdisk / dev/xvdb # Select disk

Command (m for help): M # help

Command action

A toggle a bootable flag

B edit bsd disklabel

C toggle the dos compatibility flag

D delete a partition

L list known partition types

M print this menu

N add a new partition

O create a new empty DOS partition table

P print the partition table

Q quit without saving changes

S create a new empty Sun disklabel

T change a partition's system id

U change display/entry units

V verify the partition table

W write table to disk and exit

X extra functionality (experts only)

Command (m for help): n # create a new partition

Command action

E extended

P primary partition (1-4)

P # create a primary partition

Partition number (1-4): 1 # partition ID

First cylinder (1-65270, default 1):

Using default value 1

Last cylinder, + cylinders or + size {KMagne Mpeng} (1-65270, default 65270):

Using default value 65270

Command (m for help): t # modify partition type

Command (m for help): 8e # Linux lvm

Command (m for help): W # Save changes

Shell > pvcreate / dev/xvdb1/ # create a new pv volume

Shell > pvs # View pv volumes

Shell > vgcreate VolGroup01 / dev/xvdb1/ # create a new vg volume

Shell > vgs # View vg volumes

Shell > lvcreate-L 50G-n lvmServer VolGroup01 # create logical volume-L specify partition size-n specify lvm name

Shell > mkfs.ext4 / dev/VolGroup01/lvmServer # use the mkfs.ext4 command to create an ext4 file system on the logical volume lvmServer

Shell > mount / dev/VolGroup01/lvmServer / server/ # hang from partition to local directory / server

Shell > vi / etc/fstab # modify fstab boot auto mount

#

# / etc/fstab

# Created by anaconda on Thu Aug 14 21:16:42 2014

#

# Accessible filesystems, by reference, are maintained under'/ dev/disk'

# See man pages fstab (5), findfs (8), mount (8) and/or blkid (8) for more info

#

UUID=94e4e384-0ace-437f-bc96-057dd64f42ee / ext4 defaults,barrier=0 1 1

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/VolGroup01/lvmServer / server ext4 defaults 0 0

: wq

# Save restart test

Note:

* fstab must fill in the path correctly. If there is an error, it may not start normally.

* you can mount it on rc.local using the mount command

Thank you for reading! This is the end of this article on "how to add disks to create LVM under Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Disk content command more article logic help good practical name size file article directory look knowledge type system path reference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Docker Shulou Information Huawei macOS