jackyzm

导航

xenserver添加磁盘后挂载为本地存储库并且删除

方法一:

  1.1:查看磁盘列表

    fdisk -l

[root@xenserver ~]# fdisk -l

Disk /dev/sdb: 7999.4 GB, 7999376588800 bytes, 15623782400 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1  4294967295  2147483647+  ee  GPT

Disk /dev/sda: 2000.4 GB, 2000398934016 bytes, 3907029168 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/mapper/VG_XenStorage--342bacfc--f135--104c--bd2b--9963ffa9b0bb-MGT: 4 MB, 4194304 bytes, 8192 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

 

  df -h

[root@xenserver ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 2.0G     0  2.0G   0% /dev
tmpfs                    2.0G  120K  2.0G   1% /dev/shm
tmpfs                    2.0G  1.5M  2.0G   1% /run
tmpfs                    2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/sdb1                 18G  2.1G   15G  13% /
xenstore                 2.0G     0  2.0G   0% /var/lib/xenstored
/dev/loop0                45M   45M     0 100% /var/xen/xc-install
/dev/sdb5                3.9G  247M  3.4G   7% /var/log
/dev/sda                 1.8T   77M  1.7T   1% /data
10.18.18.18:/nfs/iso   18G  8.9G  7.9G  53% /run/sr-mount/a3ab3cfb-645d-54a0-9c49-9462bd66a7c3
tmpfs                    393M     0  393M   0% /run/user/0

 

  1.2:主机列表

    xe host-list

[root@xenserver~]# xe host-list
uuid ( RO)                : 03c38c30-f4f7-4cb7-ad5f-963c9f604e23
          name-label ( RW): xenserver-hk-01
    name-description ( RW): Default install


uuid ( RO)                : 3befa5af-c1dd-4b94-b299-09c27458cd59
          name-label ( RW): xenserver-hk-02
    name-description ( RW): Default install

 

  1.3:新建本地存储仓库

    xe sr-create host-uuid=3befa5af-c1dd-4b94-b299-09e27458cd59 content-type=user type=lvm device-config:device=/dev/sda shared=false name-label="Local storage 2"

[root@xenserver ~]# xe sr-create host-uuid=3befa5af-c1dd-4b94-b299-09e27458cd59 content-type=user type=lvm device-config:device=/dev/sda shared=false name-label="Local storage 2"
-bash: $'xe\342\200\202sr-create\342\200\202host-uuid=3befa5af-c1dd-4b94-b299-09e27458cd59': command not found

 

方法二:

  2.1:查看磁盘路径:

    ls -l /dev/disk/by-path/

[root@xenserver ~]# ls -l /dev/disk/by-path/
total 0
lrwxrwxrwx 1 root root  9 Feb 26 16:53 pci-0000:02:00.0-scsi-0:0:5:0 -> ../../sda
lrwxrwxrwx 1 root root  9 Feb 26 16:23 pci-0000:02:00.0-scsi-0:2:0:0 -> ../../sdb
lrwxrwxrwx 1 root root 10 Feb 26 16:23 pci-0000:02:00.0-scsi-0:2:0:0-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Feb 26 16:23 pci-0000:02:00.0-scsi-0:2:0:0-part2 -> ../../sdb2
lrwxrwxrwx 1 root root 10 Feb 26 16:23 pci-0000:02:00.0-scsi-0:2:0:0-part3 -> ../../sdb3
lrwxrwxrwx 1 root root 10 Feb 26 16:23 pci-0000:02:00.0-scsi-0:2:0:0-part4 -> ../../sdb4
lrwxrwxrwx 1 root root 10 Feb 26 16:23 pci-0000:02:00.0-scsi-0:2:0:0-part5 -> ../../sdb5
lrwxrwxrwx 1 root root 10 Feb 26 16:23 pci-0000:02:00.0-scsi-0:2:0:0-part6 -> ../../sdb6

 

  2.2:创建本地存储仓库

xe sr-create host-uuid=3befa5af-c1dd-4b94-b299-09e27458cd59 type=lvm content-type=user device-config:device=/dev/disk/by-path/pci-0000:02:00.0-scsi-0:0:5:0 name-label="Local storage 2"

[root@xenserver ~]# xe sr-create host-uuid=3befa5af-c1dd-4b94-b299-09e27458cd59 type=lvm content-type=user device-config:device=/dev/disk/by-path/pci-0000:02:00.0-scsi-0:0:5:0 name-label="Local storage 2"
The SR operation cannot be performed because a device underlying the SR is in use by the host.

 

xe sr-create name-label="Local storage 2" type=lvm content-type=user host-uuid=03c38c30-f4f7-4eb7-ad5f-963c9f604e23 device-config:device=/dev/sda shared=false

 

注意:

集群中机器host-uuid项不可少

磁盘不要挂载,直接运行命令,否则会报错 the SR is in use by the host.

 

三:删除已挂载的本地仓库

  3.1:如用本地仓库挂载到windows盘,先到计算机管理-磁盘管理-对应盘-右键-脱机-右键-属性-策略-删除策略-快速删除

 

 

  如不卸载则会报错:

[root@xenserver ~]# xe pbd-unplug uuid=a5d8e8a8-07b0-a619-c61f-042e5876f761
This operation cannot be performed because this VDI is in use by some other operation
vdi: 1ec4041f-54bf-4b2a-ab8a-fda866596390 (New12)
operation: <unknown>

 

   如上述方法无法卸载,可以用一下方法

 

 

  3.2:列出当前SR资源

 

 

    xe sr-list

[root@xenserver ~]# xe sr-list
uuid ( RO)                : defc9d39-deb2-9f87-54f7-d4212b8ed216
          name-label ( RW): Local storage 2
    name-description ( RW):
                host ( RO): xenserver-hk-01
                type ( RO): lvm
        content-type ( RO): user

     

    xe -pbdlist

[root@xenserver ~]# xe pbd-list sr-uuid=defc9d39-deb2-9f87-54f7-d4212b8ed216
uuid ( RO)                  : a5d8e8a8-07b0-a619-c61f-042e5876f761
             host-uuid ( RO): 03c38c30-f4f7-4eb7-ad5f-963c9f604e23
               sr-uuid ( RO): defc9d39-deb2-9f87-54f7-d4212b8ed216
         device-config (MRO): device: /dev/sda
    currently-attached ( RO): true

 

     3.3:删除对应PBD:

      xe pbd-unplug uuid=a5d8e8a8-07b0-a619-c61f-042e5876f761

     3.4:删除对应SR:

      xe sr-forget uuid=defc9d39-deb2-9f87-54f7-d4212b8ed216

 

 

感谢:

https://wenku.baidu.com/view/c75c65f787c24028905fc3a2.html

https://blog.csdn.net/pclzr/article/details/44724353

https://blog.csdn.net/bishuixing/article/details/79823660

删除:

https://jingyan.baidu.com/article/5d368d1eda6bf73f61c05744.html

 

posted on 2019-02-26 21:13  jackyzm  阅读(951)  评论(0编辑  收藏  举报