linux lvm创建
来自mount_volume.sh文件https://opendev.org/opendev/system-config
DEVICE=$1
MOUNT_PATH=$2
FS_LABEL=$3
parted --script $DEVICE mklabel msdos mkpart primary 0% 100% set 1 lvm on
partprobe -s $DEVICE
pvcreate ${DEVICE}1
vgcreate main ${DEVICE}1
lvcreate -l 100%FREE -n $FS_LABEL main
mkfs.ext4 -m 0 -j -L $FS_LABEL /dev/main/$FS_LABEL
tune2fs -i 0 -c 0 /dev/main/$FS_LABEL
# Remove existing fstab entries for this device
perl -nle "m,/dev/main/$FS_LABEL, || print" -i /etc/fstab //相关的学习,请参考https://www.ibm.com/developerworks/cn/linux/sdk/perl/l-p102/ https://www.runoob.com/perl/perl-regular-expressions.html //m代码正则匹配,由于匹配的内容中的/,所以用逗号来包围匹配串
if [ ! -d $MOUNT_PATH ] ; then
mkdir -p $MOUNT_PATH
fi
echo "/dev/main/$FS_LABEL $MOUNT_PATH ext4 errors=remount-ro, barrier=0 0 2" >> /etc/fstab
mount -a
------------------------------------
LVCREATE(8) System Manager's Manual LVCREATE(8)
NAME
lvcreate - Create a logical volume
-l|--extents Number[PERCENT]
-n|--name String
-----------------------------------
MKE2FS(8) System Manager's Manual MKE2FS(8)
NAME
mke2fs - create an ext2/ext3/ext4 filesystem
-m reserved-blocks-percentage
Specify the percentage of the filesystem blocks reserved for the super-user. This avoids fragmentation, and allows root-owned daemons, such as syslogd(8), to continue to
function correctly after non-privileged processes are prevented from writing to the filesystem. The default percentage is 5%.
-j Create the filesystem with an ext3 journal. If the -J option is not specified, the default journal parameters will be used to create an appropriately sized journal (given
the size of the filesystem) stored within the filesystem. Note that you must be using a kernel which has ext3 support in order to actually make use of the journal.
-L new-volume-label
Set the volume label for the filesystem to new-volume-label. The maximum length of the volume label is 16 bytes.
-----------------------------
TUNE2FS(8) System Manager's Manual TUNE2FS(8)
NAME
tune2fs - adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems
-i interval-between-checks[d|m|w]
Adjust the maximal time between two filesystem checks. No suffix or d will interpret the number interval-between-checks as days, m as months, and w as weeks. A value of
zero will disable the time-dependent checking.
There are pros and cons to disabling these periodic checks; see the discussion under the -c (mount-count-dependent check) option for details.
-c max-mount-counts
Adjust the number of mounts after which the filesystem will be checked by e2fsck(8). If max-mount-counts is 0 or -1, the number of times the filesystem is mounted will be
disregarded by e2fsck(8) and the kernel.
Staggering the mount-counts at which filesystems are forcibly checked will avoid all filesystems being checked at one time when using journaled filesystems.
Mount-count-dependent checking is disabled by default to avoid unanticipated long reboots while e2fsck does its work. However, you may wish to consider the consequences
of disabling mount-count-dependent checking entirely. Bad disk drives, cables, memory, and kernel bugs could all corrupt a filesystem without marking the filesystem dirty
or in error. If you are using journaling on your filesystem, your filesystem will never be marked dirty, so it will not normally be checked. A filesystem error detected
by the kernel will still force an fsck on the next reboot, but it may already be too late to prevent data loss at that point.
---------------------------------------------