之前服务器硬盘是100g, 因运行时间很长,服务器硬盘不足. 所以新扩容了一个新硬盘
使用宝塔官方的方法也是可以的,.他的做法是把新硬盘挂载到/www下,然后或迁移数据
这样的服务器需要停机,. 而且转移数据过程中可能会出现问题,
需要的话.具体移步这里https://www.bt.cn/bbs/forum.php?mod=viewthread&tid=3187
因为我们挂载的硬盘主要是做备份使用.这样腾出来的空间, 还能继续支持他的运行. 所有我们不停机下进行扩充.安全可靠
[root@~~]# fdisk -l
Disk /dev/vda: 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
一定要记住这个名字.不同代理商可能不一样
[root@~~]# ll /data //确保/data 么有被使用
ls: cannot access /data: No such file or directory
[root@~ ~]# mkdir /data //创建/data
[root@~~]# ll /data
total 0
[root@~ ~]# fdisk /dev/vda //注意: 看清楚这个名字/dev/vda和上面的要相同. 选错了,就会把数据格式掉.
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.
[root@~~]# partprobe /dev/vda //内核重新读取分区表
[root@~~]# fdisk -l //重新查看硬盘. 已经比开始多了一条了
Disk /dev/vda: 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/vda2 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/vda2 //格式化硬盘,.这个/dev/vda2 要和上面显示的相同,一定要注意区分,通关容量和上面的过程,不要把老硬盘格式了
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
[root@~~]# mount /dev/vda2 /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/vda2 394G 73M 374G 1% /data
vi /etc/fstab 也可以用宝塔的文件管理找到文件进行编辑
添加如下内容:
/dev/vda2 /data ext4 defaults 0 0
进入宝塔面板设置,修改为新的目录
当然 ,如果你的网站需要转移的话,也是可以的,. 但是可能需要停机