linux分区及逻辑卷划分 下载本文

内容发布更新时间 : 2024/5/2 1:03:29星期一 下面是文章的全部内容请认真阅读。

划分磁盘阵列和创建逻辑卷

标题 01创建磁盘阵列分区 02创建逻辑卷组和逻辑卷 03绑定逻辑卷和裸设备

内容 介绍如何创建磁盘阵列分区。 介绍如何创建逻辑卷组和逻辑卷。 介绍如何绑定逻辑卷和裸设备。 [键入文字]

0划分磁盘阵列和创建逻辑卷

1创建磁盘阵列分区

任务说明

执行此任务可以手动格式化磁盘阵列并根据需要创建新的分区。

本节以在双机上创建分区/dev/sdc1为例,给出手动创建磁盘分区的方法。操作时请根据实际的安装规划调整分区的具体信息。

操作指引

创建磁盘阵列的磁盘分区操作步骤如下:

步骤 1 以root用户登录主节点。 步骤 2 检查磁盘阵列的分区信息。

# fdisk -l

屏幕显示信息如下(供参考)。

Disk /dev/sda: 40.0 GB, 40007756288 bytes 64 heads, 32 sectors/track, 38154 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System /dev/sda1 1 1024 1048560 82 Linux swap /dev/sda2 1025 11264 10485760 83 Linux /dev/sda3 11265 38154 27535360 83 Linux

Disk /dev/sdb: 128.8 GB, 128849018880 bytes 255 heads, 63 sectors/track, 15665 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 73.1 GB, 73139224576 bytes 255 heads, 63 sectors/track, 8892 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

从以上加粗的信息可以看出磁盘阵列里的逻辑盘sdb和sdc没有划分分区。

步骤 3 格式化磁盘。

# fdisk /dev/sdc

屏幕显示信息如下(供参考)。

The number of cylinders for this disk is set to 8892.

There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with:

2

1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)

步骤 4 查看fdisk命令的参数。

Command (m for help):m 屏幕显示信息如下(供参考)。

Command action

a toggle a bootable flag b edit bsd disklabel

c toggle the dos compatibility flag d delete a partition

l list known partition types m print this menu

n add a new partition

o create a new empty DOS partition table p print the partition table q quit without saving changes

s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit

x extra functionality (experts only)

步骤 5 查看磁盘/dev/sdc的分区表。

Command (m for help):p 屏幕显示信息如下(供参考)。

Disk /dev/sdc: 73.1 GB, 73139224576 bytes 255 heads, 63 sectors/track, 8892 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

步骤 6 给磁盘/dev/sdc添加新的分区。

Command (m for help):n 屏幕显示信息如下(供参考)。

Command action e extended

p primary partition (1-4)

步骤 7 配置分区信息。

1. 输入“p”,设定分区为主分区,按“Enter”键。 2. 输入“1”,划分/dev/sdc1分区,按“Enter”键。

Partition number (1-4):1

3. 输入柱面开始位置,按“Enter”键。

First cylinder (1-8892, default 1):1

[键入文字]

0划分磁盘阵列和创建逻辑卷

4. 输入柱面结束位置,按“Enter”键。

Last cylinder or +size or +sizeM or +sizeK (1-8892, default 8892):8892

步骤 8 设置分区ID。

1. 输入修改分区编号的命令。 Command (m for help):t 2. 输入待修改的分区编号。

Partition number (1-4): 1

3. 输入分区类型“8e”。

Hex code (type L to list codes): 8e

步骤 9 查看磁盘/dev/sdc的分区表,检查分区是否成功。

Command (m for help):p 屏幕显示信息如下(供参考)。

Disk /dev/sdc: 73.1 GB, 73139224576 bytes 255 heads, 63 sectors/track, 8892 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdc1 1 8892 71424958+ 8e Linux LVM

步骤 10 将分区信息写入分区表并退出fdisk命令。

Command (m for help):w 屏幕显示信息如下(供参考)。

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table.

The new table will be used at the next reboot. Syncing disks.

步骤 11 重启操作系统。

# reboot

步骤 12 检查磁盘阵列的分区信息。

# fdisk -l

屏幕显示信息如下(供参考)。

Disk /dev/sda: 40.0 GB, 40007756288 bytes 64 heads, 32 sectors/track, 38154 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System /dev/sda1 1 1024 1048560 82 Linux swap /dev/sda2 1025 11264 10485760 83 Linux

4

/dev/sda3 11265 38154 27535360 5 Extended /dev/sda5 11265 21504 10485744 83 Linux /dev/sda6 21505 37888 16777200 83 Linux

Disk /dev/sdb: 128.8 GB, 128849018880 bytes 255 heads, 63 sectors/track, 15665 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 73.1 GB, 73139224576 bytes 255 heads, 63 sectors/track, 8892 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdc1 1 8892 71424958+ 8e Linux LVM

----结束

2创建逻辑卷组和逻辑卷

任务说明

执行此任务可以手动创建物理卷、逻辑卷组和逻辑卷。

上一节划分了分区/dev/sdc1。本节在双机上以/dev/sdc1为物理卷创建逻辑卷组oracledg及其逻辑卷为例,介绍如何手动创建逻辑卷组和逻辑卷。

?

?

逻辑卷组oracledg的逻辑卷划分以安装规划为准。

操作指引

创建逻辑卷组和逻辑卷操作步骤如下:

步骤 1 以root用户登录主节点。 步骤 2 创建物理卷。

# pvcreate /dev/sdc1

屏幕显示信息如下(供参考)。

Physical volume \

步骤 3 检查物理卷创建是否成功。

# pvscan

屏幕显示信息如下(供参考)。

PV /dev/sdc1 lvm2 [34.06 GB]

Total: 1 [34.06 GB] / in use: 0 [0 ] / in no VG: 1 [34.06 GB]

[键入文字]