1.查看要挂载的空间
[root@iZuf6610s5jsqm9fr53nslZ ~]# fdisk -l
Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00053156
Device Boot Start End Blocks Id System
/dev/vda1 * 1 5222 41942016 83 Linux
Disk /dev/vdb: 107.4 GB, 107374182400 bytes
16 heads, 63 sectors/track, 208050 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
2.添加分区
[root@iZuf6610s5jsqm9fr53nslZ ~]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x65cce73f.
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)
WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).
Command (m for help): n
Command action
e extended
p primary partition (1-4)
1
Invalid partition number for type `1’
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-208050, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-208050, default 208050):
Using default value 208050
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
fdisk 对应分区 相继输入 n, p, 1, wq
3.查看当前分区情况
[root@iZuf6610s5jsqm9fr53nslZ ~]# fdisk -l
Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00053156
Device Boot Start End Blocks Id System
/dev/vda1 * 1 5222 41942016 83 Linux
Disk /dev/vdb: 107.4 GB, 107374182400 bytes
16 heads, 63 sectors/track, 208050 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x65cce73f
Device Boot Start End Blocks Id System
/dev/vdb1 1 208050 104857168+ 83 Linux
4.格式化分区
[root@iZuf6610s5jsqm9fr53nslZ ~]# mkfs.ext3 /dev/vdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214292 blocks
1310714 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
5.挂载硬盘
#创建要挂载的目录
mkdir /data
#挂载分区
mount /dev/vdb1 /data/
#写入分区信息
echo “/dev/vdb1 /data ext3 defaults 0 0” >> /etc/fstab
#查看分许信息
cat /etc/fstab
最后挂载完成后如果需要迁移数据–>
第一步:进入data目录(data是数据盘名称,有很多是home,你的数据盘名称是什么就用那么名称替换data就好)
cd /data
第二步:创建宝塔面板安装需要用的www目录
mkdir www
第三步:建立/data/www的软连接到/www(也就是给系统根目录建立一个www的“快捷方式”指向/data/www)
ln -s /data/www /www
第四步:正常安装宝塔面板即可
如果已经安装了宝塔面板和WEB环境,连接终端输入命令:
第一步:移动系统根目录下的www到data
mv /www /data/www
第二步:建立/data/www的软连接到/www
ln -s /data/www /www
第三步:重启服务器
reboot
第四步:重启宝塔面板服务
service bt restart
第五步:打开宝塔面板,CTRL+F5刷新浏览器缓存
(PS:Linux下的软链接类似于windows下的快捷方式 ,如上面的示例,当我们执行命令 cd /www/的时候 实际上是进入了 /data/ ,操作前切记备份数据,防止因误操作引起数据丢失!!!)