Linux VM - Create Disk to New Partition
You are running a Linux Server, and need to create new partition disk. In this example, a new 50 GB disk will be assigned as new LVM partition.
1. You need to add disk 50 GB from vCloud Director.
2. Go to VM and check before condition. You see you only have 1 partition LVM.
3. Check all partition in server.
# lsblk
The new disk you add has been assigned as sdb
4. Now. create new partition for sdb.
# fdsik /dev/sdb
5. Type following command:
n
then select primary, type:
p
partition number, choose:
1
First sector, enter it as default.
6. You need to change type of partition into LVM.
Type:
t
Partition type:
8e
7. Now, check your sdb. Type:
p
you'll see /dev/sdb1 has created. Then type:
w
8. You need to choose the physical volumes that will be used to create the LVM. You can create the physical volumes using pvcreate command.
# pvcreate /dev/sdb1
9. Volume group is collection of physical volumes. Volume groups are nothing but a pool of storage that consists of one or more physical volumes. Once you create the physical volume, you can create the volume group (VG) from these physical volumes (PV).
# vgcreate ubuntu_vgnew/dev/sdb1
note: ubuntu_vgnew is name of this volume group. you can change it as your preference.
10. Now check your volume group.
# vgdisplay ubuntu_vgnew
11. A volume group is divided up into logical volumes. We can create logical volume with lvcreate command by giving the name of a new logical volume, its size, and the volume group.
# lvcreate -L +49G -n vg_new ubuntu_vgnew
note:
- here, you create 50 GB size of available disk.
- vg_new is name of logical volume. you can change it as your preference.
12. Before using the partition, you need to format both new partitions with a file system. You can do this with mkfs command.
# mkfs.ext4 /dev/ubuntu_vgnew/vg_new
13. Now, add new partition into fstab in order to make it mounted permanently.
# vim /etc/fstab
Add this line:
/dev/ubuntu_vgnew/vg_new /data ext4 default 0 0
14. Create new directory to mounted. Sample here: /data
# mkdir data
15. Now, mount new partition.
# mount /dev/ubuntu_vgnew/vg_new /data
16. Check after condition. You'll see there is new partition listed.