首页 > 系统相关 >Linux下添加磁盘创建lvm分区

Linux下添加磁盘创建lvm分区

时间:2023-08-24 22:34:46浏览次数:29  
标签:shell 分区 partition dev #### Command Linux lvm 磁盘

shell> fdisk /dev/xvdb                               #### 选择磁盘
Command (m for help): m                              #### 帮助
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                               #### 创建新的分区
Command action
   e   extended
   p   primary partition (1-4)
p                                                     #### 创建主分区
Partition number (1-4):1                              #### 分区ID
First cylinder (1-65270, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-65270, default 65270): 
Using default value 65270

Command (m for help):t                                 #### 修改分区类型
Command (m for help):8e                                #### Linux lvm
Command (m for help):w                                 #### 保存修改
shell> pvcreate /dev/xvdb1/                            #### 创建新的pv卷
shell> pvs                                             #### 查看pv卷
shell> vgcreate VolGroup01 /dev/xvdb1/                 #### 创建新的vg卷
shell> vgs                                             #### 查看vg卷
shell> lvcreate -L 50G -n lvmServer    VolGroup01      #### 创建逻辑卷 -L 指定分区大小 -n 指定lvm名称
shell> mkfs.ext4 /dev/VolGroup01/lvmServer             #### 使用mkfs.ext4命令在逻辑卷lvmServer上创建ext4文件系统
shell> mount /dev/VolGroup01/lvmServer /server/        #### 挂在分区到本地目录/server
shell> vi /etc/fstab                                   #### 修改fstab 开机自动挂载
#
# /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
#### 保存重启测试 
注意:
* fstab一定要正确填写路径,一旦出错,可能无法正常启动.
* 可以在rc.local使用mount命令进行挂载


转载自https://www.cnblogs.com/youn/p/6079376.html

标签:shell,分区,partition,dev,####,Command,Linux,lvm,磁盘
From: https://www.cnblogs.com/northlander/p/17655318.html

相关文章

  • docker想保留ip和端口其他的不要,想把这个变成linux的命令怎么做?
    docker想保留ip和端口其他的不要,想把这个变成linux的命令怎么做?dockerps只会显示这样一坨东西,看ip和端口又不好看456746ec7581moxi/mogu_blog_nacos"/usr/sbin/init"12hoursagoUp12hours0.0.0.0:465->465/tcp,:::465->465/tcp,0.0.0.0:3306->3306/tcp,:......
  • 手把手教你Linux CentOS 8 安装MySQL 8
     安装步骤我所使用的Linux版本是CentOS8,在CentOS8上安装MySQL的步骤:启用MySQL8.0存储库首先,您需要启用MySQL8.0存储库。为此,请下载和安装MySQL的存储库包:sudodnfinstallhttps://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm安装MyS......
  • 利用systemd设置springboot微服务服务在linux重启后自启动
    要使SpringBoot服务的JAR包在Linux重启后自启动,您可以使用systemd。以下是步骤:1.创建一个systemd服务单元文件在/etc/systemd/system/目录下,创建一个新的服务单元文件,例如my-springboot-app.service。使用sudo打开一个文本编辑器来创建和编辑文件:sudonano/e......
  • Linux之Shell脚本与Nginx
    1.入门Shell脚本1.1HelloWord打开我们的finalshell软件连接虚拟机在/usr/local/下创建一个点后缀为test的文件且编辑文件文件头部固定语句必须输入#!/bin/bash随后在下面我们直接输出一句Helloword按下ESC键且输入:wq保存退出后,这时不能直接执行,因为这个时候的文件你......
  • Linux 内核音频子系统调试
    debugfs文件系统debugfs可以为Linux内核各个模块的分析调试,提供许多信息,如音频子系统的ASoC,以及tracing等。debugfs文件系统可以通过命令行工具挂载,如下所示:root@apollo:~#ls/sys/kernel/debug/root@apollo:~#mount-tdebugfsnodev/sys/kernel/debugroot@apollo......
  • Linux下修改文件编码格式
    查看文件编码格式:filefishmails.csv.old修改文件编码格式:iconv-fiso-8859-1-tUTF-8fishmails.csv.oldt-o fishmails.csv ......
  • linux的用户配置文件(4个用户文件)
    Linux中用户与组原创 凉兮 凉兮的运维日记 2023-08-2411:07 发表于北京收录于合集#linux11个#管理员1个#linux系统5个一、基本概念1、基本介绍    Linux作为一种多用户的操作系统(服务器系统),允许多个用户同时登录到系统上,并响应每个用户的请求。任何......
  • 浅谈 Linux 下 vim 的使用
    Vim是从vi发展出来的一个文本编辑器,其代码补全、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用。Vi是老式的字处理器,功能虽然已经很齐全了,但还有可以进步的地方。Vim可以说是程序开发者的一项很好用的工具。对于大多数用户来说,Vim刚开始学习的时候可能会进......
  • Linux基础命令:应付测试面试
    1.进入文件命令vi文件名(一定要知道是那个目录下的文件) 下图为进入该文件: 2.编辑文件:先按I进入编辑模式就可以随便写入了保存之前一定要先退出编辑模式:按ESC接下来就是保存:    :q 不保存直接退出    ......
  • CentOS 8 无痕升级到 Rocky Linux
    CentOS8无痕升级到RockyLinux1.升级当前系统dnfupgrade-y2.重启当前系统:reboot3.下载脚本:CentOS8到RockyLinux8https://github.com/rocky-linux/rocky-tools/blob/main/migrate2rocky/migrate2rocky.sh8至9curl-Ohttps://github.com/rocky-linux/rocky-to......