Tuesday, July 9, 2013

How to create LVM partition in command mode

LVM partition in command mode



LVM is most popular porcess in HDD partition. In LVM partition has a great facitilities. When you extend your partition using LVM, then without data loss you may extend any partition if you have free space. The free space will be same HDD or any other HDD. You may add or extend with your partition without data loss. As a system admin you have to know LVM partition.

If you have to maintain a mail server, your /var is 1TB. In a certain time (may be 5 - 8 years later, it depends on your user) your /var/log/mail will be fill up 1 TB. Then what will you do?

Whatever, to ignore your problem, please follow below step:

# fdisk -cul /dev/sda [to see hdd status]

# fdisk -cu /dev/sda [hdd partition command]

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-1044, default 1):                   [blank enter]




Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): +100M

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (15-1044, default 15):                   [blank enter]

Last cylinder, +cylinders or +size{K,M,G} (15-1044, default 1044): +100M

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 3

First cylinder (29-1044, default 29):                   [blank enter]

Last cylinder, +cylinders or +size{K,M,G} (29-1044, default 1044): +100M

p [display the partition status]

w [save & exit]

# reboot [reboot your system]

# fdisk -cu /dev/sda [hdd partition command]

t [to change partition type]

p [select primary]

1 [number of partition]

8e [partition type 8e = lvm]

t [to change partition type]

p [select primary]

2 [number of partition]

8e [partition type 8e = lvm]

t [to change partition type]

p [select primary]

3 [number of partition]

8e [partition type 8e = lvm]

p [select primary]

5 [number of partition]

8e [partition type 8e = lvm]

# pvcreate /dev/sda1 /dev/sda2 /dev/sda3 /dev/sda5

# vgcreate vg /dev/sda1 /dev/sda2 /dev/sda3 /dev/sda5

vgcreate = volume group create

vg = volume group name

# pvdisplay [display status]

# lvcreate -L 500M -n lvm1 vg

lvcreate = logical volume create

-L = Partition size is fixed

500M = space

-n = new logical volume

lvm1 = logical volume name

vg = volume group name

# mkfs.ext4 /dev/vg/lvm1 [format in ext4]

# mkdir /test [folder/derictory create]

# vim /etc/fstab

/dev/vg/lvm1 /test /ext4 defaults 0 0

:wq!

# mount -a

# reboot

No comments:

Post a Comment