宝塔面板 bt.cn CentOS6.x/7.x系统盘迁移到数据盘操作方法

2023-05-06 04:38:07

 

(此处已添加小程序,请到今日头条客户端查看)

最近操作了几个宝塔面板系统盘迁移到数据盘的项目,找了好多网上的教程,发现大部分写的比较片面,今天特意整理了一下操作方案,经验分享给大家~

首先要明确以下几个步骤:

第一步 格式化数据盘、挂载磁盘

第二步 移动系统盘宝塔数据到新挂载的数据盘

第三步 将新挂载的磁盘目录链接到www

第四步 重新启动服务器后重启面板

(所有操作全部在命令行操作,请提前简单学习linux命令行操作)

第一步 格式化数据盘并挂载磁盘

通常在增加磁盘或新系统,必不可少的就是格式化磁盘,分区,挂载分区。使用过阿里ECS的朋友都知道,数据盘是需要自己分区并挂载的,对于新手确实是个难题,特记之,以供参考!

(1)先使用 df -lh 命令查看 ,发现系统只有系统盘。

(2)使用 fdisk -l 查看磁盘情况,从下图可看到 有一个磁盘未分区,并记住为分区的 标识,我们这里是 /dev/vdb:

(3)执行 fdisk /dev/vdb 对磁盘分区,需要依次输入 "n","p","1"(注意:这里一般是写1 看要分几个区),两次回车,"w":

[root@iZtl9h0eoqfyy7Z ~]# fdisk -l

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x590ca8b1.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content wont be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. Its 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)

p

Partition number (1-4): 1First cylinder (1-39162, default 1):

Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-39162, default 39162):

Using default value 39162Command (m for help): p

Disk /dev/vdb: 322.1 GB, 322122547200 bytes255 heads, 63 sectors/track, 39162 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: 0x590ca8b1Device Boot Start End Blocks Id System/dev/xvde1 1 39162 314568733+ 83 Linux

Command (m for help): w

The partition table has been altered!Calling ioctl() to re-read partition table.

Syncing disks.

(4) 创建分区 命令: mkfs.ext4 /dev/vdb1 (相当于win的格式化)

[root@iZtl9h0eoqfyy7Z ~]# mkfs.ext4 /dev/vdb1

mke2fs 1.41.12 (17-May-2010)

Could not stat vdb1 --- No such file or directory

The device apparently does not exist; did you specify it correctly?[root@qxyw ~]# mkfs.ext4 /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 blocks19660800 inodes, 78642183 blocks3932109 blocks (5.00%) reserved for the super user

First data block=0Maximum filesystem blocks=4294967296

2400 block groups32768 blocks per group, 32768 fragments per group8192 inodes per group

Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.

(5)根目录新建文件夹 命令: mkdir /mydata ,然后使用命令 mount /dev/vdb1 /mydata 将/dev/vdb1 挂载到mydata文件夹。

[root@iZtl9h0eoqfyy7Z ~]# mount /dev/vdb1 /mydata

[root@iZtl9h0eoqfyy7Z ~]# df -h

复制

(6)mount直接挂载,一旦系统重新启动就会失效,所以要设置系统启动自动挂载。命令: echo "/dev/vdb1 /mydata ext4 defaults 0 0" >>/etc/fstab

[root@iZtl9h0eoqfyy7Z ~]# echo "/dev/vdb1 /mydata ext4 defaults 0 0" >>/etc/fstab

[root@iZtl9h0eoqfyy7Z ~]#

复制

使用命令 mount -a 查看是否有错误。注意:要是有错误,可以通过vim /etc/fstab编辑挂载表。

第二步 移动系统盘宝塔数据到新挂载的数据盘

(1)先通过命令: /etc/init.d/bt stop 停止宝塔。

[root@iZtl9h0eoqfyy7Z ~]# /etc/init.d/bt stop

Stopping Bt-Tasks... done

Stopping Bt-Panel... done

Stoping nginx... done

Shutting down MySQL.. SUCCESS!

Stopping Pure-FTPd... Pure-FTPd is not running.Gracefully shutting down php-fpm warning, no pid file found - php-fpm is not running ?

Gracefully shutting down php-fpm . done

复制

(2)通过命令: mv /www /mydata 将宝塔数据移动到自定义文件夹。

注意:移动时间是根据你数据的大小来定的,在移动过程中不要操作。

[root@iZtl9h0eoqfyy7Z ~]# mv /www /mydata

[root@iZtl9h0eoqfyy7Z ~]#

复制

第三步 将新挂载的磁盘目录链接到www

(1)删除/www文件夹 通过命令: rm -rf /www 实现。 删除文件夹 可能性的会出现2个问题,第一是宝塔默认的swap交换分区删除不了 可以通过命令 swapoff swap 来关闭swap , 然后再执行rm swap命令删除这个文件,第二个可能性问题就是部分文件可能权限不够删除不了 如:.user.ini 可以通过命令 chattr -i

/wwww/wwwroot/yoursite/.user.ini 来提权,再执行rm命令删除文件。

(2)删除www文件夹后,通过命令 ln -s /mydata/www /www 将/mydata/www 链接到 /www 文件夹。

[root@iZtl9h0eoqfyy7Z ~]# ln -s /mydata/www /www

[root@iZtl9h0eoqfyy7Z ~]#

复制

第四步 重新启动服务器后重启面板

首先重新启动服务器,再次连接后 执行命令: /etc/init.d/bt restart 重新启动宝塔面板。

[root@localhost ~]# /etc/init.d/bt restart

Starting Bt-Panel... done

Starting Bt-Tasks... done

Starting nginx... done

Starting MySQL.. SUCCESS!

复制

自此 迁移完成!!!


以上就是关于《宝塔面板 bt.cn CentOS6.x/7.x系统盘迁移到数据盘操作方法》的全部内容,本文网址:https://www.7ca.cn/baike/22898.shtml,如对您有帮助可以分享给好友,谢谢。
标签:
声明

排行榜