新建LV,并mount到指定目录的简单步骤:
从VG新建LV->给LV格式化文件系统->mount到我们需要的目录
前提:
我要从VolGroup00的VG上新建一个名叫vps的LV,大小为100G,要挂在的目录是/vps
1.创建LV
1
2
|
[root@
test
~]
# lvcreate -L 100G -n vps /dev/VolGroup00
Logical volume
"vps"
created
|
2.确认下我们新建的LV
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
[root@
test
~]
# lvdisplay
--- Logical volume ---
LV Name
/dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID fDHwa0-IUZV-no5O-RRJB-4N9o-U2MV-TAqucp
LV Write Access
read
/write
LV Status available
# open 1
LV Size 15.00 GB
Current LE 480
Segments 1
Allocation inherit
Read ahead sectors auto
- currently
set
to 256
Block device 253:0
--- Logical volume ---
LV Name
/dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID cUjKA9-bI60-6R05-K0jS-MdXi-r26d-mfwU8X
LV Write Access
read
/write
LV Status available
# open 1
LV Size 5.41 GB
Current LE 173
Segments 1
Allocation inherit
Read ahead sectors auto
- currently
set
to 256
Block device 253:1
--- Logical volume ---
LV Name
/dev/VolGroup00/vps
<--这就是我们新建的LV
VG Name VolGroup00
LV UUID pGW8ck-dFTG-QuXb-PL14-3hMO-BUbi-2g8wWE
LV Write Access
read
/write
LV Status available
# open 0
LV Size 100.00 GB
Current LE 3200
Segments 1
Allocation inherit
Read ahead sectors auto
- currently
set
to 256
Block device 253:2
|
可以看到,已经创建成功了。
3.格式化LV逻辑卷为ext3文件系统格式
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[root@
test
~]
# mkfs.ext3 /dev/VolGroup00/vps
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 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
|
4.把/dev/VolGroup00/vps挂载到我要挂载的/vps目录
1
2
3
4
5
6
7
8
9
10
11
|
[root@
test
~]
# mkdir /vps
[root@
test
~]
# mount -t ext3 /dev/VolGroup00/vps /vps
[root@
test
~]
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
15G 898M 14G 7% /
/dev/cciss/c0d0p2
19G 238M 18G 2%
/var
/dev/cciss/c0d0p1
99M 19M 76M 20%
/boot
tmpfs 2.0G 0 2.0G 0%
/dev/shm
/dev/mapper/VolGroup00-vps
99G 188M 94G 1%
/vps
|
看最后一行,已经挂载成功了。
5.如果你要开机自动挂载,那么还需要修改/etc/fstab,追加:
1
|
/dev/VolGroup00/vps
/vps
ext3 defaults 1 2
|
重要追记:我使用的CentOS5.6,虽然支持ext4,但是默认装系统的时候还是ext3,如果要用ext4的话,做如下操作,后面的教程我将默认以ext4为例。
1.安装操作ext4的工具
1
|
[root@
test
~]
# yum -y install e4fsprogs
|
2.在上面第三步格式化的时候,把mkfs.ext3换成mkfs.ext4,当然后几步ext3的地方也要对应的换成ext4。
1
|
[root@
test
~]
# mkfs.ext4 /dev/VolGroup00/vps
|
如果要把我们刚才格式化完了的ext3直接转换成ext4,那么执行
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@
test
~]
# umount /vps
[root@
test
~]
# e4fsck -fDC0 /dev/VolGroup00/vps
e4fsck 1.41.12 (17-May-2010)
One or
more
block group descriptor checksums are invalid. Fix<y>?
yes
........
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup00/vps
: ***** FILE SYSTEM WAS MODIFIED *****
/dev/VolGroup00/vps
: 11
/13107200
files (0.0% non-contiguous), 459383
/26214400
blocks
[root@
test
~]
# tune4fs -O extents,uninit_bg,dir_index /dev/VolGroup00/vps
[root@
test
~]
# mount -t ext4 /dev/VolGroup00/vps /vps
|
同样别忘记把/etc/fstab这条记录里的ext3改成ext4。