Online disk addition and LVM volume expansion case

Source: Internet
Author: User

Online disk addition and LVM volume expansion case 1. Add a hard disk and scan it online. First, add a hard disk to the VM. Note that it must be a SCSI hard disk. Scan the hard disk without restarting the operating system. Echo "---">/sys/class/scsi_host/host0/scanecho "---">/sys/class/scsi_host/host1/scanecho "---">/ sys/class/scsi_host/host2/scanecho "---">/sys/class/scsi_host/host3/scan ....... echo "---">/sys/class/scsi_host/hostn/scan can scan several hosts! Remember to modify the host number. I have tested and found that, whether it is a virtual machine or a physical machine, some physical volumes are allocated to the host from the remote storage, the host can directly use this command to identify the newly added hard disk. Then run fdisk-l to find that the newly added hard disk has been recognized by the system. Check the system log/var/log/messages and check that the SCSI device has been scanned again. Note: there is an interval between the three hyphens. The following is the process after I add the hard disk: [root @ con4test ~] # Fdisk-l Disk/dev/sda: 107.3 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylindersUnits = cylinders of 16065*512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 13054 104751832 + 8e Linux LVM [root @ con4test ~] # Echo "---">/sys/class/scsi_host/host0/scan [root @ con4test ~] # [Root @ con4test ~] # Fdisk-l Disk/dev/sda: 107.3 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylindersUnits = cylinders of 16065*512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 13054 104751832 + 8e Linux LVM Disk /dev/sdb: 53.6 GB, 53687091200 bytes255 heads, 63 sectors/track, 6527 cylindersUnits = cylinders of 16065*512 = 8225280 bytes Disk/de V/sdb doesn' t contain a valid partition table 2. Add the hard disk to the original partition for RedHat usage. We often encounter the problem of hard disk space usage. Today, the server's hard disk space is used up to increase the hard disk space and add the existing space to the LVM. For details, see the internal document. 1. Collect related data and execute the following command: [root @ con4test ~] # Vgs/dev/hdc: open failed: No medium found VG # PV # LV # SN Attr VSize VFree VolGroup00 1 2 0wz -- n-99.88G 0 [root @ con4test ~] # Lvs-a-o + devices/dev/hdc: open failed: no medium found lv vg Attr LSize Origin Snap % Move Log Copy % Convert Devices LogVol00 VolGroup00-wi-ao 99.12G/dev/sda2 (0) logVol01 VolGroup00-wi-ao 768.00 M/dev/sda2 (3172) 2. run the following command to initialize the configuration of the newly added Hard Disk: [root @ con4test ~] # Fdisk-l Disk/dev/sda: 107.3 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylindersUnits = cylinders of 16065*512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 13054 104751832 + 8e Linux LVM Disk /dev/sdb: 53.6 GB, 53687091200 bytes255heads, 63 sectors/track, 6527 cylindersUnits = cylinders of 16065*512 = 8225280 bytes Disk/dev/sdb d Oesn' t contain a valid partition table fdisk/dev/sdb divides the hard disk into one partition. Result: [root @ con4test ~] # Fdisk-l Disk/dev/sda: 107.3 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylindersUnits = cylinders of 16065*512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 13054 104751832 + 8e Linux LVM Disk /dev/sdb: 53.6 GB, 53687091200 bytes255heads, 63 sectors/track, 6527 cylindersUnits = cylinders of 16065*512 = 8225280 bytes Device Boot S Tart End Blocks Id System/dev/sdb1 1 6527 52428096 83 run the following command in Linux: [root @ con4test ~] # Pvcreate/dev/sdb1 Physical volume "/dev/sdb1" successfully created 3. detailed explanation of LVM configuration commands pvcreate/dev/sdb1 # create sdb1 as pv, you can use pvdisplay to check the situation first. Then, create kernel vmax_bkupvg # VG and rename lvcreate-L 2.43 T-I 5-I1024-n vmax_bkuplv vmax_bkupvg # LV, -L specify the lv size,-I specify the number of strip,-I specify the Strip size, -n: Specify the lv name mkfs-t ext3/dev/vmax_bkupvg/vmax_bkuplv vgextend VolGroup00/dev/sdb1 # Add sdb1 Go to VolGroup00 lvextend-l + 100% FREE/dev/VolGroup00/LogVol00 # expand all FREE space resize2fs-f/dev/VolGroup00/LogVol00 4. run the following command to verify the configuration: [root @ con4test ~] # Vgs VG # PV # LV # SN Attr VSize VFree VolGroup00 2 2 0 wz -- n-149.84G 0 [root @ con4test ~] # Lvs-a-o + devices lv vg Attr LSize Origin Snap % Move Log Copy % Convert Devices LogVol00 VolGroup00-wi-ao 149.09G/dev/sda2 (0) logVol00 VolGroup00-wi-ao 149.09G/dev/sdb1 (0) LogVol01 VolGroup00-wi-ao 768.00 M/dev/sda2 (3172) [root @ con4test ~] # Df-ThFilesystem Type Size Used Avail Use % Mounted on/dev/mapper/VolGroup00-LogVol00 ext3 145G 97G 41G 71%/dev/sda1 ext3 99 M 13 M 82 M 14%/ boottmpfs tmpfs 3.9G 0 3.9G 0%/dev/shm this article is from the Linux community website (www.linuxidc.com) common http://www.linuxidc.com/Linux/2010-04/25799.htm errors: [root @ con4test ~] # Vgextend volgroup00/dev/sdb1/dev/hdc: open failed: No medium found Volume group "volgroup00" not found [root @ con4test ~] # Vgextend VolGroup00/dev/sdb1 Nophysical volume label read from/dev/sdb1/dev/sdb1not identified as an existing physical volume Unable to add physical volume '/dev/sdb1' to volume 'volgroup00 '. create pv [root @ con4test ~] First # Pvcreate/dev/sdb1 Physical volume "/dev/sdb1" successfully created III. case Study (detailed process of volume division LVM on EMC storage) pvcreate/dev/emcpowerk Physical volume "/dev/emcpowerk" successfully createdbi-bkdb: /# pvcreate/dev/emcpowerl Physical volume "/dev/emcpowerl" successfully createdbi-bkdb:/# bi-bkdb: /# pvcreate/dev/emcpowerm Physical volume "/dev/emcpowerm" successfully createdbi-bkdb:/# pvcreate/dev/emcpow Ern Physical volume "/dev/emcpowern" successfully createdbi-bkdb:/# pvcreate/dev/emcpowero Physical volume "/dev/emcpowero" successfully createdbi-bkdb:/# bi-bkdb: /# bi-bkdb: /# pvscan PV/dev/emcpowerb VG 1_levg lvm2 [500.00 GiB/0 free] PV/dev/emcpowera VG 1_levg lvm2 [500.00 GiB/0 free] PV/dev/emcpowerc VG 1_levg lvm2 [500.00 GiB/0 free] PV/dev/emcpowerf VG 1_levg lvm2 [500.00 GiB /0 free] PV/dev/emcpowere VG 1_levg lvm2 [500.00 GiB/0 free] PV/dev/emcpowerd VG 1_levg lvm2 [500.00 GiB/0 free] PV/dev/emcpowerg VG oraclevg lvm2 [500.00 GiB/0 free] PV/dev/emcpowerj VG 1_levg lvm2 [500.00 GiB/0 free] PV/dev/emcpowerh VG 1_levg lvm2 [500.00 GiB/0 free] PV /dev/emcpoweri VG unzip levg lvm2 [500.00 GiB/0 free] PV/dev/emcpowerk lvm2 [500.00 GiB] PV/dev/emcpowerl Vm2 [500.00 GiB] PV/dev/emcpowerm lvm2 [500.00 GiB] PV/dev/emcpowern lvm2 [500.00 GiB] PV/dev/emcpowero lvm2 [500.00 GiB] Total: 15 [7.32 TiB]/in use: 10 [4.88 TiB]/in no VG: 5 [2.44 TiB] bi-bkdb: /# vgcreate vmax_bkup/dev/emcpowerk/dev/emcpowerl/dev/emcpowerm/dev/emcpowern/dev/emcpowero Volume group "vmax_bkup" successfully createdbi-bkdb:/# bi-bkdb: /# bi-bkdb:/# vgscan Reading all physical vo Lumes. this may take a while... found volume group "vmax_bkup" using metadata type lvm2 Found volume group "oraclevg" using metadata type lvm2 bi-bkdb: /# vgrename vmax_bkup vmax_bkupvg Volume group "vmax_bkup" successfully renamed to "vmax_bkupvg" bi-bkdb: /# vgs VG # PV # LV # SN Attr VSize VFree 1_levg 10 2 0wz -- n-4.88 t 0 vmax_bkupvg 5 0 0wz -- n-2.44 t 2.44traumatic brain-bkdb: /# lvcreate-L 2.43 T-I 5-I 1 024-n specify parameter Rounding up size to full physical extent 2.43 TiB Logical volume "vmax_bkuplv" created bi-bkdb:/# mkfs-t ext3-c/dev/vmax_bkupvg/limit 4. case Study (LVM online expansion of redhat AS5) redhat AS5 LVM add disk space instance [root @ virus_update/] # df-hFilesystem Size Used Avail Use % Mounted on/dev/mapper/VolGroup00-LogVol002.9G 2.4G 396 M 86%/dev/sda1 99 M 11 M 83 M 12%/boottmpfs 1014 M 0 1014 M 0%/de V/shm [root @ virus_update/] # fdisk-lDisk/dev/sda: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065*512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 652 5132767 + 8e Linux LVMDisk/dev /sdb: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 cylindersUnits = cylinders of 16065*512 = 8225280 BytesDisk/dev/sdb doesn't contain a valid partition table [root @ virus_update/] # fdisk/dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSFdisklabelBuilding a new DOS disklabel. changes will remain in memory only, until you decide to write them. after that, of course, the previuscontent won't be recoverable. the number of cylinders for this disk is set to 5221. there is Nothing wrong with that, but this is larger than 1024, and cocould 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 ): nCommand actione extendedp primary partition (1-4) PHA Tition number (1-4): 1 First cylinder (1-5221, default 1): Using default value 1 Last cylinder or + size or + sizeM or + sizeK (1-5221, default 5221): Using default value 5221 Command (m for help): wThe partition table has been altered! Calling ioctl () to re-read partition table. syncing disks. [root @ virus_update/] # fdisk-lDisk/dev/sda: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065*512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 652 5132767 + 8e Linux LVMDisk/dev /sdb: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 CylindersUnits = cylinders of 16065*512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/sdb1 1 5221 41937651 83 Linux [root @ virus_update/] # pvcreate/dev/sdb1Physical volume "/ dev/sdb1 "successfully created [root @ virus_update/] # pvdisplay/dev/sdb1 --- NEW Physical volume --- PV Name/dev/sdb1VG Name PV Size 39.99 GBAllocatable NOPE Size (KByte) 0 Total PE 0 Free PE 0 Allocated PE 0PV UUID KW7PHZ-CtMC-0SzR-PNvV-OrZW-2s2d-LFfJ6I [root @ virus_update/] # vgdisplay --- Volume group --- VG Name VolGroup00System ID Format lvm2Metadata Areas 1 Metadata Sequence No 3VG Access read/writeVG Status resizableMAX LV 0Cur LV 2 Open LV 2Max PV 0Cur PV 1Act PV 1VG Size 4.88 GBPE Size 32.00 MBTotal PE 156 Alloc PE/Size 156/4 .88 GBFree PE/Size 0/0 vg uuid 4Iob4o-byje-ckbV-7dGt-49zm-J27Q-w0NtrU [roo T @ virus_update/] # vgextend VolGroup00/dev/sdb1Volume group "VolGroup00" successfully extended [root @ virus_update/] # lvextend-L + 40G/dev/VolGroup00/[root @ virus_update /] # lvscanACTIVE '/dev/VolGroup00/LogVol00' [2.94 GB] inheritACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit [root @ virus_update/] # df-hFilesystem size Used Avail Use % Mounted on/dev/mapper/VolGroup00-LogVol002.9G 2.4G 396 M 86% // Dev/sda1 99 M 11 M 83 M 12%/boottmpfs 1014 M 0 1014 M 0%/dev/shm [root @ virus_update ~] # Resize2fs/dev/VolGroup00/LogVol00resize2fs 1.39 (29-May-2006) Filesystem at/dev/VolGroup00/LogVol00 is mounted on /; on-line resizingrequired‑ming an on-line resize of/dev/VolGroup00/LogVol00 to 10993664 (4 k) blocks. the filesystem on/dev/VolGroup00/LogVol00 is now 10993664 blocks long. [root @ virus_update ~] # Df-hFilesystem Size Used Avail Use % Mounted on/dev/mapper/VolGroup00-LogVol0041G 2.4G 37G 6% // dev/sda1 99 M 11 M 83 M 12%/boottmpfs 1014 M 0 1014 M 0%/dev/shm [root @ virus_update ~] #

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.