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:
- [root@rhel6 /]# lsscsi
- [0:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda
- [2:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0
- [3:0:0:3] disk OPNFILER VIRTUAL-DISK 0 /dev/sde
- [root@rhel6 /]# echo "scsi add-single-device 3 0 0 4" > /proc/scsi/scsi
- [root@rhel6 /]# lsscsi
- [0:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda
- [2:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0
- [3:0:0:3] disk OPNFILER VIRTUAL-DISK 0 /dev/sde
- [3:0:0:4] disk OPNFILER VIRTUAL-DISK 0 /dev/sdb
- [root@rhel6 /]# fdisk -l
- (truncated)
- Disk /dev/mapper/testp1: 96 MB, 96468992 bytes
- 255 heads, 63 sectors/track, 11 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk identifier: 0x00000000
- Disk /dev/mapper/testp1 doesn't contain a valid partition table
- 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- Device Boot Start End Blocks Id System
- Disk /dev/mapper/mpatha: 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
- Device Boot Start End Blocks Id System
- /dev/mapper/mpathap1 1 1016 294611 83 Linux
- Disk /dev/mapper/mpathap1: 301 MB, 301681664 bytes
- 255 heads, 63 sectors/track, 36 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk identifier: 0x00000000
- 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!
- [root@rhel6 /]# multipath -ll
- mpatha (14f504e46494c45006c4a687777612d327777672d69625766) dm-4 OPNFILER,VIRTUAL-DISK
- size=288M features='0' hwhandler='0' wp=rw
- `-+- policy='round-robin 0' prio=1 status=active
- `- 3:0:0:4 sdb 8:16 active ready running
- test (14f504e46494c4500346c765730712d4a6864792d634d6c64) dm-2 OPNFILER,VIRTUAL-DISK
- size=96M features='1 queue_if_no_path' hwhandler='0' wp=rw
- `-+- policy='round-robin 0' prio=1 status=active
- `- 3:0:0:3 sde 8:64 active ready running
- [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 .
- [root@rhel6 /]# parted /dev/sdb
- GNU Parted 2.1
- Using /dev/sdb
- Welcome to GNU Parted! Type 'help' to view a list of commands.
- (parted) help
- align-check TYPE N check partition N for TYPE(min|opt)
- alignment
- check NUMBER do a simple check on the file system
- cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another partition
- help [COMMAND] print general help, or help on
- COMMAND
- mklabel,mktable LABEL-TYPE create a new disklabel (partition
- table)
- mkfs NUMBER FS-TYPE make a FS-TYPE file system on
- partition NUMBER
- mkpart PART-TYPE [FS-TYPE] START END make a partition
- mkpartfs PART-TYPE FS-TYPE START END make a partition with a file system
- move NUMBER START END move partition NUMBER
- name NUMBER NAME name partition NUMBER as NAME
- print [devices|free|list,all|NUMBER] display the partition table,
- available devices, free space, all found partitions, or a particular
- partition
- quit exit program
- rescue START END rescue a lost partition near START
- and END
- resize NUMBER START END resize partition NUMBER and its file
- system
- rm NUMBER delete partition NUMBER
- select DEVICE choose the device to edit
- set NUMBER FLAG STATE change the FLAG on partition NUMBER
- toggle [NUMBER [FLAG]] toggle the state of FLAG on partition
- NUMBER
- unit UNIT set the default unit to UNIT
- version display the version number and
- copyright information of GNU Parted
- (parted) mklabel
- New disk label type? new
- parted: invalid token: new
- New disk label type? gpt
- Warning: The existing disk label on /dev/sdb will be destroyed and all data on
- this disk will be lost. Do you want to continue?
- Yes/No? yes
- (parted) print
- Model: OPNFILER VIRTUAL-DISK (scsi)
- Disk /dev/sdb: 302MB
- Sector size (logical/physical): 512B/512B
- Partition Table: gpt
- Number Start End Size File system Name Flags
- (parted) mkpart
- Partition name? []? new
- File system type? [ext2]? ext3
- Start? 1
- End? 302MB
- Warning: The resulting partition is not properly aligned for best performance.
- Ignore/Cancel? ignore
- (parted) print
- Model: OPNFILER VIRTUAL-DISK (scsi)
- Disk /dev/sdb: 302MB
- Sector size (logical/physical): 512B/512B
- Partition Table: gpt
- Number Start End Size File system Name Flags
- 1 17.4kB 302MB 302MB new
- (parted) toggle 1 lvm
- (parted) print
- Model: OPNFILER VIRTUAL-DISK (scsi)
- Disk /dev/sdb: 302MB
- Sector size (logical/physical): 512B/512B
- Partition Table: gpt
- Number Start End Size File system Name Flags
- 1 17.4kB 302MB 302MB new lvm
- (parted) quit
- Information: You may need to update /etc/fstab.
- [root@rhel6 /]#
notice this one “(parted) toggle 1 lvm”,of course,we can use help:
- [root@rhel6 /]# parted /dev/sdb
- GNU Parted 2.1
- Using /dev/sdb
- Welcome to GNU Parted! Type 'help' to view a list of commands.
- (parted) help toggle
- toggle [NUMBER [FLAG]] toggle the state of FLAG on partition
- NUMBER
- NUMBER is the partition number used by Linux. On MS-DOS disk labels,
- the primary partitions number from 1 to 4, logical partitions from 5
- onwards.
- FLAG is one of: boot, root, swap, hidden, raid, lvm, lba, hp-service,
- palo, prep, msftres, bios_grub, atvrecv, diag
- (parted)
Ok,after this,if you use fdisk to check out the lun ,it appears like this:
- WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
- Disk /dev/sdb: 301 MB, 301989888 bytes
- 255 heads, 63 sectors/track, 36 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk identifier: 0x00000000
- Device Boot Start End Blocks Id System
- /dev/sdb1 1 37 294911+ ee GPT
- Partition 1 has different physical/logical beginnings (non-Linux?):
- phys=(0, 0, 1) logical=(0, 0, 2)
- Partition 1 has different physical/logical endings:
- phys=(1023, 254, 63) logical=(36, 182, 18)
- Disk /dev/mapper/mpatha: 301 MB, 301989888 bytes
- 255 heads, 63 sectors/track, 36 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk identifier: 0x00000000
- Device Boot Start End Blocks Id System
- Disk /dev/mapper/mpathap1: 301 MB, 301681664 bytes
- 255 heads, 63 sectors/track, 36 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk identifier: 0x00000000
- Disk /dev/mapper/mpathap1 doesn't contain a valid partition table
well,create LVM.
- [root@rhel6 /]# pvscan
- PV /dev/sda2 VG vg_rhel6 lvm2 [19.80 GiB / 0 free]
- Total: 1 [19.80 GiB] / in use: 1 [19.80 GiB] / in no VG: 0 [0 ]
- [root@rhel6 /]# pvcreate /dev/mapper/
- control mpathap1 testp1 vg_rhel6-LogVol01
- mpatha test vg_rhel6-LogVol00
- [root@rhel6 /]# pvcreate /dev/mapper/mpathap1
- Physical volume "/dev/mapper/mpathap1" successfully created
- [root@rhel6 /]# pvscan
- PV /dev/sda2 VG vg_rhel6 lvm2 [19.80 GiB / 0 free]
- PV /dev/mapper/mpathap1 lvm2 [287.71 MiB]
- Total: 2 [20.08 GiB] / in use: 1 [19.80 GiB] / in no VG: 1 [287.71 MiB]
- [root@rhel6 /]# vgcreate mpathvg /dev/mapper/mpathap1
- Volume group "mpathvg" successfully created
- [root@rhel6 /]# vgscan
- Reading all physical volumes. This may take a while...
- Found volume group "mpathvg" using metadata type lvm2
- Found volume group "vg_rhel6" using metadata type lvm2
- [root@rhel6 /]# vgdisplay mpathvg
- --- Volume group ---
- VG Name mpathvg
- System ID
- Format lvm2
- Metadata Areas 1
- Metadata Sequence No 1
- VG Access read/write
- VG Status resizable
- MAX LV 0
- Cur LV 0
- Open LV 0
- Max PV 0
- Cur PV 1
- Act PV 1
- VG Size 284.00 MiB
- PE Size 4.00 MiB
- Total PE 71
- Alloc PE / Size 0 / 0
- Free PE / Size 71 / 284.00 MiB
- VG UUID p2g0qA-wqrn-Uy0z-sp9U-dghf-UrGO-jpeIkj
- [root@rhel6 /]# lvcreate -l 71 mpathvg -n mpathlv
- Logical volume "mpathlv" created
- [root@rhel6 /]# lvscan
- ACTIVE '/dev/mpathvg/mpathlv' [284.00 MiB] inherit
- ACTIVE '/dev/vg_rhel6/LogVol01' [1.95 GiB] inherit
- ACTIVE '/dev/vg_rhel6/LogVol00' [17.85 GiB] inherit
display the logical volume with lvdisplay:
- [root@rhel6 /]# lvdisplay
- --- Logical volume ---
- LV Name /dev/mpathvg/mpathlv
- VG Name mpathvg
- LV UUID M7A8dK-sJ8M-EEMP-rUFZ-45uw-Gm7q-BTtNaK
- LV Write Access read/write
- LV Status available
- # open 0
- LV Size 284.00 MiB
- Current LE 71
- Segments 1
- Allocation inherit
- Read ahead sectors auto
- - currently set to 256
- Block device 253:6
Ok,now,make filesystem:
- [root@rhel6 /]# mkfs.ext3 /dev/mpathvg/mpathlv
- mke2fs 1.41.12 (17-May-2010)
- Filesystem label=
- OS type: Linux
- Block size=1024 (log=0)
- Fragment size=1024 (log=0)
- Stride=0 blocks, Stripe width=0 blocks
- 72864 inodes, 290816 blocks
- 14540 blocks (5.00%) reserved for the super user
- First data block=1
- Maximum filesystem blocks=67633152
- 36 block groups
- 8192 blocks per group, 8192 fragments per group
- 2024 inodes per group
- Superblock backups stored on blocks:
- 8193, 24577, 40961, 57345, 73729, 204801, 221185
- Writing inode tables: done
- Creating journal (8192 blocks): done
- Writing superblocks and filesystem accounting information: done
- This filesystem will be automatically checked every 39 mounts or
- 180 days, whichever comes first. Use tune2fs -c or -i to override.
- [root@rhel6 /]# mkdir /mpath
- [root@rhel6 /]# mount /dev/mpathvg/mpathlv /mpath/
- [root@rhel6 /]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_rhel6-LogVol00
- 18G 2.3G 15G 14% /
- tmpfs 260M 0 260M 0% /dev/shm
- /dev/sda1 194M 25M 160M 14% /boot
- /dev/mapper/testp1 90M 5.6M 79M 7% /data
- /dev/mapper/mpathvg-mpathlv
- 276M 11M 251M 4% /mpath
- [root@rhel6 /]#
When i was deploying the system,i feel confused about GPT with LVM,So i write down this for my further reference!