Linux virtual Machine added a new block of 100G hard disk, the space allocated to/OPT

Source: Internet
Author: User

Background add a 150G disk to the Linux virtual machine and add the space to the/OPT directory. Add disk procedure skip the talk.
1. Execute "fdsik-l" to verify that the add is successful. Use FDISK to partition the newly added hard drive. Such as:

2. After creating the partition, execute the command partprone sync
[Email protected] ~]# Partprobe
3. Execute the command PVCREATE/DEV/SDB1 create the physical volume on the partition/DEV/SDB1.
[Email protected] ~]# PVCREATE/DEV/SDB1
Physical volume "/DEV/SDB1" successfully created

  1. Execute the command PVs to view the current physical volume, and of course it can be viewed with the Pvdisplay command.
    [Email protected] ~]# PVs
    /dev/hdc:open FAILED:PV VG Fmt Attr PSize pfree
    /dev/sda2 vg00 lvm2 a-99.88g 0--------------
    /DEV/SDB1 lvm2 a-150.00g 150.00G
  2. Execute command LVS View the volume group name of the home/home directory where the logical volume belongs
    [[email protected] ~]# LVS
    LV VG Attr lsize Origin snap% Move Log copy% Convert
    LV01 Vg00-wi-ao 4.00G
    Lv02 Vg00-wi-ao 7.81G
    lv03 Vg00-wi-ao 2.00G
    LV04 Vg00-wi-ao 10.00G
    lv05 Vg00-wi-ao 4.00G
    lv07 Vg00-wi-ao 72.06G------------can see that all the partitions are under the VG00 volume group
  3. Execute command vgextend vg00/dev/sdb1 to add the newly created physical volume/DEV/SDB1 to the volume group
    [[email protected] ~]# vgextend vg00/dev/sdb1
    Volume Group "vg00" successfully extended
  4. Execute command lvextend increase the logical volume/OPT by 100G
    [Email protected] ~]# lvextend-l +100g/dev/mapper/vg00-lv07
    Extending logical Volume LV07 to 172.06 GB
    Logical Volume lv07 successfully resized
    8. Execute Command resize2fs Sync
    [Email protected] ~]# resize2fs/dev/mapper/vg00-lv07
    RESIZE2FS 1.39 (29-may-2006)
    Filesystem at/dev/mapper/vg00-lv07 is mounted on/opt; On-line resizing required
    Performing an on-line resize of/dev/mapper/vg00-lv07 to 45105152 (4k) blocks.
    The filesystem on/dev/mapper/vg00-lv07 is now 45105152 blocks long.
    9.df-h to see if the/OPT directory space is increasing
    [Email protected] ~]# df-h
    ?? %/DEV/MAPPER/VG00-LV01
    3.9G 1.7G 2.1G 44%/
    /dev/mapper/vg00-lv03
    2.0G 246M 1.6G 14%/Home
    /dev/mapper/vg00-lv04
    9.7G 5.8G 3.5G 63%/usr
    /dev/mapper/vg00-lv07
    167G 46G 113G 29%/opt
    /dev/mapper/vg00-lv05
    3.9G 2.9G 872M 77%/var
    /DEV/SDA1 99M 13M 81M 14%/boot
    Tmpfs 7.9G 0 7.9G 0%/dev/shm

Linux virtual Machine added a new block of 100G hard disk, the space allocated to/OPT

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.