侧边栏壁纸
博主头像
学海无涯博主等级

学无止境

  • 累计撰写 321 篇文章
  • 累计创建 80 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Linux创建LVM磁盘分区

利刃
2019-01-28 / 0 评论 / 0 点赞 / 4 阅读 / 3195 字
温馨提示:
本文最后更新于 2024-08-13,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

一、创建LVM格式分区

ACES01:~ # ls /dev/sdb
/dev/sdb
ACES01:~ # fdisk /dev/sdb

Welcome to fdisk (util-linux 2.28).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xedea1b84.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-33554431, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-33554431, default 33554431): 33554431

Created a new partition 1 of type 'Linux' and of size 16 GiB.

Command (m for help): t
Selected partition 1
Partition type (type L to list all types): 8e
Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

二、创建LVM卷


ACES01:~ # ls /dev/sdb1
/dev/sdb1
ACES01:~ # pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
ACES01:~ # pvs
  PV         VG     Fmt  Attr PSize   PFree 
  /dev/sda1  system lvm2 a--  100.00g 38.00g
  /dev/sdb1         lvm2 ---   16.00g 16.00g
ACES01:~ # vgcreate vgshare01 /dev/sdb1
  Volume group "vgshare01" successfully created
ACES01:~ # vgs
  VG        #PV #LV #SN Attr   VSize   VFree 
  system      1   2   0 wz--n- 100.00g 38.00g
  vgshare01   1   0   0 wz--n-  16.00g 16.00g
ACES01:~ # lvcreate -n lvshare01 -l 100%FREE vgshare01
  Logical volume "lvshare01" created.
ACES01:~ # lvs
  LV        VG        Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root      system    -wi-ao---- 60.00g                                                    
  swap      system    -wi-ao----  2.00g                                                    
  lvshare01 vgshare01 -wi-a----- 16.00g     

三、格式化并挂载lv卷

ACES01:~ # mkfs.ext4 /dev/vgshare01/lvshare01 
mke2fs 1.42.11 (09-Jul-2014)
Creating filesystem with 4193280 4k blocks and 1048576 inodes
Filesystem UUID: a823269d-656d-4e66-9c4e-4eac54c7b488
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   
ACES01:~ # mkdir /share
ACES01:~ # mount /dev/vgshare01/lvshare01 /share/
ACES01:~ # cd /share/
ACES01:/share # ls
lost+found

2019-1-28 12:44:22

0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区