添加硬盘并分区(逻辑卷)

1.添加一块硬盘
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
2.启动虚拟机查看分区
查看磁盘

[root@localhost ~]# fdisk -l

在这里插入图片描述
3. 对/dev/sdb分区

[root@localhost ~]# fdisk /dev/sdb

Command (m for help): n                      ##新建分区
Command action
   e   extended
   p   primary partition (1-4)
p								 			##新建主分区
Partition number (1-4): 
Value out of range.
Partition number (1-4): 1
First cylinder (1-13054, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-13054, default 13054): +10G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1218-13054, default 1218): 
Using default value 1218
Last cylinder or +size or +sizeM or +sizeK (1218-13054, default 13054): +10G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (2435-13054, default 2435): 
Using default value 2435
Last cylinder or +size or +sizeM or +sizeK (2435-13054, default 13054): +10G

Command (m for help): n

Command action
   e   extended
   p   primary partition (1-4)
e								##新建扩展分区
Selected partition 4
First cylinder (3652-13054, default 3652): 
Using default value 3652
Last cylinder or +size or +sizeM or +sizeK (3652-13054, default 13054): 
Using default value 13054

Command (m for help): n
First cylinder (3652-13054, default 3652): 
Using default value 3652
Last cylinder or +size or +sizeM or +sizeK (3652-13054, default 13054): +10G

Command (m for help): n
First cylinder (4869-13054, default 4869): 
Using default value 4869
Last cylinder or +size or +sizeM or +sizeK (4869-13054, default 13054): +10G

Command (m for help): n
First cylinder (6086-13054, default 6086): 
Using default value 6086
Last cylinder or +size or +sizeM or +sizeK (6086-13054, default 13054): +10G

Command (m for help): n
First cylinder (7303-13054, default 7303): 
Using default value 7303
Last cylinder or +size or +sizeM or +sizeK (7303-13054, default 13054): +10G

Command (m for help): n
First cylinder (8520-13054, default 8520): 
Using default value 8520
Last cylinder or +size or +sizeM or +sizeK (8520-13054, default 13054): 10G
Value out of range.
Last cylinder or +size or +sizeM or +sizeK (8520-13054, default 13054): 
Using default value 13054

Command (m for help): p            ##打印分区列表

Disk /dev/sdb: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1217     9775521   83  Linux
/dev/sdb2            1218        2434     9775552+  83  Linux
/dev/sdb3            2435        3651     9775552+  83  Linux
/dev/sdb4            3652       13054    75529597+   5  Extended
/dev/sdb5            3652        4868     9775521   83  Linux
/dev/sdb6            4869        6085     9775521   83  Linux
/dev/sdb7            6086        7302     9775521   83  Linux
/dev/sdb8            7303        8519     9775521   83  Linux
/dev/sdb9            8520       13054    36427356   83  Linux

Command (m for help): t  
Partition number (1-9): q
Partition number (1-9): 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-9): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-9): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-9): 4
Hex code (type L to list codes): 8e
You cannot change a partition into an extended one or vice versa
Delete it first.

Command (m for help): t
Partition number (1-9): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-9): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-9): 7
Hex code (type L to list codes): 8e
Changed system type of partition 7 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-9): 8
Hex code (type L to list codes): 8e
Changed system type of partition 8 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-9): 9
Hex code (type L to list codes): 8e
Changed system type of partition 9 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1217     9775521   8e  Linux LVM
/dev/sdb2            1218        2434     9775552+  8e  Linux LVM
/dev/sdb3            2435        3651     9775552+  8e  Linux LVM
/dev/sdb4            3652       13054    75529597+   5  Extended
/dev/sdb5            3652        4868     9775521   8e  Linux LVM
/dev/sdb6            4869        6085     9775521   8e  Linux LVM
/dev/sdb7            6086        7302     9775521   8e  Linux LVM
/dev/sdb8            7303        8519     9775521   8e  Linux LVM
/dev/sdb9            8520       13054    36427356   8e  Linux LVM

Command (m for help): w              ##保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

刷新磁盘列表,使配置生效

[root@localhost ~]# partprobe 

3.创建逻辑卷

创建物理卷

[root@localhost ~]# pvcreate /dev/sdb1 /dev/sdb2
  Physical volume "/dev/sdb1" successfully created
  Physical volume "/dev/sdb2" successfully created

创建卷组

[root@localhost ~]# vgcreate vg_orasoft /dev/sdb1 /dev/sdb2
  Volume group "vg_orasoft" successfully created

创建逻辑卷

[root@localhost ~]# lvcreate -n lv_orasoft_u01 -L 15G vg_orasoft
  Logical volume "lv_orasoft_u01" created

创建文件系统

[root@localhost ~]# mkfs.ext3 /dev/vg_orasoft/lv_orasoft_u01 

创建目录并挂载

[root@localhost ~]# mkdir /u01
[root@localhost ~]# mount /dev/vg_orasoft/lv_orasoft_u01 /u01

写入开机挂载文件中

[root@localhost ~]# vim /etc/fstab 
/dev/vg_orasoft/lv_orasoft_u01 /u01 ext3 defaults 0 0
[root@localhost ~]# mount -a

4. 逻辑卷扩展
扩展卷组

[root@localhost ~]# vgextend vg_orasoft /dev/sdb3
  Volume group "vg_orasoft" successfully extended

创建一个逻辑卷

[root@localhost ~]# lvcreate -n lv_orasoft -L 10G vg_orasoft
  Logical volume "lv_orasoft" created

格式化

[root@localhost ~]# mkfs.ext3 /dev/vg_orasoft/lv_orasoft

创建目录挂载

[root@localhost ~]# mkdir /soft
[root@localhost ~]# mount /dev/vg_orasoft/lv_orasoft /soft

写入开机挂载文件中

[root@localhost ~]# mount -a
[root@localhost ~]# vim /etc/fstab 
/dev/vg_orasoft/lv_orasoft  /soft ext3 defaults 0 0

给目录777的权限

[root@localhost ~]# chmod 777 /soft/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值