教程#Linux VPS 挂载磁盘LVM格式#充分利用磁盘#
![]() | ![]() | ![]() | ![]() |
| 【性价之王】 | 【线路之王】 | 【价格之王】 | 【配置之王】 |
| 【免费之王】 | 【香港首推】 | 【梯子之王】 | 【独服之王】 |

目前很多VPS或者云主机出于数据保护机制,主机都可以最少划分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
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 //
Command action
e extended
p primary partition (1-4)
Partition number (1-4): 1 //
First cylinder (1-913, default 1)://
Using default value 1
Using default value 913
Selected partition 1
Changed system type of partition 1 to 8e (Linux LVM)
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
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:\>
Connecting to :22…
Connection established.
Escape character is ‘^@]’.
Last login: Mon Aug 15 00:41:06 2011 from
[root@MyVPS1280 ~]#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
Device Boot Start End Blocks Id System
/dev/xvdb1 1 913 7333641 8e Linux LVM
Physical volume “/dev/xvdb1” successfully created
Volume group “VolGroup00” successfully extended
— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 16.81 GB
PE Size 32.00 MB
Total PE 538
Alloc PE / Size 315 / 9.84 GB
Free PE / Size 223 / 6.97 GB
VG UUID ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI
Extending logical volume LogVol00 to 15.59 GB
Logical volume LogVol00 successfully resized
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4087808 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 4087808 blocks long.
— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 16.81 GB
PE Size 32.00 MB
Total PE 538
Alloc PE / Size 507 / 15.84 GB
Free PE / Size 31 / 992.00 MB
VG UUID ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI
Extending logical volume LogVol00 to 16.56 GB
Logical volume LogVol00 successfully resized
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4341760 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 4341760 blocks long.
— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 16.81 GB
PE Size 32.00 MB
Total PE 538
Alloc PE / Size 538 / 16.81 GB
Free PE / Size 0 / 0
VG UUID ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
17G 1.2G 15G 8% /
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
注意事项:
1.教程所用主机为CentOS系统,不同Linux、不同服务器的VPS的卷标(本教程中那个的VolGroup00-LogVol00)可能不同,使用df -hal命令可以查看卷标。
2.如果你使用的不是基本套餐或者你的硬盘不是15G,那么你两次操作需要增加的容量要以你vgdisplay所看到的为准,(vgidsplay里面的Free PE/Size显示的就是可扩容容量)。我们只所以分两次扩容是由于1024的进制差别造成的,我们所实际看到的容量6.97G并不能直接一次扩容,所以我们可以先扩容整数部分,然后扩容以M为单位的部分。
3.系统重装后的重装扩展处理(仅格式化系统盘)
系统重装后,直接执行resize2fs进行动态扩容即可
resize2fs /dev/VolGroup2011/LogVol00
4.PVs missing导致LVM无法重新扩容的解决办法
运行vgextend/vgdisplay返回错误:
Couldn’t find device with uuid ************************
Cannot change VG VolGroup2011 while PVs are missing.
此时可以运行:
vgreduce VolGroup2011 –removemissing
然后重新扩容LVM即可
猜你可能想看的VPS
- JQuery 获取 select 选中 option 的索引全球[VPS测评]
- Laravel 报错 Call to undefined functio全球[VPS测评]
- 促销 数脉科技→香港双向 CN2 服务器低至 4 折 E3-1230v2香港VPS[主机]
- 优惠 野草云双十二优惠→香港三网直连云服务器 19 元起 适合做站香港VPS[主机]
- ThinkPHP 高危安全漏洞 攻击者可直接获取服务器权限 请尽快升级官全球[VPS测评]
- 新人首单 0 元购 APP 这几个首单都是免费全球[VPS测评]
- Dell 笔记本开机提示→The AC power adapter wa全球[VPS测评]
- ThinkPHP5 扩展配置目录 extra 中自定义配置文件的管理方法全球[VPS测评]
- PacificRack 便宜美国 vps 五月特惠,洛杉矶 QN 机房,美国VPS[主机]
- Win10 访问共享时出现错误代码 0x80070035 是怎么回事?全球[VPS测评]
- RackNerd三月特惠 Intel SSD VPS $9.49起/年;全球[VPS测评]
- 恒星云国内高防优惠辽宁高防 2H2G 5M小带宽 月付35元 带20G防全球[VPS测评]
- WordPress插件:Autoptimize 插件优化版 整合并压缩C全球[VPS测评]
- 2020年双十一 各大云服务商VPS/服务器/域名促销活动汇总全球[VPS测评]
- CloudCone 512M 内存 10G HDD 500G流量 洛杉矶全球[VPS测评]
- DMIT.IO 香港VPS HKG.Pro系列香港VPS[主机]
- 快车道 新用户-季付65折-半年付6折优惠 圣何塞-德国GIA全球[VPS测评]
- 中概股扫描网传拼多多正筹备跨境电商平台首站登陆美国美国VPS[主机]
- 者也IO,香港日本美国云服务器促销,2核2G1000元/2年,7折+内存日本VPS[主机]
- 快速云:云计算分类和云计算的特点全球[VPS测评]
- 云服务器能干什么?有几十种玩法?阿里云,腾讯云服务器如何购买?全球[VPS测评]
- 磐逸云怎么样?1核1G香港安畅CN2 VPS带宽5M年付128元香港VPS[主机]
- 什么是IconFont ?iconfont 的使用和解析全球[VPS测评]
- edgeNAT双十二:韩国VPS/美国CN2/香港CN2VPS主机,月付韩国VPS[主机]
- 腾讯云香港/韩国/日本免备案服务器优惠促销活动日本VPS[主机]
- 影速科技怎么样?影速科技海外云服务器价格多少钱?全球[VPS测评]
- 热网互联:日本+香港 cn2 gia vps7折,日本服务器7.5折,全日本VPS[主机]
- 蓝米云:美国cera vps/香港cn2vps套餐,1核2G/40G/1美国VPS[主机]
- 腾讯云vps主机:288元/3年,1核/2G/50gSSD,北京/上海/美国VPS[主机]
- 拼多多也要做跨境电商?出海之路能一帆风顺吗,了解一下全球[VPS测评]
转载请注明原文地址:http://140.238.13.167:12355/read-78168.html











