Mounting a USB Device In a Xen Guest

​Mounting a USB device

 Attach the USB device to the Dom0 and run ‘dmesg’ to see if the device attached

Run ‘fdisk -l’ to see if the drive is partitioned the way you want it

For instance:

[[email protected] ~]# fdisk -l /dev/sdc

Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

dev/sdc1 1 121601 976760001 8e Linux LVM

Now find a drive letter that is not being used on the DomU, in this instance we’ll use /dev/sde

To attach the USB device to the DomU run the following command

xm block-attach exampledomu phy:/dev/sdc sde w

You should now see the device on the DomU, run either ‘dmesg’ or ‘fdisk -l’ to verify

Mount the device as normal

mount /dev/sde1 /mnt/usb

Unmounting the device

You first need to get the device id number from the block list. Do this by running:

xm block-list exampledomu

This will return:

    Vdev BE handle state evt-ch ring-ref BE-path

    51712 0 0 4 9 8 /local/domain/0/backend/tap/23/51712

    2176 0 0 4 10 1338 /local/domain/0/backend/vbd/23/2176

The number you need to use to remove the device is 2176

Unmount the USB device from the DomU

umount /mnt/usb

 Now on the Dom0 run:

xm block-detach exampledomu 2176

You may now remove the USB device

Share this Post

Leave a Comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.