英文地址:http://www.howtoforge.com/linux_lvm

转自:http://forum.ubuntu.org.cn/viewtopic.php?f=54&t=254335

      本指南将介绍如何使用lvm-逻辑卷管理。

1 预备
我是通过以下两篇文章得到灵感,才写出此教程的。
http://www.linuxdevcenter.com/pub/a/lin ... h-lvm.html
http://www.debian-administration.org/articles/410
这两篇文章都很不错,不过如果之前没有用过lvm,就会很难理解它的内容。所以,我才写了该文档来简化lvm的学习过程。首先,我们要安装所有必须的工具软件包。

1 $ sudo apt-get install lvm2 dmsetup mdadm reiserfsprogs xfsprogs
2 apt-get install lvm2 dmsetup mdadm reiserfsprogs xfsprogs

2 lvm层次结构
大体上,LVM的层次结构是这样的:

底层是物理卷physical volume,一个多个都可以(如/dev/sda1到/dev/sde1,实际上是和分区一一对应的,只不过要通过相关工具创建),然后在把这些物理卷(一个或多个)集合为一个逻辑卷组 volume group. 柔和在一起后,我们就可以重新分割啦。可以分割为一个或多个逻辑卷(logical volume),此时,就可以再分割成的逻辑卷上面格式化了,然后就可以向上面存放数据了(就想我们原来使用的分区一样)。这样的逻辑卷比制作前的任何一个物理分区或物理卷,可以都要大,当然也可以小,这就看你自己怎么分割了。(我本人觉得这就好比和面,刚开始时,有几块都比较小,分散。我们加点水,柔和在一起,我们就又可以制作任何大小的块了,面条也可以啊。)

使用逻辑卷时候,最好不要把所有的磁盘空间都使用了。这样,以后某块逻辑卷需要加大,就可以使用留下的空闲空间。

本教程例子中将创建逻辑卷组volume group,fileserver,创建逻辑卷/dev/fileserver/share, /dev/fileserver/backup, and /dev/fileserver/media

3 开始LVM设置

第一步,找出硬盘及分区

1 server1:~# fdisk -l
 2 
 3 Disk /dev/sda: 21.4 GB, 21474836480 bytes
 4 255 heads, 63 sectors/track, 2610 cylinders
 5 Units = cylinders of 16065 * 512 = 8225280 bytes
 6 
 7 Device Boot Start End Blocks Id System
 8 /dev/sda1 * 1 18 144553+ 83 Linux
 9 /dev/sda2 19 2450 19535040 83 Linux
10 /dev/sda4 2451 2610 1285200 82 Linux swap / Solaris
11 
12 Disk /dev/sdb: 85.8 GB, 85899345920 bytes
13 255 heads, 63 sectors/track, 10443 cylinders
14 Units = cylinders of 16065 * 512 = 8225280 bytes
15 
16 Disk /dev/sdb doesn't contain a valid partition table
17 
18 Disk /dev/sdc: 85.8 GB, 85899345920 bytes
19 255 heads, 63 sectors/track, 10443 cylinders
20 Units = cylinders of 16065 * 512 = 8225280 bytes
21 
22 Disk /dev/sdc doesn't contain a valid partition table
23 
24 Disk /dev/sdd: 85.8 GB, 85899345920 bytes
25 255 heads, 63 sectors/track, 10443 cylinders
26 Units = cylinders of 16065 * 512 = 8225280 bytes
27 
28 Disk /dev/sdd doesn't contain a valid partition table
29 
30 Disk /dev/sde: 85.8 GB, 85899345920 bytes
31 255 heads, 63 sectors/track, 10443 cylinders
32 Units = cylinders of 16065 * 512 = 8225280 bytes
33 
34 Disk /dev/sde doesn't contain a valid partition table
35 
36 Disk /dev/sdf: 85.8 GB, 85899345920 bytes
37 255 heads, 63 sectors/track, 10443 cylinders
38 Units = cylinders of 16065 * 512 = 8225280 bytes
39 
40 Disk /dev/sdf doesn't contain a valid partition table

我们看到了/dev/sdb到/dev/sdf都没有分区。我们将创建/dev/sdb1, /dev/sdc1, /dev/sdd1, and

/dev/sde1分区,/dev/sdf暂时不用。每个分区都只分配25G的分区。

第二步,创建磁盘分区
第一块硬盘

1 server1:~# fdisk /dev/sdb
 2 
 3 The number of cylinders for this disk is set to 10443.
 4 There is nothing wrong with that, but this is larger than 1024,
 5 and could in certain setups cause problems with:
 6 1) software that runs at boot time (e.g., old versions of LILO)
 7 2) booting and partitioning software from other OSs
 8 (e.g., DOS FDISK, OS/2 FDISK)
 9 
10 Command (m for help): <-- m 帮助文档
11 Command action
12 a toggle a bootable flag
13 b edit bsd disklabel
14 c toggle the dos compatibility flag
15 d delete a partition
16 l list known partition types
17 m print this menu
18 n add a new partition
19 o create a new empty DOS partition table
20 p print the partition table
21 q quit without saving changes
22 s create a new empty Sun disklabel
23 t change a partition's system id
24 u change display/entry units
25 v verify the partition table
26 w write table to disk and exit
27 x extra functionality (experts only)
28 
29 Command (m for help): <-- n创建新分区new
30 Command action
31 e extended 扩展分区
32 p primary partition (1-4)主分区
33 <-- p选主分区
34 Partition number (1-4): <-- 1分区编号
35 First cylinder (1-10443, default 1): <-- <ENTER>开始磁道 ,直接回车默认为第一个磁道)
36 Using default value 1
37 Last cylinder or +size or +sizeM or +sizeK (1-10443, default 10443): <-- +25000M我们只使用
38 
39 25G空间
40 
41 Command (m for help): <-- t改变分区id
42 Selected partition 1
43 Hex code (type L to list codes): <-- L列出所有的代码意思
44 
45 0 Empty 1e Hidden W95 FAT1 80 Old Minix be Solaris boot
46 1 FAT12 24 NEC DOS 81 Minix / old Lin bf Solaris
47 2 XENIX root 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
48 3 XENIX usr 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
49 4 FAT16 <32M 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
50 5 Extended 41 PPC PReP Boot 85 Linux extended c7 Syrinx
51 6 FAT16 42 SFS 86 NTFS volume set da Non-FS data
52 7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
53 8 AIX 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
54 9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM df BootIt
55 a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e1 DOS access
56 b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
57 c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS e4 SpeedStor
58 e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
59 f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ee EFI GPT
60 10 OPUS 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
61 11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
62 12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
63 14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f4 SpeedStor
64 16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
65 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fd Linux raid auto
66 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fe LANstep
67 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT
68 1c Hidden W95 FAT3 75 PC/IX
69 Hex code (type L to list codes): <-- 8e表示linux的lvm
70 Changed system type of partition 1 to 8e (Linux LVM)
71 
72 Command (m for help): <-- w将设置写入
73 The partition table has been altered!
74 
75 Calling ioctl() to re-read partition table.
76 Syncing disks.

下面的三块硬盘我们也使用类似的方法,

fdisk /dev/sdc
fdisk /dev/sdd
fdisk /dev/sde

完成后,使用fdisk -l输出应该是这样:

1 server1:~# fdisk -l
 2 
 3 Disk /dev/sda: 21.4 GB, 21474836480 bytes
 4 255 heads, 63 sectors/track, 2610 cylinders
 5 Units = cylinders of 16065 * 512 = 8225280 bytes
 6 
 7 Device Boot Start End Blocks Id System
 8 /dev/sda1 * 1 18 144553+ 83 Linux
 9 /dev/sda2 19 2450 19535040 83 Linux
10 /dev/sda4 2451 2610 1285200 82 Linux swap / Solaris
11 
12 Disk /dev/sdb: 85.8 GB, 85899345920 bytes
13 255 heads, 63 sectors/track, 10443 cylinders
14 Units = cylinders of 16065 * 512 = 8225280 bytes
15 
16 Device Boot Start End Blocks Id System
17 /dev/sdb1 1 3040 24418768+ 8e Linux LVM
18 
19 Disk /dev/sdc: 85.8 GB, 85899345920 bytes
20 255 heads, 63 sectors/track, 10443 cylinders
21 Units = cylinders of 16065 * 512 = 8225280 bytes
22 
23 Device Boot Start End Blocks Id System
24 /dev/sdc1 1 3040 24418768+ 8e Linux LVM
25 
26 Disk /dev/sdd: 85.8 GB, 85899345920 bytes
27 255 heads, 63 sectors/track, 10443 cylinders
28 Units = cylinders of 16065 * 512 = 8225280 bytes
29 
30 Device Boot Start End Blocks Id System
31 /dev/sdd1 1 3040 24418768+ 8e Linux LVM
32 
33 Disk /dev/sde: 85.8 GB, 85899345920 bytes
34 255 heads, 63 sectors/track, 10443 cylinders
35 Units = cylinders of 16065 * 512 = 8225280 bytes
36 
37 Device Boot Start End Blocks Id System
38 /dev/sde1 1 3040 24418768+ 8e Linux LVM
39 
40 Disk /dev/sdf: 85.8 GB, 85899345920 bytes
41 255 heads, 63 sectors/track, 10443 cylinders
42 Units = cylinders of 16065 * 512 = 8225280 bytes
43 
44 Disk /dev/sdf doesn't contain a valid partition table

4.创建物理卷

1 pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1(看到了吧,物理卷和分区是一一对应的哦)
2 
3 server1:~# pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
4 Physical volume "/dev/sdb1" successfully created
5 Physical volume "/dev/sdc1" successfully created
6 Physical volume "/dev/sdd1" successfully created
7 Physical volume "/dev/sde1" successfully created

如果你想再练习一下,可以删除刚才的创建的物理卷。

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

server1:~# pvremove /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
Labels on physical volume "/dev/sdb1" successfully wiped
Labels on physical volume "/dev/sdc1" successfully wiped
Labels on physical volume "/dev/sdd1" successfully wiped
Labels on physical volume "/dev/sde1" successfully wiped

然后再创建:

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

again:

server1:~# pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdc1" successfully created
Physical volume "/dev/sdd1" successfully created
Physical volume "/dev/sde1" successfully created

然后:
pvdisplay来显示物理卷的状态。

1 server1:~# pvdisplay
 2 --- NEW Physical volume ---
 3 PV Name /dev/sdb1
 4 VG Name
 5 PV Size 23.29 GB
 6 Allocatable NO
 7 PE Size (KByte) 0
 8 Total PE 0
 9 Free PE 0
10 Allocated PE 0
11 PV UUID G8lu2L-Hij1-NVde-sOKc-OoVI-fadg-Jd1vyU
12 
13 --- NEW Physical volume ---
14 PV Name /dev/sdc1
15 VG Name
16 PV Size 23.29 GB
17 Allocatable NO
18 PE Size (KByte) 0
19 Total PE 0
20 Free PE 0
21 Allocated PE 0
22 PV UUID 40GJyh-IbsI-pzhn-TDRq-PQ3l-3ut0-AVSE4B
23 
24 --- NEW Physical volume ---
25 PV Name /dev/sdd1
26 VG Name
27 PV Size 23.29 GB
28 Allocatable NO
29 PE Size (KByte) 0
30 Total PE 0
31 Free PE 0
32 Allocated PE 0
33 PV UUID 4mU63D-4s26-uL00-r0pO-Q0hP-mvQR-2YJN5B
34 
35 --- NEW Physical volume ---
36 PV Name /dev/sde1
37 VG Name
38 PV Size 23.29 GB
39 Allocatable NO
40 PE Size (KByte) 0
41 Total PE 0
42 Free PE 0
43 Allocated PE 0
44 PV UUID 3upcZc-4eS2-h4r4-iBKK-gZJv-AYt3-EKdRK6

好像每个都没有25G哦,那当然啦,因为我们输入的是大概值。

总结来讲,上面主要有两部
第一,fdisk 分区,然后标记8e,lvm
第二,创建pv,物理卷

5.创建逻辑卷组

创建逻辑卷组fileserver:

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

 

这样就把分开的面团和为一个了,哈哈~

1 server1:~# vgcreate fileserver /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
2 Volume group "fileserver" successfully created

查看逻辑卷组:


vgdisplay

1 server1:~# vgdisplay
 2 --- Volume group ---
 3 VG Name fileserver
 4 System ID
 5 Format lvm2
 6 Metadata Areas 4
 7 Metadata Sequence No 1
 8 VG Access read/write
 9 VG Status resizable
10 MAX LV 0
11 Cur LV 0
12 Open LV 0
13 Max PV 0
14 Cur PV 4
15 Act PV 4
16 VG Size 93.14 GB
17 PE Size 4.00 MB
18 Total PE 23844
19 Alloc PE / Size 0 / 0
20 Free PE / Size 23844 / 93.14 GB
21 VG UUID 3Y1WVF-BLET-QkKs-Qnrs-SZxI-wrNO-dTqhFP


vgscan命令也可以查看逻辑卷组。

vgscan


1 server1:~# vgscan
2 Reading all physical volumes. This may take a while...
3 Found volume group "fileserver" using metadata type lvm2

 

我们可以重命名逻辑卷组名
vgrename fileserver data

1 server1:~# vgrename fileserver data
2 Volume group "fileserver" successfully renamed to "data"

 

然后再用vgdisplay查看

1 server1:~# vgdisplay
 2 --- Volume group ---
 3 VG Name data
 4 System ID
 5 Format lvm2
 6 Metadata Areas 4
 7 Metadata Sequence No 2
 8 VG Access read/write
 9 VG Status resizable
10 MAX LV 0
11 Cur LV 0
12 Open LV 0
13 Max PV 0
14 Cur PV 4
15 Act PV 4
16 VG Size 93.14 GB
17 PE Size 4.00 MB
18 Total PE 23844
19 Alloc PE / Size 0 / 0
20 Free PE / Size 23844 / 93.14 GB
21 VG UUID 3Y1WVF-BLET-QkKs-Qnrs-SZxI-wrNO-dTqhFP

vgscan查看

1 server1:~# vgscan
2 Reading all physical volumes. This may take a while...
3 Found volume group "data" using metadata type lvm2

 

删除逻辑卷组data:

vgremove data

1 server1:~# vgremove data
2 Volume group "data" successfully removed

 

vgdisplay

这下就没有输出了

server1:~# vgdisplay

vgscan

好啦,不折腾了,重新创建fileserver卷组吧


1 vgcreate fileserver /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
2 
3 server1:~# vgcreate fileserver /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
4 Volume group "fileserver" successfully created

 

6.在fileserver上面创建逻辑卷

下面我们在fileserver上面创建逻辑卷了(分面团了嘛)。分别为share(40G),backup(5G),media(1G)这个大小是可以任意分的,但不能超过fileserver的总大小哦.
我们只使用了少于50%的空间,其余用于等会使用RAID1.fileserver大概有96G的空间哦。

 

命令很简单,也很好理解:
1.lvcreate --name share --size 40G fileserver

1 server1:~# lvcreate --name share --size 40G fileserver
2 Logical volume "share" created


2.lvcreate --name backup --size 5G fileserver


1 server1:~# lvcreate --name backup --size 5G fileserver
2 Logical volume "backup" created


3.lvcreate --name media --size 1G fileserver


1 server1:~# lvcreate --name media --size 1G fileserver
2 Logical volume "media" created

 

查看逻辑卷:

1 lvdisplay
 2 server1:~# lvdisplay
 3 --- Logical volume ---
 4 LV Name /dev/fileserver/share
 5 VG Name fileserver
 6 LV UUID 280Mup-H9aa-sn0S-AXH3-04cP-V6p9-lfoGgJ
 7 LV Write Access read/write
 8 LV Status available
 9 # open 0
10 LV Size 40.00 GB
11 Current LE 10240
12 Segments 2
13 Allocation inherit
14 Read ahead sectors 0
15 Block device 253:0
16 
17 --- Logical volume ---
18 LV Name /dev/fileserver/backup
19 VG Name fileserver
20 LV UUID zZeuKg-Dazh-aZMC-Aa99-KUSt-J6ET-KRe0cD
21 LV Write Access read/write
22 LV Status available
23 # open 0
24 LV Size 5.00 GB
25 Current LE 1280
26 Segments 1
27 Allocation inherit
28 Read ahead sectors 0
29 Block device 253:1
30 
31 --- Logical volume ---
32 LV Name /dev/fileserver/media
33 VG Name fileserver
34 LV UUID usfvrv-BC92-3pFH-2NW0-2N3e-6ERQ-4Sj7YS
35 LV Write Access read/write
36 LV Status available
37 # open 0
38 LV Size 1.00 GB
39 Current LE 256
40 Segments 1
41 Allocation inherit
42 Read ahead sectors 0
43 Block device 253:2
44 
45 
46 lvscan
47 
48 server1:~# lvscan
49 ACTIVE '/dev/fileserver/share' [40.00 GB] inherit
50 ACTIVE '/dev/fileserver/backup' [5.00 GB] inherit
51 ACTIVE '/dev/fileserver/media' [1.00 GB] inherit

 

我们也可以重命名逻辑卷名称

1 lvrename fileserver media films


也可以删除逻辑卷

1 lvremove /dev/fileserver/films
2 
3 server1:~# lvremove /dev/fileserver/films
4 Do you really want to remove active logical volume "films"? [y/n]: <-- y
5 Logical volume "films" successfully removed


然后,再创建

1 lvcreate --name media --size 1G fileserver
2 
3 server1:~# lvcreate --name media --size 1G fileserver
4 Logical volume "media" created

 

扩大大小:

1 lvextend -L1.5G /dev/fileserver/media
2 
3 server1:~# lvextend -L1.5G /dev/fileserver/media
4 Extending logical volume media to 1.50 GB
5 Logical volume media successfully resized

缩小:


1 lvreduce -L1G /dev/fileserver/media
2 server1:~# lvreduce -L1G /dev/fileserver/media
3 WARNING: Reducing active logical volume to 1.00 GB
4 THIS MAY DESTROY YOUR DATA (filesystem etc.)
5 Do you really want to reduce media? [y/n]: <-- y
6 Reducing logical volume media to 1.00 GB
7 Logical volume media successfully resized


看到了吧,这真是孙悟空啊,能大能小。

7.在刚创建的逻辑卷上创建文件系统

  目前为止,我们创建了三个逻辑卷,但都还没有创建文件系统,格式化。在这之前,是无法使用的。于是,我们分别在它们上面创建文件系统。share 为ext3,backup为xfs,media为reiserfs。


第一个:

linux lvs安装 linux安装lvm软件包_逻辑卷

1 mkfs.ext3 /dev/fileserver/share
 2 
 3 server1:~# mkfs.ext3 /dev/fileserver/share
 4 mke2fs 1.40-WIP (14-Nov-2006)
 5 Filesystem label=
 6 OS type: Linux
 7 Block size=4096 (log=2)
 8 Fragment size=4096 (log=2)
 9 5242880 inodes, 10485760 blocks
10 524288 blocks (5.00%) reserved for the super user
11 First data block=0
12 Maximum filesystem blocks=0
13 320 block groups
14 32768 blocks per group, 32768 fragments per group
15 16384 inodes per group
16 Superblock backups stored on blocks:
17 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
18 4096000, 7962624
19 
20 Writing inode tables: done
21 Creating journal (32768 blocks): done
22 Writing superblocks and filesystem accounting information: done
23 
24 This filesystem will be automatically checked every 23 mounts or
25 180 days, whichever comes first. Use tune2fs -c or -i to override.

 

第二个:

linux lvs安装 linux安装lvm软件包_逻辑卷

1 mkfs.xfs /dev/fileserver/backup
 2 
 3 server1:~# mkfs.xfs /dev/fileserver/backup
 4 meta-data=/dev/fileserver/backup isize=256 agcount=8, agsize=163840 blks
 5 = sectsz=512 attr=0
 6 data = bsize=4096 blocks=1310720, imaxpct=25
 7 = sunit=0 swidth=0 blks, unwritten=1
 8 naming =version 2 bsize=4096
 9 log =internal log bsize=4096 blocks=2560, version=1
10 = sectsz=512 sunit=0 blks
11 realtime =none extsz=65536 blocks=0, rtextents=0

 

第三个:

linux lvs安装 linux安装lvm软件包_逻辑卷

1 mkfs.reiserfs /dev/fileserver/media
 2 
 3 server1:~# mkfs.reiserfs /dev/fileserver/media
 4 mkfs.reiserfs 3.6.19 (2003 www.namesys.com)
 5 
 6 A pair of credits:
 7 Alexander Lyamin keeps our hardware running, and was very generous to our
 8 project in many little ways.
 9 
10 Chris Mason wrote the journaling code for V3, which was enormously more useful
11 to users than just waiting until we could create a wandering log filesystem as
12 Hans would have unwisely done without him.
13 Jeff Mahoney optimized the bitmap scanning code for V3, and performed the big
14 endian cleanups.
15 
16 
17 Guessing about desired format.. Kernel 2.6.17-2-486 is running.
18 Format 3.6 with standard journal
19 Count of blocks on the device: 262144
20 Number of blocks consumed by mkreiserfs formatting process: 8219
21 Blocksize: 4096
22 Hash function used to sort names: "r5"
23 Journal Size 8193 blocks (first block 18)
24 Journal Max transaction length 1024
25 inode generation number: 0
26 UUID: 2bebf750-6e05-47b2-99b6-916fa7ea5398
27 ATTENTION: YOU SHOULD REBOOT AFTER FDISK!
28 ALL DATA WILL BE LOST ON '/dev/fileserver/media'!
29 Continue (y/n):y
30 Initializing journal - 0%....20%....40%....60%....80%....100%
31 Syncing..ok
32 
33 Tell your friends to use a kernel based on 2.4.18 or later, and especially not a
34 kernel based on 2.4.9, when you use reiserFS. Have fun.
35 
36 ReiserFS is successfully created on /dev/fileserver/media.

 

 

8.挂载文件系统

    创建文件系统完成后,就该挂载逻辑卷了

linux lvs安装 linux安装lvm软件包_逻辑卷_04

。我将把它们分别挂载share /var/share, backup


/var/backup, media。挂载之前,先创建挂载所需目录:

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

下面挂载:

1 mount /dev/fileserver/share /var/share
2 mount /dev/fileserver/backup /var/backup
3 mount /dev/fileserver/media /var/media

查看挂载的文件系统:

1 server1:~# df -h
 2 Filesystem Size Used Avail Use% Mounted on
 3 /dev/sda2 19G 665M 17G 4% /
 4 tmpfs 78M 0 78M 0% /lib/init/rw
 5 udev 10M 88K 10M 1% /dev
 6 tmpfs 78M 0 78M 0% /dev/shm
 7 /dev/sda1 137M 17M 114M 13% /boot
 8 /dev/mapper/fileserver-share
 9 40G 177M 38G 1% /var/share
10 /dev/mapper/fileserver-backup
11 5.0G 144K 5.0G 1% /var/backup
12 /dev/mapper/fileserver-media
13 1.0G 33M 992M 4% /var/media

这样我们就手动挂载好了。不过,我们还是希望系统能够自动挂载这些。我们可以修改/etc/fstab文件。

首先备份它:

linux lvs安装 linux安装lvm软件包_System_05


sudo cp /etc/fstab /etc/fstab_orig


编辑:

1 sudo vi /etc/fstab
 2 
 3 # /etc/fstab: static file system information.
 4 #
 5 # <file system> <mount point> <type> <options> <dump> <pass>
 6 proc /proc proc defaults 0 0
 7 /dev/sda2 / ext3 defaults,errors=remount-ro 0 1
 8 /dev/sda1 /boot ext3 defaults 0 2
 9 /dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0
10 /dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
11 #在末尾添加如下几行 :em01
12 /dev/fileserver/share /var/share ext3 rw,noatime 0 0
13 /dev/fileserver/backup /var/backup xfs rw,noatime 0 0
14 /dev/fileserver/media /var/media reiserfs rw,noatime 0 0

如果你不建意,重启系统.

linux lvs安装 linux安装lvm软件包_System_05

1 sudo shutdown -r now

然后查看一下挂载了的文件系统,

1 df -h
 2 
 3 server1:~# df -h
 4 Filesystem Size Used Avail Use% Mounted on
 5 /dev/sda2 19G 665M 17G 4% /
 6 tmpfs 78M 0 78M 0% /lib/init/rw
 7 udev 10M 88K 10M 1% /dev
 8 tmpfs 78M 0 78M 0% /dev/shm
 9 /dev/sda1 137M 17M 114M 13% /boot
10 /dev/mapper/fileserver-share
11 40G 177M 38G 1% /var/share
12 /dev/mapper/fileserver-backup
13 5.0G 144K 5.0G 1% /var/backup
14 /dev/mapper/fileserver-media
15 1.0G 33
16 M 992M 4% /var/media