Skip to content


How to create LVM on Ubuntu

Create LVM on Ubuntu

1. Using the whole secondary hard disk for LVM partition:
sudo fdisk /dev/sdb

Once in the fdisk menu:
1. press n to create a new disk partition,
2. press p to create a primary disk partition,
3. press 1 to define it as the first disk partition,
4. press ENTER twice. This converts the whole secondary disk into a single disk partition,
5. press t to select the partition type,
6. press L to list all the supported partition types,
7. press 8e to select Linux LVM partition type,
8. press p to display the secondary hard disk partition setup. it shows you as /dev/sdb1.
9. press w to write the partition table
10. exit fdisk upon completion.

1.1 Assign disk partitions to physical volumes
sudo pvcreate /dev/sdb1

1.2 Create Volume Group VG for the /data and /backup volumes
sudo vgcreate myvg_data /dev/sdb1
pvdisplay
vgdisplay

pvdisplay and vgdisplay gives you information about LVM.

1.3 Create Logical Volumes ( LV )
sudo lvcreate -L 500G --name data myvg_data

1.4 Format file system
sudo mke2fs -t ext4 -L /data /dev/myvg_data/data

1.5 Mount file system
sudo mkdir /data
sudo mount /dev/myvg_data/data /data
df -hT

Make sure you see the partition mounted and its correct size.

1.7. Add it to the system startup
Check disks UUID by installing blkid and takes not of the UUID from /dev/sdb1 – /dev/myvg_data/data
sudo apt-get install id-utils
sudo blkid

1.8 Add the following entry in /etc/fstab to have the partition mounted
sudo vi /etc/fstab
Add at the end of the file the following lines:
UUID=<enter the uuid number found with blkid> /data ext4 errors=remount-ro 0 1

sudo mount -v
sudo umount --force /data
sudo mount -a
sudo mount -v

1.9 Make sure you can write something in to the new partition
touch /data/file1.asc
ls -la /data

2 Reboot the server and make sure that the /data partition is mounted.

Posted in Knowledge Base.

Tagged with , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.