標籤:des http io ar os 使用 sp for on
參考文檔連結:
http://www.chinaunix.net/jh/4/72921.html
名詞解釋:
1.物理卷 Physical Volume (PV):一個物理卷,包含了許多物理分區
2.物理分區 Physical Extents (PE)
3.卷組 Volume Group (VG):一個VG是由許多物理分區組成的(可能來自多個物理卷或硬碟)。
4.邏輯卷 Logical Volume (LV)
5.檔案系統 Filesystem
建立邏輯卷LV,操作步驟如下:
1.對各個磁碟進行分區
[[email protected] ~]# fdisk /dev/sdb
2.建立物理卷(PV),例如:
[[email protected] ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[[email protected] ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
[[email protected] ~]# pvcreate /dev/sdc2
Physical volume "/dev/sdc2" successfully created
3.將建立的物理卷(PV),添加到卷組(VG)中,比如VG命名為vgtest
[[email protected] ~]# vgcreate vgtest /dev/sdb1 /dev/sdc1 /dev/sdc2
Volume group "vgtest" successfully created
3.1 查看建立的卷組
[[email protected] ~]# vgdisplay vgtest
--- Volume group ---
VG Name vgtest
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 4.45 TB
PE Size 4.00 MB
Total PE 1167649
Alloc PE / Size 0 / 0
Free PE / Size 1167649 / 4.45 TB
VG UUID mxlmwo-DFHf-0Q32-W5Kj-KhaA-In07-DBReET
4.建立邏輯卷(命名為vgtest_LV01),在建立的卷組vgtest中
[[email protected] ~]# lvcreate -L 100G -n vgtest_LV01 vgtest #建立100G容量大小的邏輯卷
Logical volume "vgtest_LV01" created
[[email protected] ~]# lvcreate -l +100%PVS -n vgtest_LV01 vgtest #新邏輯卷使用全部的物理卷空間
Logical volume "vgtest_LV01" created
5.在邏輯卷上面建立檔案系統,也就是格式化新建立的邏輯卷vgtest_LV01
[[email protected]st ~]# mkfs.ext3 /dev/vgtest/vgtest_LV01
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
13107200 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
800 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
6.擴充邏輯卷LV的容量
[[email protected] ~]# lvextend -L +100G /dev/vgtest/vgtest_LV01
Extending logical volume vgtest_LV01 to 200.00 GB
Logical volume vgtest_LV01 successfully resized
7.擴充檔案系統容量,邏輯卷LV容量擴充之後,需要隨之擴充檔案系統的容量
7.1檢查檔案系統
[[email protected] ~]# e2fsck -f /dev/vgtest/vgtest_LV01
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vgtest/vgtest_LV01: 11/13107200 files (9.1% non-contiguous), 459383/26214400 blocks
7.2擴充檔案系統
[[email protected] ~]# resize2fs -p /dev/vgtest/vgtest_LV01
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vgtest/vgtest_LV01 to 52428800 (4k) blocks.
Begin pass 1 (max = 800)
Extending the inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/vgtest/vgtest_LV01 is now 52428800 blocks long.
部分命令:
help Display help for commands
lvcreate Create a logical volume
lvdisplay Display information about a logical volume
lvs Display information about logical volumes
pvcreate Initialize physical volume(s) for use by LVM
pvdisplay Display various attributes of physical volume(s)
pvs Display information about physical volumes
vgcreate Create a volume group
vgdisplay Display volume group information
vgextend Add physical volumes to a volume group
vgremove Remove volume group(s)
vgs Display information about volume groups
使用 parted 建立大於2T的gpt分區
[[email protected] ~]# parted /dev/sdb # 使用parted來對GPT磁碟操作,進入互動式模式
GNU Parted 1.8.1 Using /dev/sdb Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) mklabel gpt # 將MBR磁碟格式化為GPT
(parted) print #列印當前分區
(parted) mkpart primary 0 4.5TB # 分一個4.5T的主要磁碟分割
(parted) mkpart primary 4.5TB 12TB # 分一個7.5T的主要磁碟分割
(parted) print #列印當前分區
(parted) quit 退出
Information: Don’t forget to update /etc/fstab, if necessary.
linux下建立LVM