LVM LAB 1

Thông tin đĩa:

– /dev/sda: đĩa hệ thống

– 4 HDD: /dev/sdb, /dev/sdc, /dev/sdd, /dev/sde cho LVM, mỗi đĩa dung lượng khoảng 30GB, sử dụng 20GB

1. Format đĩa:

– fdisk /dev/sdb

Enter: n (tạo partition mới)

Enter: p (tạo primary partition)

Enter: 1 (tạo part số 1)

Enter (First sector default)

Enter: +20000M (Last sector: 20GB)

Enter: t (chọn partition type)

Enter: 8e (linux LVM)

Enter: w (write changes)

Tương tự cho sdc, sdd, sde. Check lại bằng fdisk -l

2. Tạo Physcial Volume

pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1

Kiểm tra bằng pvdisplay

3. Tạo Volume Group

vgcreate fileserver /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1

Kiểm tra bằng vgdisplay, vgscan

Đổi tên bằng vgrename, xóa bằng vgremove

4. Tạo Logical Volume

lvcreate –name share –size 40G fileserver

lvcreate –name backup –size 5G fileserver

lvcreate –name media –size 1G fileserver

Kiểm ta bằng lvdisplay hoặc lvscan

Đổi tên bằng lvrename, xóa bằng lvremove

Mở rộng Logical Volume

lvextend -L1.5G /dev/fileserver/media

Thu hẹp LV

lvreduce -L1G /dev/fileserver/media

5. Tạo FS

mkfs.ext3 /dev/fileserver/share

mkfs.ext3 /dev/fileserver/backup

mkfs.ext3 /dev/fileserver/media

6. Tạo mountpoint

mkdir /var/media /var/backup /var/share

7. Mount

mount /dev/fileserver/share /var/share
mount /dev/fileserver/backup /var/backup
mount /dev/fileserver/media /var/media

Check bằng df -h

8. Edit file fstab

/dev/fileserver/share   /var/share     ext3       default    0 0
/dev/fileserver/backup    /var/backup      ext3        default    0 0
/dev/fileserver/media    /var/media      ext3   rw,default    0 0

Restart

Done

Trả hệ thống lại tình trạng cũ:

1. Unmount

umount /var/share
umount /var/backup
umount /var/media

2. Xóa LV

lvremove /dev/fileserver/share

Check lại bằng lvdisplay

3. Xóa VG

vgremove fileserver

Check lại bằng vgdisplay

4. Xóa PV

pvremove /dev/sdb1 /dev/sdc1 /dev/sde1 /dev/sdd1

Check lại bằng pvdisplay

5. Xóa các dòng vừa thêm trong file fstab

Reboot

Check lại bằng df -h

Refrence: How to forge LVM

Advertisements

About dongthao

"Man does not simply exist but always decides what his existence will be, what he will become the next moment"
This entry was posted in Linux, Linux Tutorial and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s