User Tools

Site Tools


software:multibootusb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

software:multibootusb [2023/02/26 17:02] – created rodolicosoftware:multibootusb [2023/02/26 17:07] (current) rodolico
Line 4: Line 4:
  
 However, at our NOC, we have several Windows virtuals, some of which we use internally, so we can use one of those. How to attach a USB Thumbdrive on my workstation to the remote virtual was an interesting problem. I finally came up with one solution: Create a virtual disk image, mount it as a USB Drive on the Windows virtual, do all the work, then use DD to copy the disk image to the the thumbdrive plugged into my physical machine. However, at our NOC, we have several Windows virtuals, some of which we use internally, so we can use one of those. How to attach a USB Thumbdrive on my workstation to the remote virtual was an interesting problem. I finally came up with one solution: Create a virtual disk image, mount it as a USB Drive on the Windows virtual, do all the work, then use DD to copy the disk image to the the thumbdrive plugged into my physical machine.
- 
-===== Gather Information ===== 
- 
-==== On your computer ==== 
- 
-Plug in the USB Thumbdrive and get the size of it, in bytes. fdisk will work just fine 
-<code bash>fdisk -l /dev/usbdrive</code> 
-On my "32 Gig" drive, this returned 32015679488 
  
 ===== Plan your image ===== ===== Plan your image =====
  
-Plan a disk image to be attached to your virtual. This **must** be smaller or the exact size of the USB drive. For maximum disk space, create block device based on blocks (files) or extents (lvm2). +  - Plug in the USB Thumbdrive and get the size of it, in bytes. fdisk will work just fine<code bash>fdisk -l /dev/usbdrive</code>On my "32 Gig" drive, this returned 32015679488 
- +  - Calculate the size of the disk image to work with. This **must** be smaller or the exact size of the USB drive. For maximum disk space, create block device based on blocks (files) or extents (lvm2). 
-Decide what the backing device will be. In my case, I'll use lvm2, but you can use a file backed device.  +  Decide what the backing device will be. In my case, I'll use lvm2, but you can use a file backed device. 
-An LVM extent (block) is 4M, or 4194304, so, we need to know the maximum number of extents we can allocate. Just divide the size of the device (in bytes) by the size of the extent (in bytes) +    An LVM extent (block) is 4M, or 4194304, so, we need to know the maximum number of extents we can allocate. Just divide the size of the device (in bytes) by the size of the extent (in bytes). 
-32015679488 / 4194304 = 7633.1328, round down to 7633 +      32015679488 / 4194304 = 7633.1328, round down to 7633 
- +    A file will be built in increments of the block sizeso find out the block size, the use the systems tools to create a file of the correct size.
-<code bash>lvcreate -l 7633 /dev/vg-md0/usbthumbdrive</code> +
- +
-Note that you will "lose" 557056 bytes in this conversionbut you are guaranteed it will copy to your drive +
- +
  
-==== On the hypervisor ====+===== On the hypervisor =====
  
 I'll use //saffron// as the name of the virtual, and usbthumbdrive as the name of the block device to create. Adjust to your system. I'll use //saffron// as the name of the virtual, and usbthumbdrive as the name of the block device to create. Adjust to your system.
  
-=== Create block device ===+==== Create block device ====
  
 <code bash>lvcreate -l 7633 /dev/vg-md0/usbthumbdrive</code> <code bash>lvcreate -l 7633 /dev/vg-md0/usbthumbdrive</code>
Line 39: Line 26:
 <code bash>dd if=/dev/zero | pv -petrs 29G | of=/dev/vg-md0/usbthumbdrive</code> <code bash>dd if=/dev/zero | pv -petrs 29G | of=/dev/vg-md0/usbthumbdrive</code>
  
-=== Mount logical volume on running virtual ====+==== Mount logical volume on running virtual =====
 Determine an available block name on the virtual by entering the command: Determine an available block name on the virtual by entering the command:
 <code bash>virsh domblklist saffron</code> <code bash>virsh domblklist saffron</code>
software/multibootusb.txt · Last modified: 2023/02/26 17:07 by rodolico