Linux系统——逻辑卷创建
1、使用fdisk 创建分区
[root@ ~]# fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n #输入n,新建分区
Command action
e extended
p primary partition (1-4) p #输入p,确定主分区
Partition number (1-4): 1 #输入数字1,选择sdb1
First cylinder (1-652, default 1): #输入回车,默认
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): #输入回车,默认
Command (m for help): t #输入t,更改分区的系统id
Selected partition 1
Hex code (type L to list codes): 8e #输入8e,选择Linux LVM
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p #输入p,打印分区信息
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00093fc1
Device Boot Start End Blocks Id System
/dev/sdb1 1 132 1060258+ 8e Linux LVM
Command (m for help): w #输入w,写入分区
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
2、创建物理卷(PV)
[root@ ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
查看物理卷
[root@ ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 --- 5g 5g
[root@ ~]# pvdisplay
"/dev/sdb1" is a new physical volume of "5 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 5 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 8zlcev-vH6E-Bwe3-IXcM-jm91-ewjf-6AwsAn
3、创建卷组(VG)
创建一个名为vg_data 的卷组
[root@ ~]# vgcreate vg_data /dev/sdb1
Volume group "vg_data" successfully created
查看卷组
[root@ ~]# vgs
[root@ ~]# vgdisplay
4、创建逻辑卷(LV)
从vg_data 卷组中,创建一个名为lv_data的逻辑卷。
[root@ ~]# lvcreate -n lv_data -L +100%FREE vg_data
Logical volume "lv_data" created.
查看逻辑卷
[root@ ~]# lvs
[root@ ~]# lvdisplay
5、格式化逻辑卷
[root@ ~]# mkfs.ext4 /dev/vg_data/lv_data
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
76912 inodes, 307200 blocks
15360 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=67633152
38 block groups
8192 blocks per group, 8192 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
正在写入inode表: 完成
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
6、格式化完成后,挂载使用
[root@ ~]# vim /etc/fstab
/dev/vg_data/lv_data /db_bak ext4 defaults 0 0
[root@ ~]# mount -a