客户有一个新的磁盘需要挂载到服务器,作为数据盘是非常重要的。服务器基于宝塔搭建的一个管理端,腾讯服务器自动挂载到了服务器(没有实际mount),在宝塔没有显示数据盘,只有50G的系统盘,这时候需要用mount 命令挂载磁盘,当然用宝塔的脚本更方便,可以转移数据到新的磁盘。
命令(centos系统):
yum install wget -y && wget -O auto_disk.sh http://download.bt.cn/tools/auto_disk.sh && bash auto_disk.sh
上面的命令可以自动挂载并迁移数据到数据盘哦。
操作过程:
yum install wget -y && wget -O auto_disk.sh http://download.bt.cn/tools/auto_disk.sh && bash auto_disk.sh #这里省略下载执行过程 #确认是否要挂载到这个目录下面 Do you want to try to mount the data disk to the /www directory?(y/n): y stop bt-service 停止宝塔服务 Stopping Bt-Tasks... done Stopping Bt-Panel... done disk partition... 磁盘分区... Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x716b411b. Command (m for help): Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): Partition number (1-4, default 1): First sector (2048-209715199, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): Using default value 209715199 Partition 1 of type Linux and of size 100 GiB is set Command (m for help): The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 6553600 inodes, 26214144 blocks 1310707 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2174746624 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 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done Filesystem Size Used Avail Use% Mounted on devtmpfs 1.9G 8.0K 1.9G 1% /dev tmpfs 1.9G 24K 1.9G 1% /dev/shm tmpfs 1.9G 708K 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/vda1 50G 13G 35G 28% / tmpfs 379M 0 379M 0% /run/user/0 /dev/vdb1 99G 61M 94G 1% /www move disk... 迁移数据中... Done 迁移完成 start bt-service 启动宝塔服务 Starting Bt-Panel.... done Starting Bt-Tasks... done You have new mail in /var/spool/mail/root
结果用df -h查看一下:
Filesystem Size Used Avail Use% Mounted on devtmpfs 1.9G 8.0K 1.9G 1% /dev tmpfs 1.9G 24K 1.9G 1% /dev/shm tmpfs 1.9G 712K 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/vda1 50G 13G 35G 28% / #原来的系统盘 tmpfs 379M 0 379M 0% /run/user/0 /dev/vdb1 99G 4.7G 89G 6% /www #新挂载的数据盘
宝塔也显示了数据盘:
提示:如果想要挂载到其他盘的可以修改auto_disk.sh里开始的setup_path变量值:
#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH LANG=en_US.UTF-8 setup_path=/www #这个可以修改挂载位置哦