Linux parted(>2TB) tools with LVM service

      This afternoon when i was deploying Coremail cluster service,My customer needed more than 2TB storage for the mail server!unfortunately,they've got only 700GB,and they may expand their storage,of course the Coremail server.In order to expand the lun online,i have to configure it with LVM,also,in considering of the capacity they need,I have to deploy it with GPT instead of MBR format! This is the subject.

I will demonstrate with VMware.

I've already got a lun for 100MB,now i will add a new lun online:

  1. [root@rhel6 /]# lsscsi  
  2. [0:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda  
  3. [2:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0  
  4. [3:0:0:3]    disk    OPNFILER VIRTUAL-DISK     0     /dev/sde  
  5. [root@rhel6 /]# echo "scsi add-single-device 3 0 0 4" > /proc/scsi/scsi  
  6. [root@rhel6 /]# lsscsi  
  7. [0:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda  
  8. [2:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0  
  9. [3:0:0:3]    disk    OPNFILER VIRTUAL-DISK     0     /dev/sde  
  10. [3:0:0:4]    disk    OPNFILER VIRTUAL-DISK     0     /dev/sdb  
  11. [root@rhel6 /]# fdisk -l
  12. (truncated)
  13. Disk /dev/mapper/testp1: 96 MB, 96468992 bytes  
  14. 255 heads, 63 sectors/track, 11 cylinders  
  15. Units = cylinders of 16065 * 512 = 8225280 bytes  
  16. Sector size (logical/physical): 512 bytes / 512 bytes  
  17. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  18. Disk identifier: 0x00000000  
  19.  
  20. Disk /dev/mapper/testp1 doesn't contain a valid partition table  
  21.  
  22. Disk /dev/sdb: 301 MB, 301989888 bytes
    10 heads, 58 sectors/track, 1016 cylinders
    Units = cylinders of 580 * 512 = 296960 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
  23.    Device Boot      Start         End      Blocks   Id  System
  24.  
  25.  
  26. Disk /dev/mapper/mpatha: 301 MB, 301989888 bytes  
  27. 10 heads, 58 sectors/track, 1016 cylinders  
  28. Units = cylinders of 580 * 512 = 296960 bytes  
  29. Sector size (logical/physical): 512 bytes / 512 bytes  
  30. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  31. Disk identifier: 0x00000000  
  32.  
  33.              Device Boot      Start         End      Blocks   Id  System  
  34. /dev/mapper/mpathap1               1        1016      294611   83  Linux  
  35.  
  36. Disk /dev/mapper/mpathap1: 301 MB, 301681664 bytes  
  37. 255 heads, 63 sectors/track, 36 cylinders  
  38. Units = cylinders of 16065 * 512 = 8225280 bytes  
  39. Sector size (logical/physical): 512 bytes / 512 bytes  
  40. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  41. Disk identifier: 0x00000000  
  42.  
  43. Disk /dev/mapper/mpathap1 doesn't contain a valid partition table  

as the above shows,the green and bold words mean that i have configured multipath service!

  1. [root@rhel6 /]# multipath -ll  
  2. mpatha (14f504e46494c45006c4a687777612d327777672d69625766) dm-4 OPNFILER,VIRTUAL-DISK  
  3. size=288M features='0' hwhandler='0' wp=rw 
  4. `-+- policy='round-robin 0' prio=1 status=active 
  5.   `- 3:0:0:4 sdb 8:16 active ready running  
  6. test (14f504e46494c4500346c765730712d4a6864792d634d6c64) dm-2 OPNFILER,VIRTUAL-DISK  
  7. size=96M features='1 queue_if_no_path' hwhandler='0' wp=rw 
  8. `-+- policy='round-robin 0' prio=1 status=active 
  9.   `- 3:0:0:3 sde 8:64 active ready running  
  10. [root@rhel6 /]#  

Ok.next we have to parted this lun,cause i used to configured it in MBR format with fdisk tool,so it may look strange for the steps,but for a totally new lun,you can ignore this .

  1. [root@rhel6 /]# parted /dev/sdb  
  2. GNU Parted 2.1  
  3. Using /dev/sdb  
  4. Welcome to GNU Parted! Type 'help' to view a list of commands.  
  5. (parted) help  
  6.   align-check TYPE N                        check partition N for TYPE(min|opt)  
  7.         alignment  
  8.   check NUMBER                             do a simple check on the file system  
  9.   cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition  
  10.   help [COMMAND]                           print general help, or help on  
  11.         COMMAND  
  12.   mklabel,mktable LABEL-TYPE               create a new disklabel (partition  
  13.         table)  
  14.   mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on  
  15.         partition NUMBER  
  16.   mkpart PART-TYPE [FS-TYPE] START END     make a partition  
  17.   mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system  
  18.   move NUMBER START END                    move partition NUMBER  
  19.   name NUMBER NAME                         name partition NUMBER as NAME  
  20.   print [devices|free|list,all|NUMBER]     display the partition table,  
  21.         available devices, free space, all found partitions, or a particular  
  22.         partition  
  23.   quit                                     exit program  
  24.   rescue START END                         rescue a lost partition near START  
  25.         and END  
  26.   resize NUMBER START END                  resize partition NUMBER and its file  
  27.         system  
  28.   rm NUMBER                                delete partition NUMBER  
  29.   select DEVICE                            choose the device to edit  
  30.   set NUMBER FLAG STATE                    change the FLAG on partition NUMBER  
  31.   toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition  
  32.         NUMBER  
  33.   unit UNIT                                set the default unit to UNIT  
  34.   version                                  display the version number and  
  35.         copyright information of GNU Parted  
  36. (parted) mklabel  
  37. New disk label type? new  
  38. parted: invalid token: new  
  39. New disk label type? gpt  
  40. Warning: The existing disk label on /dev/sdb will be destroyed and all data on  
  41. this disk will be lost. Do you want to continue?  
  42. Yes/No? yes  
  43. (parted) print  
  44. Model: OPNFILER VIRTUAL-DISK (scsi)  
  45. Disk /dev/sdb: 302MB  
  46. Sector size (logical/physical): 512B/512B  
  47. Partition Table: gpt  
  48.  
  49. Number  Start  End  Size  File system  Name  Flags  
  50.  
  51. (parted) mkpart  
  52. Partition name?  []? new  
  53. File system type?  [ext2]? ext3  
  54. Start? 1  
  55. End? 302MB  
  56. Warning: The resulting partition is not properly aligned for best performance.  
  57. Ignore/Cancel? ignore  
  58. (parted) print  
  59. Model: OPNFILER VIRTUAL-DISK (scsi)  
  60. Disk /dev/sdb: 302MB  
  61. Sector size (logical/physical): 512B/512B  
  62. Partition Table: gpt  
  63.  
  64. Number  Start   End    Size   File system  Name  Flags  
  65.  1      17.4kB  302MB  302MB               new  
  66.  
  67. (parted) toggle 1 lvm  
  68. (parted) print  
  69. Model: OPNFILER VIRTUAL-DISK (scsi)  
  70. Disk /dev/sdb: 302MB  
  71. Sector size (logical/physical): 512B/512B  
  72. Partition Table: gpt  
  73.  
  74. Number  Start   End    Size   File system  Name  Flags  
  75.  1      17.4kB  302MB  302MB               new   lvm  
  76.  
  77. (parted) quit  
  78. Information: You may need to update /etc/fstab.  
  79.  
  80. [root@rhel6 /]#  

notice this one “(parted) toggle 1 lvm”,of course,we can use help:

  1. [root@rhel6 /]# parted /dev/sdb  
  2. GNU Parted 2.1  
  3. Using /dev/sdb  
  4. Welcome to GNU Parted! Type 'help' to view a list of commands.  
  5. (parted) help toggle  
  6.   toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition  
  7.         NUMBER  
  8.  
  9.         NUMBER is the partition number used by Linux.  On MS-DOS disk labels,  
  10.         the primary partitions number from 1 to 4, logical partitions from 5  
  11.         onwards.  
  12.         FLAG is one of: boot, root, swap, hidden, raid, lvm, lba, hp-service,  
  13.         palo, prep, msftres, bios_grub, atvrecv, diag  
  14. (parted)  

Ok,after this,if you use fdisk to check out the lun ,it appears like this:

  1. WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.  
  2.  
  3.  
  4. Disk /dev/sdb: 301 MB, 301989888 bytes  
  5. 255 heads, 63 sectors/track, 36 cylinders  
  6. Units = cylinders of 16065 * 512 = 8225280 bytes  
  7. Sector size (logical/physical): 512 bytes / 512 bytes  
  8. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  9. Disk identifier: 0x00000000  
  10.  
  11.    Device Boot      Start         End      Blocks   Id  System  
  12. /dev/sdb1               1          37      294911+  ee  GPT  
  13. Partition 1 has different physical/logical beginnings (non-Linux?):  
  14.      phys=(0, 0, 1) logical=(0, 0, 2)  
  15. Partition 1 has different physical/logical endings:  
  16.      phys=(1023, 254, 63) logical=(36, 182, 18)  
  17.  
  18. Disk /dev/mapper/mpatha: 301 MB, 301989888 bytes  
  19. 255 heads, 63 sectors/track, 36 cylinders  
  20. Units = cylinders of 16065 * 512 = 8225280 bytes  
  21. Sector size (logical/physical): 512 bytes / 512 bytes  
  22. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  23. Disk identifier: 0x00000000  
  24.  
  25.              Device Boot      Start         End      Blocks   Id  System  
  26.  
  27. Disk /dev/mapper/mpathap1: 301 MB, 301681664 bytes  
  28. 255 heads, 63 sectors/track, 36 cylinders  
  29. Units = cylinders of 16065 * 512 = 8225280 bytes  
  30. Sector size (logical/physical): 512 bytes / 512 bytes  
  31. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  32. Disk identifier: 0x00000000  
  33.  
  34. Disk /dev/mapper/mpathap1 doesn't contain a valid partition table  

well,create LVM.

  1. [root@rhel6 /]# pvscan  
  2.   PV /dev/sda2   VG vg_rhel6   lvm2 [19.80 GiB / 0    free]  
  3.   Total: 1 [19.80 GiB] / in use: 1 [19.80 GiB] / in no VG: 0 [0   ]  
  4. [root@rhel6 /]# pvcreate /dev/mapper/  
  5. control            mpathap1           testp1             vg_rhel6-LogVol01  
  6. mpatha             test               vg_rhel6-LogVol00  
  7. [root@rhel6 /]# pvcreate /dev/mapper/mpathap1  
  8.   Physical volume "/dev/mapper/mpathap1" successfully created  
  9. [root@rhel6 /]# pvscan  
  10.   PV /dev/sda2              VG vg_rhel6        lvm2 [19.80 GiB / 0    free]  
  11.   PV /dev/mapper/mpathap1                      lvm2 [287.71 MiB]  
  12.   Total: 2 [20.08 GiB] / in use: 1 [19.80 GiB] / in no VG: 1 [287.71 MiB]  
  13. [root@rhel6 /]# vgcreate mpathvg /dev/mapper/mpathap1  
  14.   Volume group "mpathvg" successfully created  
  15. [root@rhel6 /]# vgscan  
  16.   Reading all physical volumes.  This may take a while...  
  17.   Found volume group "mpathvg" using metadata type lvm2  
  18.   Found volume group "vg_rhel6" using metadata type lvm2  
  19. [root@rhel6 /]# vgdisplay mpathvg  
  20.   --- Volume group ---  
  21.   VG Name               mpathvg  
  22.   System ID  
  23.   Format                lvm2  
  24.   Metadata Areas        1  
  25.   Metadata Sequence No  1  
  26.   VG Access             read/write  
  27.   VG Status             resizable  
  28.   MAX LV                0  
  29.   Cur LV                0  
  30.   Open LV               0  
  31.   Max PV                0  
  32.   Cur PV                1  
  33.   Act PV                1  
  34.   VG Size               284.00 MiB  
  35.   PE Size               4.00 MiB  
  36.   Total PE              71  
  37.   Alloc PE / Size       0 / 0  
  38.   Free  PE / Size       71 / 284.00 MiB  
  39.   VG UUID               p2g0qA-wqrn-Uy0z-sp9U-dghf-UrGO-jpeIkj  
  40.  
  41. [root@rhel6 /]# lvcreate -l 71 mpathvg -n mpathlv  
  42.   Logical volume "mpathlv" created  
  43. [root@rhel6 /]# lvscan  
  44.   ACTIVE            '/dev/mpathvg/mpathlv' [284.00 MiB] inherit  
  45.   ACTIVE            '/dev/vg_rhel6/LogVol01' [1.95 GiB] inherit  
  46.   ACTIVE            '/dev/vg_rhel6/LogVol00' [17.85 GiB] inherit  

display the logical volume with lvdisplay:

  1. [root@rhel6 /]# lvdisplay  
  2.   --- Logical volume ---  
  3.   LV Name                /dev/mpathvg/mpathlv  
  4.   VG Name                mpathvg  
  5.   LV UUID                M7A8dK-sJ8M-EEMP-rUFZ-45uw-Gm7q-BTtNaK  
  6.   LV Write Access        read/write  
  7.   LV Status              available  
  8.   # open                 0  
  9.   LV Size                284.00 MiB  
  10.   Current LE             71  
  11.   Segments               1  
  12.   Allocation             inherit  
  13.   Read ahead sectors     auto  
  14.   - currently set to     256  
  15.   Block device           253:6  

Ok,now,make filesystem:

  1. [root@rhel6 /]# mkfs.ext3 /dev/mpathvg/mpathlv  
  2. mke2fs 1.41.12 (17-May-2010)  
  3. Filesystem label=  
  4. OS type: Linux  
  5. Block size=1024 (log=0)  
  6. Fragment size=1024 (log=0)  
  7. Stride=0 blocks, Stripe width=0 blocks  
  8. 72864 inodes, 290816 blocks  
  9. 14540 blocks (5.00%) reserved for the super user  
  10. First data block=1 
  11. Maximum filesystem blocks=67633152 
  12. 36 block groups  
  13. 8192 blocks per group, 8192 fragments per group  
  14. 2024 inodes per group  
  15. Superblock backups stored on blocks:  
  16.         8193, 24577, 40961, 57345, 73729, 204801, 221185  
  17.  
  18. Writing inode tables: done  
  19. Creating journal (8192 blocks): done  
  20. Writing superblocks and filesystem accounting information: done  
  21.  
  22. This filesystem will be automatically checked every 39 mounts or  
  23. 180 days, whichever comes first.  Use tune2fs -c or -i to override.  
  24. [root@rhel6 /]# mkdir /mpath  
  25. [root@rhel6 /]# mount /dev/mpathvg/mpathlv /mpath/  
  26. [root@rhel6 /]# df -h  
  27. Filesystem            Size  Used Avail Use% Mounted on  
  28. /dev/mapper/vg_rhel6-LogVol00  
  29.                        18G  2.3G   15G  14% /  
  30. tmpfs                 260M     0  260M   0% /dev/shm  
  31. /dev/sda1             194M   25M  160M  14% /boot  
  32. /dev/mapper/testp1     90M  5.6M   79M   7% /data  
  33. /dev/mapper/mpathvg-mpathlv  
  34.                       276M   11M  251M   4% /mpath  
  35. [root@rhel6 /]#  

When i was deploying the system,i feel confused about GPT with LVM,So i write down this for my further reference!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章