Skip to content

Instantly share code, notes, and snippets.

@jrziviani
Created January 27, 2016 16:16
Show Gist options
  • Save jrziviani/4090c800340192cf4741 to your computer and use it in GitHub Desktop.
Save jrziviani/4090c800340192cf4741 to your computer and use it in GitHub Desktop.
Create PVs and VG
[root@localhost ~]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.27).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-16777215, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-16777215, default 16777215): +3G
Created a new partition 1 of type 'Linux' and of size 3 GiB.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (6293504-16777215, default 6293504):
Last sector, +sectors or +size{K,M,G,T,P} (6293504-16777215, default 16777215): +2G
Created a new partition 2 of type 'Linux' and of size 2 GiB.
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (10487808-16777215, default 10487808):
Last sector, +sectors or +size{K,M,G,T,P} (10487808-16777215, default 16777215):
Created a new partition 3 of type 'Linux' and of size 3 GiB.
Command (m for help): p
Disk /dev/sdb: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x411cd82c
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 6293503 6291456 3G 83 Linux
/dev/sdb2 6293504 10487807 4194304 2G 83 Linux
/dev/sdb3 10487808 16777215 6289408 3G 83 Linux
Command (m for help): t
Partition number (1-3, default 3): 1
Partition type (type L to list all types): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): t
Partition number (1-3, default 3): 2
Partition type (type L to list all types): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): t
Partition number (1-3, default 3):
Partition type (type L to list all types): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): p
Disk /dev/sdb: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x411cd82c
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 6293503 6291456 3G 8e Linux LVM
/dev/sdb2 6293504 10487807 4194304 2G 8e Linux LVM
/dev/sdb3 10487808 16777215 6289408 3G 8e Linux LVM
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1 /dev/sdb2 /dev/sdb3
[root@localhost ~]# vgcreate mygroup /dev/sdb1 /dev/sdb2 /dev/sdb3
Volume group "mygroup" successfully created
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
fedora 1 2 0 wz--n- 9.51g 0
mygroup 3 0 0 wz--n- 7.99g 7.99g
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 fedora lvm2 a-- 9.51g 0
/dev/sdb1 mygroup lvm2 a-- 3.00g 3.00g
/dev/sdb2 mygroup lvm2 a-- 2.00g 2.00g
/dev/sdb3 mygroup lvm2 a-- 3.00g 3.00g
[root@localhost ~]# vg
vgcfgbackup vgchange vgconvert vgdisplay vgextend vgimportclone vgmknodes vgremove vgs vgsplit
vgcfgrestore vgck vgcreate vgexport vgimport vgmerge vgreduce vgrename vgscan
[root@localhost ~]# vgdisplay mygroup
--- Volume group ---
VG Name mygroup
System ID
Format lvm2
Metadata Areas 3
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 3
Act PV 3
VG Size 7.99 GiB
PE Size 4.00 MiB
Total PE 2045
Alloc PE / Size 0 / 0
Free PE / Size 2045 / 7.99 GiB
VG UUID 34YPe9-JzR1-oHF5-ZOyn-nc6S-tUuw-akUmRe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment