出于数据保护机制,我们的主机都可以最少划分2块硬盘,一块用来存放用户数据(即网站数据等),一块用来存放系统,这样在您的系统出现问题之后后台选择重装系统,所以在购买VPS之后,要手动将另外一块硬盘挂载到用户数据的目录。这个机制有一个缺点就是存放系统的分区将无法应用于用户数据(网站数据等),所以如果您需要充分利用您的磁盘,您可以挂载磁盘为LVM格式。此教程就是挂载磁盘为LVM格式,这样系统分区的磁盘也可以用来存放网页数据(存放是由系统自动分配),按此方法挂载控制面板重装系统数据会丢失!请注意备份数据!如果你想实现重装系统数据不丢失请查看:Linux VPS 挂载磁盘ext3格式(重装系统数据不丢失)
下面教程开始:
[root@MyVPS ~]# fdisk -l //*查看硬盘分区情况*//
Disk /dev/xvda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 13 104391 83 Linux
/dev/xvda2 14 1044 8281507+ 8e Linux LVM
/dev/xvda3 1045 1305 2096482+ 8e Linux LVM
Disk /dev/xvdb: 7516 MB, 7516192768 bytes
255 heads, 63 sectors/track, 913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdb doesn't contain a valid partition table
[root@MyVPS ~]#df -hal //*查看已划分区空间使用情况*//
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
9.3G 1.2G 7.7G 13% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
/dev/xvda1 99M 29M 66M 31% /boot
tmpfs 151M 0 151M 0% /dev/shm
none 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs
[root@MyVPS ~]#fdisk /dev/xvdb //*对硬盘/dev/xvdb进行增加分区操作*//
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help):n //*输入n新建分区*//
Command action
e extended
p primary partition (1-4)
p //*输入p,主分区*//
Partition number (1-4): 1 //*由于xvdb还没有分区.我们这里输入1.第1个分区*//
First cylinder (1-913, default 1)://*回车跳过*//
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-913, default 913)://*回车跳过*//
Using default value 913
Command (m for help): t //*通过t来指定分区系统格式*//
Selected partition 1
Hex code (type L to list codes):8e //*输入8e LVM系统格式*//
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help):w //*输入w保存退出*//
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@MyVPS ~]#reboot //*重启使之生效*//
Broadcast message from root (pts/0) (Mon Aug 15 00:43:03 2011):
The system is going down for reboot NOW!
[root@MyVPS ~]#
Connection closed by foreign host.
Type `help' to learn how to use Xshell prompt.
Xshell:\