LUN挂载到Linux主机后,如何对磁盘进行分区

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LUN挂载到Linux主机后,如何对磁盘进行分区相关的知识,希望对你有一定的参考价值。

参考技术A fdisk 命令创建、修改或删除块设备上的分区
1、列出磁盘分区 fdisk -l dev/sda
2、启动fdiskknoppix@Microknoppix:~$ su -root@Microknoppix:~# fdisk /dev/sda The number of cylinders for this disk is set to 121601.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with: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) Command (m for help): 3、fdisk帮助Command (m for help): mCommand 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) Command (m for help): 4、显示现有分区列表Command (m for help): p Disk /dev/sda: 1000.2 GB, 1000204886016 bytes255 heads, 63 sectors/track, 121601 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0x000de20f Device Boot Start End Blocks Id System/dev/sda1 * 1 9111 73184076 7 HPFS/NTFS/dev/sda2 9634 9730 779152+ 83 Linux/dev/sda3 9731 116679 859067842+ 5 Extended/dev/sda5 9731 20917 89859546 83 Linux/dev/sda6 20918 39644 150424596 83 Linux/dev/sda7 39645 53905 114551451 83 Linux Command (m for help): 5、创建一个分区Command (m for help): nCommand action l logical (5 or over) p primary partition (1-4)pSelected partition 4First cylinder (9112-121601, default 9112):Using default value 9112Last cylinder, +cylinders or +sizeK,M,G (9112-9633, default 9633): +521 Command (m for help): p Disk /dev/sda: 1000.2 GB, 1000204886016 bytes255 heads, 63 sectors/track, 121601 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0x000de20f Device Boot Start End Blocks Id System/dev/sda1 * 1 9111 73184076 7 HPFS/NTFS/dev/sda2 9634 9730 779152+ 83 Linux/dev/sda3 9731 116679 859067842+ 5 Extended/dev/sda4 9112 9633 4192965 83 Linux/dev/sda5 9731 20917 89859546 83 Linux/dev/sda6 20918 39644 150424596 83 Linux/dev/sda7 39645 53905 114551451 83 Linux Partition table entries are not in disk order Command (m for help):

SUSE Linux文件系统在线扩容

前几天SUSE 12文件系统/vg01/lvora,挂载点是/oracle,容量不够,需要进行扩容。

新的空间是从一台HP的存储上新映射的。由于映射的LUN是从windows主机上回收,然后直接映射的,所以在linux识别新LUN时发现上面存在windows分区信息,导致pvcreate失败。所以只好将每个新lun上的分区手动删除,再进行扩容。具体实施步骤如下:

  1. 新lun映射前需要先记录当前主机使用磁盘信息,多路径信息等。

    fdisk -l  查看现有磁盘信息

    multipath -ll   查看多路径信息

  2. 存储映射新磁盘到主机后,主机重新扫描,将新lun扫描出来

    rescan-scsi-bus.sh

  3. 确认新磁盘信息,并核参照前面日志核对出新磁盘的设备文件名,和聚合路径名

    fdisk -l    

    multipath -ll

  4. 删除新磁盘上的windows分区

    fdisk /dev/sdk  (/dev/sdk为新磁盘设备文件名)

    m(帮助信息)----p(打印出分区信息)----d(删除分区)----1(需要删除的分区编号)----w(保存操作)---q(退出)

  5. fdisk 确认操作后磁盘分区是否清除

  6. pvcreate  /dev/sdk   创建物理卷

  7. vgextend /dev/vg01  /dev/sdk   将物理卷加入卷组

  8. umount /oracle  卸载逻辑卷

  9. lvextend -L +1024GB //dev/vg01/lvora   将逻辑卷lvora扩大1T

  10. resize2fs /dev/vg01/lvora 扩大文件系统。本次操作由于数据量太大,且长时间为检查文件系统,所以我在扩文件系统时提示先运行 “e2fsck -f /dev/vg01/lvora”。

  11. 所以运行e2fsck -f -v -C0 /dev/vg01/lvora 。数据量太大,这次的检查足足进行了十几个小时才完成。前面75%跑得很慢,越到后面越快。 

    -f 表示强制检查

    -v 显示详细信息

    -C0 显示检查进度

  12. 扩文件系统 resize2fs /dev/vg01/lvora  这一步也需要一点时间,大概5分钟左右。

  13. mount /dev/vg0/lvora /oracle 挂在文件系统,df -H查看是否扩容成功。

本文出自 “不爱学习的懒人” 博客,谢绝转载!

以上是关于LUN挂载到Linux主机后,如何对磁盘进行分区的主要内容,如果未能解决你的问题,请参考以下文章

linux 磁盘挂载

linux磁盘分区和挂载

SUSE Linux文件系统在线扩容

三:磁盘与文件系统篇——磁盘分区格式化检验挂载

Linux下添加新硬盘,分区及挂载

Linux下调整磁盘大小后的基于LVM的磁盘扩容