wdcp的/www目录大小调整或增加分区/硬盘的方法

在wdcp及一键安装包里,软件及wdcp都是在安装在/www目录里的默认情况下,/www这个目录也是在根目录下的,除非在安装系统时指定

有的时候,可能根分区空间不够了,可是数据太大,想转到另一个分区或增加一个硬盘分区,那该怎么操作?

如下
假设新增加的硬盘为/dev/sdb
前且已经分好了区并格式化了,为/dev/sdb1

首先,创建一个临时加载点
mkdir /mnt/data
将新分区加载进来,如下
mount /dev/sdb1 /mnt/data

先停止所有的服务
service mysqld stop
service pureftpd stop
service wdapache stop
service httpd stop
service nginxd stop

移动数据
mv /www/* /mnt/data/

卸载新加载的分区
umount /dev/sdb1

然后重新加载到/www目录下,如
mount /dev/sdb1 /www

启动服务
service mysqld start
service pureftpd start
service wdapache start
service httpd start
service nginxd start

到此,就完成了
但还要修改/etc/fstab这个文件,否则重起后,会找不到数据导致错误的发生
在/etc/fstab增加一行,大概如下

/dev/sdb1 /www ext3 defaults 0 0

用命令配置:echo '/dev/sdb1  /www ext3    defaults    0  0' >> /etc/fstab

保存退出,这样再次重起也没问题了

----------------------------------------------

以下是分区和挂载硬盘


1. 添加磁盘,查看磁盘状况


[root@db1 /]# fdisk -l

Disk /dev/sda: 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/sda1 * 151 1305 9277537+ 83 Linux

/dev/sda2 1 150 1204843+ 82 Linux swap

Partition table entries are not in disk order

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System



从查询结果看出,多了一个/dev/sdb的盘



2. 用fdisk 对/dev/sdb 进行分区



[root@db1 /]# fdisk /dev/sdb

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-652, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-652, default 652):

Using default value 652



Command (m for help): w

The partition table has been altered!



Calling ioctl() to re-read partition table.

Syncing disks.



再次查看分区情况,多出来一个/dev/sdb1 的区,这个1是我们在前面指定的,如果我们指定2,就变成 sdb2了。



[root@db1 /]# fdisk -l



Disk /dev/sda: 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/sda1 * 151 1305 9277537+ 83 Linux

/dev/sda2 1 150 1204843+ 82 Linux swap

Partition table entries are not in disk order



Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes



Device Boot Start End Blocks Id System

/dev/sdb1 1 652 5237158+ 83 Linux

[root@db1 /]#



如果创建完之后,/proc/partitions 查看不到对应的分区,使用parprobe 命令刷新一下就可以了:

[root@web1 ~]# cat /proc/partitions
major minor #blocks name


8 0 175825944 sda
8 1 1020096 sda1
8 2 30716280 sda2
8 3 8193150 sda3
[root@web1 ~]# partprobe /dev/sda
[root@web1 ~]# cat /proc/partitions
major minor #blocks name


8 0 175825944 sda
8 1 1020096 sda1
8 2 30716280 sda2
8 3 8193150 sda3
8 4 135893835 sda4
[root@web1 ~]#





3. 格式化 /dev/sdb1 分区



[root@db1 /]# mkfs -t ext3 /dev/sdb1

mke2fs 1.35 (28-Feb-2004)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

655360 inodes, 1309289 blocks

65464 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1342177280

40 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



Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done



This filesystem will be automatically checked every 30 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.



4. 创建目录 并将 /dev/sdb1 挂在到该目录下



[root@db1 /]# ls

backup dev initrd media opt sbin sys usr

bin etc lib misc proc selinux tftpboot var

boot home lost+found mnt root srv tmp

[root@db1 /]# mkdir /u01

[root@db1 /]# ls

backup dev initrd media opt sbin sys u01

bin etc lib misc proc selinux tftpboot usr

boot home lost+found mnt root srv tmp var

[root@db1 /]# mount /dev/sdb1 /u01



5. 验证挂载是否成功

[root@db1 /]# df -k

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda1 9131772 7066884 1601012 82% /

none 454256 0 454256 0% /dev/shm

/dev/sdb1 5154852 43040 4849956 1% /backup



6. 设置开机自动挂载



[root@db1 /]# vi /etc/fstab

# This file is edited by fstab-sync - see 'man fstab-sync' for details

LABEL=/ / ext3 defaults 1 1

none /dev/pts devpts gid=5,mode=620 0 0

none /dev/shm tmpfs defaults 0 0

none /proc proc defaults 0 0

none /sys sysfs defaults 0 0

LABEL=SWAP-sda2 swap swap defaults 0 0

/dev/sdb1 /u01 ext3 defaults 0 0

/dev/hdc /media/cdrom auto pamconsole,exec,noauto,m

anaged 0 0

/dev/fd0 /media/floppy auto pamconsole,exec,noauto,m

anaged 0 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值