分类: LINUX
2013-12-25 09:37:19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@localhost ~]# fdisk /dev/sda
Command (m for help): p
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1 ####创建第一个分区
First cylinder (1-261, default 1): ##默认回车
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261): +500M
##500M空间
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2 ##第二个分区
First cylinder (66-261, default 66):
Using default value 66
Last cylinder, +cylinders or +size{K,M,G} (66-261, default 261): +500M ##创建了两个500M分分区
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
[root@localhost ~]# fdisk /dev/sda
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): p
Device Boot Start End Blocks Id System
/dev/sda1 1 65 522081 83 Linux
/dev/sda2 66 130 522112+ 83 Linux
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
Command (m for help): p
Device Boot Start End Blocks Id System
/dev/sda1 1 65 522081 8e Linux LVM
/dev/sda2 66 130 522112+ 8e Linux LVM
#Partition number (1-4): 2 输入盘符
#Hex code (type L to list codes): 8e ##格式类型
|
1
2
3
4
5
6
|
首先激活分区执行:partprobe
[root@localhost ~]# pvcreate /dev/sda1
Physical volume "/dev/sda1" successfully created
[root@localhost ~]# pvcreate /dev/sda2
Physical volume "/dev/sda2" successfully created
使用pvdisplay 查看建的pv
|
1
2
3
|
[root@localhost ~]# vgcreate VG001 /dev/sda1 /dev/sda2
Volume group "VG001" successfully created
使用vgdisplay 查看。由于sda1 sda2每个都是500M 这个VG001卷容量为1G
|
1
2
3
|
[root@localhost ~]# lvcreate -L 800M -nlv0 VG001
Logical volume "lv0" created
使用 lvdisplay可以查看到 /dev/VG001/lv0的容量为800M 那么此时VG001容量为200M
|
1
|
mkfs.ext3 /dev/VG001/lv0
|
1
2
3
4
5
6
7
8
9
|
[root@localhost ~]# mount /dev/VG001/lv0 /mnt/
[root@localhost ~]# df -lh
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
19G 5.0G 13G 29% /
tmpfs 242M 0 242M 0% /dev/shm
/dev/sdb1 485M 53M 408M 12% /boot
/dev/mapper/VG001-lv0
788M 17M 731M 3% /mnt
|
1
2
3
|
[root@localhost ~]# lvextend -L+100M /dev/VG001/lv0
Extending logical volume lv0 to 900.00 MiB
Logical volume lv0 successfully resized
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
fdisk /dev/sda
Device Boot Start End Blocks Id System
/dev/sda1 1 65 522081 8e Linux LVM
/dev/sda2 66 130 522112+ 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (131-261, default 131):
Using default value 131
Last cylinder, +cylinders or +size{K,M,G} (131-261, default 261): +600M
Command (m for help): p
Device Boot Start End Blocks Id System
/dev/sda1 1 65 522081 8e Linux LVM
/dev/sda2 66 130 522112+ 8e Linux LVM
/dev/sda3 131 207 618502+ 83 Linux
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): p
Device Boot Start End Blocks Id System
/dev/sda1 1 65 522081 8e Linux LVM
/dev/sda2 66 130 522112+ 8e Linux LVM
/dev/sda3 131 207 618502+ 8e Linux LVM
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
lvextend -L+700M /dev/VG001/lv0
e2fsck -f /dev/VG001/lv0
resize2fs /dev/VG001/lv0
mount /dev/VG001/lv0 /mnt
[root@localhost soft]# df -lh
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
19G 5.1G 13G 30% /
tmpfs 242M 0 242M 0% /dev/shm
/dev/sdb1 485M 53M 408M 12% /boot
/dev/mapper/VG001-lv0
1.6G 18M 1.5G 2% /mnt
########## 此时可以看到mnt的容量由最开始的800M变成800+100+700=1600M
|
1
2
3
4
5
6
7
8
9
10
11
12
|
fdisk -l :查看系统中都认到了那些物理硬盘
pvdisplay:查看系统中已经创建好的物理卷
pvcreate:创建一个新的物理卷
pvremove:删除一个物理卷(也就是从物理卷中删除一个LVM标签)
vgdisplay:查看系统中的卷组
vgcreate:创建一个新的卷组
vgreduce:从卷组中删除一个物理卷(也就是缩小卷组)
vgremove:删除一个卷组
lvdisplay:查看系统中已经创建好的逻辑卷
lvcreate:创建一个新的逻辑卷
lvreduce:缩小逻辑卷(也就是从一个逻辑卷中减少一些LE)
lvremove:从系统中删除一个逻辑卷
|