折雨的天空

新浪微薄腾讯微薄

最新碎语:最近霉到了住。哎。。。

您的位置:折雨的天空 >其他技术> 不同的VPS存储不同的问题

不同的VPS存储不同的问题

之前买了两个VPS,均是国外的VPS,硬盘只有一块,买到后装完系统直接配置lnmp就行了。

可是今天一个VPS居然是两块硬盘,按照之前的步骤就遇到问题了。

数据盘20G,没有,系统盘10G快用光了,不得不找方法,结果google又被屏蔽了,只好用360搜了下。


按照以下步骤,挂载未分区的那块盘


通过fdisk -l我们可以看到/dev/xvdb(此名称因系统而异)容量有23.6G,
而且没有分区,接下来我们对它进行分区和挂载
fdisk -l

[root@MyVPS ~]# fdisk -l
Disk /dev/xvda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 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

Disk /dev/xvdb: 23.6 GB, 23622320128 bytes
255 heads, 63 sectors/track, 2871 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System

对/dev/xvdb(此名称因系统而异)进行分区:
fdisk /dev/xvdb

[root@MyVPS ~]# fdisk /dev/xvdb(开始执行命令)
The number of cylinders for this disk is set to 2871.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

输入n新建分区
Command (m for help): n(直接输入n回车)
Command action
   e   extended
   p   primary partition (1-4)
p(这里输入P 回车)

/dev/xvdb中第1个分区
Partition number (1-4): 1(输入1回车)
First cylinder (1-2871, default 1):(回车)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2871, default 2871):(回车键)
Using default value 2871

输入W保存退出
Command (m for help): w(输入W回车保存)
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

将新分区xvdb1(此名称因系统而异)格式化为ext3格式mkfs -t ext3 /dev/xvdb1

[root@MyVPS ~]# mkfs -t ext3 /dev/xvdb1(必须执行这个命令将分区格式化)
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2883584 inodes, 5765319 blocks
288265 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
176 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

我们示范将新分区xvdb1挂载到目录/home
因为home已经存在,所以我们挂载
mount /dev/xvdb1 /home(这个命令必须执行,不然无法挂载成功)
如果你需要挂载在别的目录.可以新建一个目录挂载.如:home1,使用如下命令:
mkdir /home1 mount /dev/xvdb1 /home1(这个是根据你的需求扩展命令)
完成后我们通过df -hal可以看到,新分区已经挂载到目录/home上了

    [root@MyVPS ~]# df -hal (执行命令检查是否挂载成功)
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup00-LogVol00
                          5.7G  1.4G  4.1G  25% /
    proc                     0     0     0   -  /proc
    sysfs                    0     0     0   -  /sys
    devpts                   0     0     0   -  /dev/pts
    /dev/xvda1             99M   28M   67M  30% /boot
    tmpfs                 256M     0  256M   0% /dev/shm
    none                     0     0     0   -  /proc/sys/fs/binfmt_misc
    sunrpc                   0     0     0   -  /var/lib/nfs/rpc_pipefs
    /dev/xvdb1             22G  173M   21G   1% /home

最后添加开机自动挂载: echo "/dev/xvdb1 /home ext3 defaults 1 2" >> /etc/fstab(必执行命令,开机后自动挂载)
这样就完成了!
通过后台控制系统重做系统之后,只需要重新挂载一次即可
mount /dev/xvdb1 /home
最后,重新添加自动挂载即可:
echo "/dev/xvdb1 /home ext3 defaults 1 2" >> /etc/fstab


原文地址:http://www.b7.net.cn/post/8.html



然后又遇到问题了,我之前安lnmp的时候没有挂载数据盘,安完后,lnmp的东西都放在home目录下,挂载数据盘上去以后,原来的东西就丢了,网站都打不开了,于是有只有找取消挂载的方法

命令:


umount /dev/svdb1


结果又遇到问题,问题是:


umount: /home: device is busy


再找答案


执行命令:


fuser -km /home

再次unmount成功,赶忙把home下的数据考到其他目录,然后重新挂载,挂载后从其他目录拷贝进刚挂载的数据盘,重新启动,好了一切都好了。。

------------正 文 已 结 束, 感 谢 您 的 阅 读 (折雨的天空)--------------------

转载请注明本文标题和链接:《不同的VPS存储不同的问题

奖励一下

取消

分享不易,烦请有多多打赏,如您也困难,点击右边关闭即可!

扫码支持
扫码打赏,5元,10元,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

-秒后自动关闭,如已打赏,或者不愿打赏,请点击右上角关闭图标。

发表评论

路人甲 表情
看不清楚?点图切换