I guess you want to know the steps to create LVM after you partition the hdd. Below are the steps to create an LVM on sda1
1) pvcreate < device name>
2) vgcreate < vg name> <device name>
3) lvcreate -n <lvname> -L <LV size> <vgname>
Hi @Jayadev ,
I think you are didn’t get my question.
I mentioned all points should be required.
Create from fdisk /dev/*d*
some parameters like m,n,p, +M/G , t,8e,,p,w, to partprobe -s ( here only getting issues and unable to create lvm .
Actually no issues from pvcreate,vgcreate,lvcreate . These steps are lerared from in this site .
could you please provide steps and instructions should be provided from “fdisk/dev/*d* .......................................... to partprobe ( I mentioned so many dots that area instructions/prerequisites are required.
Actually I tried but unable to create new like /dev/*d* from fdisk /dev/*d* . I think did you understand about my issue.
Could you please share these steps with example and possible try to share with screenshots. I am waiting for your valuable reply.
Could you please let me if any concerns .
It sounds like you need a fdisk tutorial. There are several on the Web. Try out a couple of them and then come back with specific questions and we will be happy to help.
If I'm understanding you correctly, you're looking for steps on how to partition a non-root disk, and create filesytems? If so, here is how I do it for creating a new filesystem within LVM.
1) Scan for the new disk:
# ls /dev/sd*
2) I do not use fdisk anymore, as it does not support disks larger than 2TB. Instead, use parted. This assumes you want to use the full disk as a single partition:
# parted -s /dev/sdb mklabel gpt mkpart primary 2048s 100%
3) Validate you can see your new partition:
# parted /dev/sdb u s p
# ls /dev/sdb*
3a) If you are having issues seeing it, rescan then repeat step above:
4) Create a new volume group (This also does a pvcreate on the disk partition, saving a step):
# vgcreate appvg /dev/sdb1
5) Create your logical volume:
# lvcreate -L 64G -n backuplv appvg
6) Format your partition:
# mkfs.xfs /dev/appvg/backuplv
7) Create your mount point:
# mkdir /backup
8) Create a copy of your /etc/fstab:
# cp -p /etc/fstab /etc/fstab.`date +%Y%m%d-%R`
9) Add the following line to your /etc/fstab:
/dev/appvg/backuplv /backup xfs defaults 0 0
10) Mount the new filesystem
# mount /backup
11) Validate it's mounted
# df -hP /backup
There's a lot of information out there on creating filesystems. The above is just a quick run through of the process I use for creating an xfs filesystem. I highly suggest you do some reading on this process since it will depend on the device used, the format of the filesystem, and other options such as owner, etc.
If you are using LVM for the entire disk and the disk is not a boot disk what is the benefit of partioning?
I guess we should understand the basic purpose of partioning the disk. A disk in its raw form cannot be used by OS at all. So even if its single LVM on the complete disk, it should be contain at least one partition for the OS to use it. Below is the link to an article that explains partitioning in detail
Pretty sure you can just pass an unpartitioned scsi device to pvcreate or vgcreate and it works OK.
I've had a look at the page you linked and that seems to be more about partitioning disks when you want to create a filesystem, which is fine, but is a different scenario to creating PVs.
I've been creating PVs for years without partitioning disks and not had any issues so I am wondering what the benefit of partitioning is when you are using an entire disk as a single PV (which I think is the common case) ?
I have done it both ways when dealing PV's. Using the entire device w/o creating a partition, as well as creating one. Both have worked. But, there's a couple of benefits to creating a partition that I prefer.
The first is that from a quick look, one can generally make a determination if a disk is in use if it's partitioned. This is especially helpful is you may have a lot of devices such as on a large Oracle database server. If your standard is to partition a drive before use, a quck "ls /dev/sd*" or "ls /dev/mapper/mpath*" will show the devices and their partitions and you see the device. Of course, you still want to validate. But, it helps cut down times and standards are good.
The second has more to deal with disk alignment. While I haven't ran into an issue regarding disk alignment in a very long time, telling parted to do it at sectors instead of based on size helps ensuring it doesn't occur.
The first issue is the primary reason why I partition devices, and in fact I had an issue the other day where the storage team (I work in large IT organizations) allocated disks and didn't provide the information to me on the LUN ID's, etc. and then they were out of the office and not reachable. Because everything is partitioned, it only took a minute to determine which device was added, as it was the only one without the "p1" at the end of it.
Beyond that, Red Hat, and other Linux distros still say to partition the disk even if using the whole disk.
While the focus is primarily about multiple partitons on a single disk, they do make this statement:
"Red Hat recommends that you create a single partition that covers the whole disk to label as an LVM physical volume for the following reasons:"
Like most things in Linux/UNIX, there's multiple ways to do a task.
It depends in the use situation, but if you split into different partitions you could more easily downsize the disk as an example:
- Create a 100GB disk
- Create 2 partitions of 50GB
- Used them as Physical Volume for a new Volume group, create smaller Logical volumes, etc...
... some time later
- you are using less than 50GB and you need more disk space in another VM.
- Move the LV into the first PV (located at the beginning of the disk)
- Remove the PV from the VG, remove the last partition in the disk.
- Resize the disk assigned.
- Use that free space for the other VM that needs it.