前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >Linux挂载逻辑卷

Linux挂载逻辑卷

作者头像
mingjie
发布2022-05-12 09:24:25
发布2022-05-12 09:24:25
6.1K00
代码可运行
举报
运行总次数:0
代码可运行

步骤

1 检查挂载磁盘

代码语言:javascript
代码运行次数:0
运行
复制
df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G   16G   22G  42% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G   40K   16G   1% /dev/shm
tmpfs            16G  1.4M   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
tmpfs           3.2G   48K  3.2G   1% /run/user/0
tmpfs           3.2G     0  3.2G   0% /run/user/1000

2 查看硬盘

只有第一块硬盘/dev/vda已经配置到/dev/vda1,另外三块硬盘只有设备没有device boot

代码语言:javascript
代码运行次数:0
运行
复制
fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b1b45

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83875364    41936658+  83  Linux

Disk /dev/vdb: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/vdc: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/vdd: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

3 配置硬盘

代码语言:javascript
代码运行次数:0
运行
复制
fdisk /dev/vdb
n # 1
t # 8e          
w               #fdisk -l 看到device boot:/dev/vdb1

fdisk /dev/vdc
n # 1
t # 8e          
w               #fdisk -l 看到device boot:/dev/vdc1

完整记录

代码语言:javascript
代码运行次数:0
运行
复制
Command (m for help): n 1
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-1048575999, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1048575999, default 1048575999):
Using default value 1048575999
Partition 1 of type Linux and of size 500 GiB is set

Command (m for help): t 8e
Selected partition 1
Hex code (type L to list all codes):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): w
The partition table has been altered!

4 创建PV物理卷

代码语言:javascript
代码运行次数:0
运行
复制
pvcreate /dev/vdb1
  Physical volume "/dev/vdb1" successfully created.
  
pvcreate /dev/vdc1
  Physical volume "/dev/vdc1" successfully created.
  
pvdisplay
  "/dev/vdc1" is a new physical volume of "<500.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/vdc1
  VG Name
  PV Size               <500.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0

  "/dev/vdb1" is a new physical volume of "<500.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/vdb1
  VG Name
  PV Size               <500.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0

5 创建卷组

代码语言:javascript
代码运行次数:0
运行
复制
vgcreate vgdata /dev/vdb1 /dev/vdc1
  Volume group "vgdata" successfully created
  
vgdisplay
  --- Volume group ---
  VG Name               vgdata
  System ID
  Format                lvm2
  Metadata Areas        2
  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                2
  Act PV                2
  VG Size               999.99 GiB
  PE Size               4.00 MiB
  Total PE              255998
  Alloc PE / Size       0 / 0
  Free  PE / Size       255998 / 999.99 GiB

6 创建逻辑卷

代码语言:javascript
代码运行次数:0
运行
复制
lvcreate -l 100%VG vgdata -n lvdata
  Logical volume "lvdata" created.
  
lvdisplay
  --- Logical volume ---
  LV Path                /dev/vgdata/lvdata
  LV Name                lvdata
  VG Name                vgdata
  LV UUID                dmfqds-IiEY-l3JV-cYQj-KAOM-hcFu-30sh8O
  LV Write Access        read/write
  LV Creation host, time iZbp1d4tisi44j6vxze02fZ, 2019-05-29 19:56:14 +0800
  LV Status              available
  # open                 0
  LV Size                999.99 GiB
  Current LE             255998
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           252:0
  
ll /dev/vgdata/lvdata
lrwxrwxrwx 1 root root 7 May 29 19:56 /dev/vgdata/lvdata -> ../dm-0

7 格式化

代码语言:javascript
代码运行次数:0
运行
复制
mkfs.ext4 /dev/vgdata/lvdata

mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536000 inodes, 262141952 blocks
13107097 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2409627648
8000 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, 2654208,
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
	102400000, 214990848

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

8 挂载

代码语言:javascript
代码运行次数:0
运行
复制
mkdir /fdisk1
mount /dev/vgdata/lvdata /fdisk1/
echo "/dev/vgdata/lvdata  /fdisk1    ext4    defaults 0 0" >> /etc/fstab

9 确认挂载成功

代码语言:javascript
代码运行次数:0
运行
复制
df -h

Filesystem                 Size  Used Avail Use% Mounted on

...
/dev/mapper/vgdata-lvdata  985G   77M  935G   1% /fdisk1
...
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-05-29,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 步骤
    • 1 检查挂载磁盘
    • 2 查看硬盘
    • 3 配置硬盘
    • 4 创建PV物理卷
    • 5 创建卷组
    • 6 创建逻辑卷
    • 7 格式化
    • 8 挂载
    • 9 确认挂载成功
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档