zoukankan      html  css  js  c++  java
  • 虚拟机添加磁盘LVM分区

    参考博客:http://kimjinlsgd.blog.51cto.com/1918030/932210

    一、查看磁盘情况

    新添加一块磁盘。

    [root@VMhost /]# fdisk -l

    Disk /dev/sda: 12.8 GB, 12884901888 bytes
    255 heads, 63 sectors/track, 1566 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 13 104391 83 Linux
    /dev/sda2 14 1566 12474472+ 8e Linux LVM

    Disk /dev/sdb: 11.2 GB, 11280916480 bytes
    255 heads, 63 sectors/track, 1371 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

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

    二、格式化磁盘

    [root@VMhost /]# fdisk /dev/sdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel. Changes will remain in memory only,
    until you decide to write them. After that, of course, the previous
    content won't be recoverable.


    The number of cylinders for this disk is set to 1371.
    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)
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

    Command (m for help): n --添加新分区
    Command action
    e extended
    p primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-1371, default 1):
    Using default value 1
    Last cylinder or +size or +sizeM or +sizeK (1-1371, default 1371):
    Using default value 1371

    Command (m for help): t --指定分区的格式
    Selected partition 1
    Hex code (type L to list codes): 8e
    Changed system type of partition 1 to 8e (Linux LVM)

    Command (m for help): p

    Disk /dev/sdb: 11.2 GB, 11280916480 bytes
    255 heads, 63 sectors/track, 1371 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 1371 11012526 8e Linux LVM

    Command (m for help): w
    The partition table has been altered!

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

    三、分区挂载

    [root@VMhost ~]# lvm

    lvm> pvcreate /dev/sdb1
    Writing physical volume data to disk "/dev/sdb1"
    Physical volume "/dev/sdb1" successfully created
    lvm> vgextend VolGroup00 /dev/sdb1
    Volume group "VolGroup00" successfully extended

    lvm> pvdisplay
    --- Physical volume ---
    PV Name /dev/sda2
    VG Name VolGroup00
    PV Size 11.90 GB / not usable 22.10 MB
    Allocatable yes (but full)
    PE Size (KByte) 32768
    Total PE 380
    Free PE 0
    Allocated PE 380
    PV UUID nwXal0-oUy4-m73q-mvTE-XJ0F-9LI5-BVm2W8

    --- Physical volume ---
    PV Name /dev/sdb1
    VG Name VolGroup00
    PV Size 10.50 GB / not usable 2.42 MB
    Allocatable yes
    PE Size (KByte) 32768
    Total PE 336
    Free PE 336
    Allocated PE 0
    PV UUID THT3Vd-Odrb-5J3r-C4Mx-TS3K-EAhe-oRl1rA

    [root@VMhost ~]# lvm
    lvm> lvdisplay
    --- Logical volume ---
    LV Name /dev/VolGroup00/LogVol00
    VG Name VolGroup00
    LV UUID baqpCg-u9O6-KWeW-mOPC-4lME-MLpn-1DUt5D
    LV Write Access read/write
    LV Status available
    # open 1
    LV Size 7.94 GB
    Current LE 254
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    - currently set to 256
    Block device 253:0

    --- Logical volume ---
    LV Name /dev/VolGroup00/LogVol01
    VG Name VolGroup00
    LV UUID JbJcil-wefD-W1xQ-iBXd-FUUc-sL0l-ZGpdKl
    LV Write Access read/write
    LV Status available
    # open 1
    LV Size 3.94 GB
    Current LE 126
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    - currently set to 256
    Block device 253:1

    lvm> lvextend -L +10G /dev/VolGroup00/LogVol00
    Extending logical volume LogVol00 to 17.94 GB
    Logical volume LogVol00 successfully resized
    lvm> exit
    Exiting.
    [root@VMhost ~]# resize2fs /dev/VolGroup00/LogVol00
    resize2fs 1.39 (29-May-2006)
    Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
    Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4702208 (4k) blocks.
    The filesystem on /dev/VolGroup00/LogVol00 is now 4702208 blocks long.

    [root@VMhost ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/VolGroup00-LogVol00
    18G 3.5G 14G 21% /
    /dev/sda1 99M 22M 72M 24% /boot
    tmpfs 1007M 0 1007M 0% /dev/shm
    [root@VMhost ~]# fdisk -l

    Disk /dev/sda: 12.8 GB, 12884901888 bytes
    255 heads, 63 sectors/track, 1566 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 13 104391 83 Linux
    /dev/sda2 14 1566 12474472+ 8e Linux LVM

    Disk /dev/sdb: 11.2 GB, 11280916480 bytes
    255 heads, 63 sectors/track, 1371 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 1371 11012526 8e Linux LVM

    Disk /dev/dm-0: 19.2 GB, 19260243968 bytes
    255 heads, 63 sectors/track, 2341 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Disk /dev/dm-0 doesn't contain a valid partition table

    Disk /dev/dm-1: 4227 MB, 4227858432 bytes
    255 heads, 63 sectors/track, 514 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Disk /dev/dm-1 doesn't contain a valid partition table
    [root@VMhost ~]# lvm
    lvm> lvdisplay
    --- Logical volume ---
    LV Name /dev/VolGroup00/LogVol00
    VG Name VolGroup00
    LV UUID baqpCg-u9O6-KWeW-mOPC-4lME-MLpn-1DUt5D
    LV Write Access read/write
    LV Status available
    # open 1
    LV Size 17.94 GB
    Current LE 574
    Segments 2
    Allocation inherit
    Read ahead sectors auto
    - currently set to 256
    Block device 253:0

    --- Logical volume ---
    LV Name /dev/VolGroup00/LogVol01
    VG Name VolGroup00
    LV UUID JbJcil-wefD-W1xQ-iBXd-FUUc-sL0l-ZGpdKl
    LV Write Access read/write
    LV Status available
    # open 1
    LV Size 3.94 GB
    Current LE 126
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    - currently set to 256
    Block device 253:1

    OK 挂载成功。

    实验环境:VirtualBox-4.2.16-86992-Win 

    [root@VMhost ~]# uname -a
    Linux VMhost.localdomain 2.6.32-300.10.1.el5uek #1 SMP Wed Feb 22 17:22:40 EST 2012 i686 i686 i386 GNU/Linux

    ORACLE linux 5.8

  • 相关阅读:
    error LNK2019: 无法解析的外部符号 该符号在函数 中被引用 解决方案
    【OSG】运行OSG示例出现的奶牛不完整问题
    python 遍历文件夹
    python os操作
    python io操作
    python request 代理/超时/证书
    python tuple
    python dict
    python request post
    python request get
  • 原文地址:https://www.cnblogs.com/Alex-Zeng/p/3208812.html
Copyright © 2011-2022 走看看