起因

VPS上mysql突然拒绝服务了,SSH上去检查一下发现是用户上传大量图片,导致磁盘空间满了。
联系IDC,给增加了一块硬盘,嗯,这下空间足够了。

启用新硬盘

使用 fdisk -l 查看新增的硬盘

Disk /dev/sdb: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x1d2d511e

使用 fdisk /dev/sdb 创建分区,然后格式化

mkfs.ext4 /dev/sdb1 #就分了一个区

同步数据


mount /mnt/sdb1 /dev/sdb1   #挂载分区
mkdir /mnt/sdb1/upload
rsync -azvP /data/wwwroot/upload/ /mnt/sdb1/upload/ #数据同步
ln -s /mnt/sdb1/upload/ /data/wwwroot/upload/ #软连接过去

小问题

软连接特殊处理

du -shL DIR
rsync -azvPl SRC TAR

使用中发现vsftpd不支持软连接,改用mount

mount --bind /mnt/sdb1/upload /data/wwwroot/upload/

这样就可以解决vsftpd的问题了

如何在不重启的情况下检测新硬盘

[root@localhost ~]# ll /sys/class/scsi_host/
lrwxrwxrwx  1 root root 0 2017-08-22 00:43:19 host0 -> ../../devices/pci0000:00/0000:00:10.0/host0/scsi_host/host0
lrwxrwxrwx  1 root root 0 2017-08-22 00:43:19 host1 -> ../../devices/pci0000:00/0000:00:07.1/host1/scsi_host/host1
lrwxrwxrwx  1 root root 0 2017-08-22 00:43:19 host2 -> ../../devices/pci0000:00/0000:00:07.1/host2/scsi_host/host2
[root@localhost ~]# echo "- - -" > /sys/class/scsi_host/host0/scan #立即扫描scsi_host0
[root@localhost ~]# echo "- - -" > /sys/class/scsi_host/host1/scan #立即扫描scsi_host1
[root@localhost ~]# echo "- - -" > /sys/class/scsi_host/host2/scan #立即扫描scsi_host2

[root@localhost ~]# fdisk -l

Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x000078ed

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         128     1024000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             128        2168    16384000   82  Linux swap / Solaris
/dev/sda3            2168        7833    45505536   83  Linux

Disk /dev/sdb: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x1d2d511e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        7832    62910508+  83  Linux

Disk /dev/sdc: 1073.7 GB, 1073741824000 bytes
255 heads, 63 sectors/track, 130541 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: 0x3fb96501
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1      130541  1048569558+  83  Linux

这样就能看到新增的第三块硬盘了

Logo

更多推荐