宝塔服务器新购买硬盘,挂载操作流程

一 前言

之前服务器硬盘是100g, 因运行时间很长,服务器硬盘不足. 所以新扩容了一个新硬盘

使用宝塔官方的方法也是可以的,.他的做法是把新硬盘挂载到/www下,然后或迁移数据

这样的服务器需要停机,. 而且转移数据过程中可能会出现问题, 

需要的话.具体移步这里BT-Panel Linux自动磁盘挂载工具1.8(2020/1/17更新) - Linux面板 - 宝塔面板论坛


+----------------------------------------------------------------------
| Bt-WebPanel Automatic disk partitioning tool
+----------------------------------------------------------------------
| Copyright © 2015-2017 BT-SOFT(http://www.bt.cn) All rights reserved.
+----------------------------------------------------------------------
| Auto mount partition disk to /www
+----------------------------------------------------------------------

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 0xb15c8b22.

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-629145599, default 2048): Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599): Using default value 629145599
Partition 1 of type Linux and of size 300 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
19660800 inodes, 78642944 blocks
3932147 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2227175424
2400 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, 71663616

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     0  1.9G   0% /dev
tmpfs           1.9G  4.0K  1.9G   1% /dev/shm
tmpfs           1.9G  468K  1.9G   1% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/vda1        99G  3.2G   91G   4% /
tmpfs           379M     0  379M   0% /run/user/0
/dev/vdb1       296G   65M  281G   1% /www

move disk...
迁移数据中...

Done
迁移完成

start bt-service
启动宝塔服务

Starting Bt-Panel....	done
Starting Bt-Tasks... 	done

因为我们挂载的硬盘主要是做备份使用.这样腾出来的空间, 还能继续支持他的运行. 所有我们不停机下进行扩充.安全可靠

二 手动挂载

1 查看有没有新硬盘

[root@~~]# fdisk -l

Disk /dev/vdb: 536.9 GB, 536870912000 bytes, 1048576000 sectors

Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000d2717

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1   *        2048   209713151   104855552   83  Linux
 

一定要记住这个名字.不同代理商可能不一样

2 创建要挂载的目录. 这样使用/data

[root@~~]# ll /data                                         //确保/data 么有被使用
ls: cannot access /data: No such file or directory
[root@~ ~]# mkdir /data                                  //创建/data 
[root@~~]# ll /data 
total 0

3 格式化硬盘

[root@~ ~]# fdisk /dev/vdb           //注意: 看清楚这个名字/dev/vdb和上面的要相同. 选错了,就会把数据格式掉.
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.


Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
 

Command (m for help): n        //创建新的
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p          //主分区. 如果么有特殊需要不要选扩展.选了扩展还要创建逻辑,很麻烦,这个主分区也不会把启动弄坏
Partition number (2-4, default 2): 回车
First sector (209713152-1048575999, default 209713152): 回车
Using default value 209713152
Last sector, +sectors or +size{K,M,G} (209713152-1048575999, default 1048575999): 回车
Using default value 1048575999
Partition 2 of type Linux and of size 400 GiB is set

Command (m for help): w               //上面的设置进行写入
The partition table has been altered!

Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
 

4 重新读取分区表

[root@~~]# partprobe /dev/vdb     //内核重新读取分区表

5 格式化硬盘

[root@~~]# fdisk -l         (结尾不能有空格)     //重新查看硬盘. 已经比开始多了一条了

Disk /dev/vdb: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000d2717

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   209713151   104855552   83  Linux
/dev/vdb1       209713152  1048575999   419431424   83  Linux

有时候会是这样的提示,如果第一步 查看有没有新硬盘 时看到的硬盘是/dev/vdb . 这里就会出现vdb1

Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bb76b

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   209715166   104856559+  83  Linux

Disk /dev/vdb: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x1d183c07

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048  1048575999   524286976   83  Linux


[root@~ ~]# mkfs.ext4 /dev/vdb1     //格式化硬盘,.这个/dev/vdb1     要和上面显示的相同,一定要注意区分,通过容量和上面的过程,不要把老硬盘格式了
mke2fs 1.42.9 (28-Dec-2013)
warning: 256 blocks unused.

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done     

6 挂载硬盘


[root@~~]# mount /dev/vdb1 /data     //注意分区和目录
[root@~~]# ll /data 
total 16
[root@~~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G  1.9M  3.9G   1% /dev/shm
tmpfs           3.9G  568K  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/vda1        99G   66G   28G  71% /
tmpfs           783M     0  783M   0% /run/user/1002
tmpfs           783M     0  783M   0% /run/user/0
/dev/vdb1       394G   73M  374G   1% /data 

7 实现自动挂载

 vi /etc/fstab  也可以用宝塔的文件管理找到文件进行编辑

 添加如下内容:

UUID=3d682a67-edb8-4ac7-ba8b-594f9d146fb6 /                       ext4    defaults        1 1

 /dev/vdb1 /data ext4 defaults 0 0

保存之后再次打开, 确认一下是否正确 防止有?这些乱码

三 宝塔操作备份路径

进入宝塔面板设置,修改为新的目录

当然 ,如果你的网站需要转移的话,也是可以的,. 但是可能需要停机

文件快速复制的命令

rsync -avh 原路径 目标  #这里不要加z参数 因为z要压缩.所以会很慢


 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值