LVM(linux) -Logical volume manger for DBA
In this post we going to see how below things.
fdisk utility is used to partition the hard disks in linux.
run fdisk in root user.you can see something like /dev/sda /dev/sdb
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0x000bbb07
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 2713599 1048576 82 Linux swap / Solaris
/dev/sda3 2713600 20971519 9128960 83 Linux
Once new hard disk added means you can able to see new device in fdisk.I have added 20GB hard disk in server so you can see new hard disk with 20gb.
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0x000bbb07
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 2713599 1048576 82 Linux swap / Solaris
/dev/sda3 2713600 20971519 9128960 83 Linux
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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
Here /dev/sdb is the newly added hard disk.we going to partition /dev/sdb.
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
we are going to create new partition.so we need to give n option in command.linux alows only 4 partitions for one hard disk.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +19G
Partition 1 of type Linux and of size 19 GB is set
atlast give w command for write table to disk and exit.
Command (m for help): w
The partition table has been altered!
Now i have created new partition of hard disk to 19gb.
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0x000bbb07
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 2713599 1048576 82 Linux swap / Solaris
/dev/sda3 2713600 20971519 9128960 83 Linux
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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
Disk label type: dos
Disk identifier: 0x7e73f232
Device Boot Start End Blocks Id System
/dev/sdb1 2048 39847935 19922944 83 Linux
Physical volume creation:-
To use disks in volume group label them as physical volume.
[root@localhost ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name oravg
PV Size 19.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 4863
Free PE 4863
Allocated PE 0
PV UUID v4AYDI-gubj-5NXp-u9Cs-b6Fh-CU2r-k7Ta1z
Volume group creation:-
Create the a volume group that consists of the LVM physical volumes you have created.
[root@localhost ~]# vgcreate oravg /dev/sdb1
Volume group "oravg" successfully created
Here i created volume group name as oravg
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name oravg
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 19.00 GiB
PE Size 4.00 MiB
Total PE 4863
Alloc PE / Size 0 / 0
Free PE / Size 4863 / 19.00 GiB
VG UUID UhJoJC-8Z3M-6gOj-e0zm-ZCuv-XWWP-2EHAoW
Physical volume creation:-
create the logical volume from volume group created.
[root@localhost ~]# lvcreate -L 15G -n orasoft oravg
Logical volume "orasoft" created.
Here i created new physical volume with 15gb and named as orasoft
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/oravg/orasoft
LV Name orasoft
VG Name oravg
LV UUID GDqmKj-qdlR-4doR-ywvJ-Q6DN-u6pA-2JxaSA
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2017-02-08 09:07:49 -0800
LV Status available
# open 1
LV Size 15.00 GiB
Current LE 3840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
Filesystem creation:-
Create file system on logical volume
[root@localhost ~]# mkfs.xfs /dev/oravg/orasoft
meta-data=/dev/oravg/orasoft isize=256 agcount=4, agsize=983040 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=3932160, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Mounting file system:-
[root@localhost ~]# mkdir /orasoft
[root@localhost ~]# mount /dev/oravg/orasoft /orasoft
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 8.7G 1.7G 7.1G 19% /
devtmpfs 480M 0 480M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 6.7M 483M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 297M 113M 185M 38% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/mapper/oravg-orasoft 15G 33M 15G 1% /orasoft
Comment me if you find this post is useful also let me know if you need any new topics.
In this post we going to see how below things.
- partition the new hard disk
- physical volume creation
- volume group creation
- logical volume creation
- filesystem creation
fdisk utility is used to partition the hard disks in linux.
run fdisk in root user.you can see something like /dev/sda /dev/sdb
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0x000bbb07
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 2713599 1048576 82 Linux swap / Solaris
/dev/sda3 2713600 20971519 9128960 83 Linux
Once new hard disk added means you can able to see new device in fdisk.I have added 20GB hard disk in server so you can see new hard disk with 20gb.
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0x000bbb07
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 2713599 1048576 82 Linux swap / Solaris
/dev/sda3 2713600 20971519 9128960 83 Linux
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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
Here /dev/sdb is the newly added hard disk.we going to partition /dev/sdb.
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
we are going to create new partition.so we need to give n option in command.linux alows only 4 partitions for one hard disk.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +19G
Partition 1 of type Linux and of size 19 GB is set
atlast give w command for write table to disk and exit.
Command (m for help): w
The partition table has been altered!
Now i have created new partition of hard disk to 19gb.
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0x000bbb07
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 2713599 1048576 82 Linux swap / Solaris
/dev/sda3 2713600 20971519 9128960 83 Linux
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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
Disk label type: dos
Disk identifier: 0x7e73f232
Device Boot Start End Blocks Id System
/dev/sdb1 2048 39847935 19922944 83 Linux
Physical volume creation:-
To use disks in volume group label them as physical volume.
[root@localhost ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name oravg
PV Size 19.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 4863
Free PE 4863
Allocated PE 0
PV UUID v4AYDI-gubj-5NXp-u9Cs-b6Fh-CU2r-k7Ta1z
Volume group creation:-
Create the a volume group that consists of the LVM physical volumes you have created.
[root@localhost ~]# vgcreate oravg /dev/sdb1
Volume group "oravg" successfully created
Here i created volume group name as oravg
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name oravg
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 19.00 GiB
PE Size 4.00 MiB
Total PE 4863
Alloc PE / Size 0 / 0
Free PE / Size 4863 / 19.00 GiB
VG UUID UhJoJC-8Z3M-6gOj-e0zm-ZCuv-XWWP-2EHAoW
Physical volume creation:-
create the logical volume from volume group created.
[root@localhost ~]# lvcreate -L 15G -n orasoft oravg
Logical volume "orasoft" created.
Here i created new physical volume with 15gb and named as orasoft
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/oravg/orasoft
LV Name orasoft
VG Name oravg
LV UUID GDqmKj-qdlR-4doR-ywvJ-Q6DN-u6pA-2JxaSA
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2017-02-08 09:07:49 -0800
LV Status available
# open 1
LV Size 15.00 GiB
Current LE 3840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
Filesystem creation:-
Create file system on logical volume
[root@localhost ~]# mkfs.xfs /dev/oravg/orasoft
meta-data=/dev/oravg/orasoft isize=256 agcount=4, agsize=983040 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=3932160, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Mounting file system:-
[root@localhost ~]# mkdir /orasoft
[root@localhost ~]# mount /dev/oravg/orasoft /orasoft
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 8.7G 1.7G 7.1G 19% /
devtmpfs 480M 0 480M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 6.7M 483M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 297M 113M 185M 38% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/mapper/oravg-orasoft 15G 33M 15G 1% /orasoft
Comment me if you find this post is useful also let me know if you need any new topics.
No comments:
Post a Comment