openstack热添加磁盘

假定在虚拟机当中添加了磁盘,但是虚拟机没有识别出来;如何识别出来

可以使用命令

echo '- - -' >/sys/class/scsi_host/host0/scan

使用后就可以识别出来了

 

 

###增加两块硬盘 默认是不会识别

 

[root@compute1 ~]# fdisk -l

 

Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x0009fb23

 

Device Boot Start End Blocks Id System

/dev/sda1 2048 4196351 2097152 82 Linux swap / Solaris

/dev/sda2 * 4196352 104857599 50330624 83 Linux

 

 

 

#scsi是内核参数

echo '- - -' >/sys/class/scsi_host/host0/scan

[root@compute1 ~]# fdisk -l

 

Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x0009fb23

 

Device Boot Start End Blocks Id System

/dev/sda1 2048 4196351 2097152 82 Linux swap / Solaris

/dev/sda2 * 4196352 104857599 50330624 83 Linux

 

Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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 /dev/sdc: 6442 MB, 6442450944 bytes, 12582912 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

 

 

 

#进行格式化

mkfs.ext4 /dev/sdb

 

#将指定目录进行挂载

mount /dev/sdb / ceshi

mount /dev/mapper/vgdata-lvdata1 /data1 将目录/data1 挂载到/dev/mapper/vgdata-lvdata1

 

umount 参数

umount /data1

umount -lf /data1 强制卸载

Options:

-a, --all unmount all filesystems

-A, --all-targets unmount all mountpoins for the given device

in the current namespace

-c, --no-canonicalize don't canonicalize paths

-d, --detach-loop if mounted loop device, also free this loop device

--fake dry run; skip the umount(2) syscall

-f, --force force unmount (in case of an unreachable NFS system)

-i, --internal-only don't call the umount.<type> helpers

-n, --no-mtab don't write to /etc/mtab

-l, --lazy detach the filesystem now, and cleanup all later

-O, --test-opts <list> limit the set of filesystems (use with -a)

-R, --recursive recursively unmount a target with all its children

-r, --read-only In case unmounting fails, try to remount read-only

-t, --types <list> limit the set of filesystem types

-v, --verbose say what is being done

 

-h, --help display this help and exit

-V, --version output version information and exit

 

For more details see umount(8).

原文地址:https://www.cnblogs.com/nodchen/p/9522013.html