首页 > 代码库 > 设备管理

设备管理

修复被删除的磁盘链接文件和更新存储信息。无需重启服务器。

删除/dev/sda后

查看/dev/sd开头的设备:
# ll /dev/sd*
brw-r----- 1 root disk 8, 16 06-12 20:25 /dev/sdb

查看本机磁盘信息:
# fdisk -l

Disk /dev/vda: 10.4 GB, 10485760000 bytes
255 heads, 63 sectors/track, 1274 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1          13      104391   83  Linux
/dev/vda2              14        1274    10128982+  8e  Linux LVM

Disk /dev/sdb: 8589 MB, 8589934592 bytes
64 heads, 32 sectors/track, 8192 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn‘t contain a valid partition table
备注:
只剩下/dev/sdb。容量8GB。

重新扫描/dev/sdb容量:
1、清除/dev/sdb现有信息:
# echo 1 > /sys/block/sdb/device/delete
2、重新扫描/dev/sdb磁盘信息:
# echo "- - -" > /sys/class/scsi_host/host0/scan 
# echo "- - -" > /sys/class/scsi_host/host1/scan 

查看现有磁盘信息:
# fdisk -l

Disk /dev/vda: 10.4 GB, 10485760000 bytes
255 heads, 63 sectors/track, 1274 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1          13      104391   83  Linux
/dev/vda2              14        1274    10128982+  8e  Linux LVM

Disk /dev/sdb: 12.8 GB, 12884901888 bytes
64 heads, 32 sectors/track, 12288 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn‘t contain a valid partition table
备注:磁盘/dev/sdb信息已经更新。

=========================================================================
创建被删除的/dev/sda设备链接:
# /dev/MAKEDEV sda

查看现有磁盘信息:
# fdisk -l

Disk /dev/vda: 10.4 GB, 10485760000 bytes
255 heads, 63 sectors/track, 1274 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1          13      104391   83  Linux
/dev/vda2              14        1274    10128982+  8e  Linux LVM

Disk /dev/sda: 8589 MB, 8589934592 bytes
64 heads, 32 sectors/track, 8192 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sda doesn‘t contain a valid partition table

Disk /dev/sdb: 12.8 GB, 12884901888 bytes
64 heads, 32 sectors/track, 12288 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn‘t contain a valid partition table
备注:磁盘/dev/sda已经恢复,但是容量错误。

重新扫描/dev/sda信息:
1、清除/dev/sdb现有信息:
# echo 1 > /sys/block/sda/device/delete
2、重新扫描/dev/sdb磁盘信息:
# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "- - -" > /sys/class/scsi_host/host1/scan

结果:
修复成功:
# fdisk -l

Disk /dev/vda: 10.4 GB, 10485760000 bytes
255 heads, 63 sectors/track, 1274 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1          13      104391   83  Linux
/dev/vda2              14        1274    10128982+  8e  Linux LVM

Disk /dev/sdb: 12.8 GB, 12884901888 bytes
64 heads, 32 sectors/track, 12288 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn‘t contain a valid partition table

Disk /dev/sda: 12.8 GB, 12884901888 bytes
64 heads, 32 sectors/track, 12288 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sda doesn‘t contain a valid partition table

====================================================================

 使用下列命令后,除了生成需要的/dev/sda外还生成大量其它以sda开头的文件:
        # /dev/MAKEDEV sda
    使用下列命令删除无用设备链接文件:
        # rm -f `ls /dev/sda*|grep -v "sda$"`


本文出自 “滴水穿石” 博客,请务必保留此出处http://4735839.blog.51cto.com/4725839/1426917