local/bin/vbox-vmdk.sh

   1 #!/bin/bash
   2 
   3 if [[ $(command -v wmic) ]]; then
   4     dev='\\.\PhysicalDrive'
   5     devs=$(wmic diskdrive get DeviceID | sed -e 's/\r$//' | tail -n +2)
   6 else
   7     dev='/dev/sd'
   8     devs=$(ls /dev/sd[a-z])
   9 fi
  10 
  11 [[ $# == 0 ]] &&
  12 for i in $devs; do
  13     echo $i
  14     vboxmanage internalcommands listpartitions -rawdisk $i
  15     echo
  16 done
  17 
  18 for i in $*; do
  19     vboxmanage internalcommands createrawvmdk -rawdisk $dev$i -filename $i.vmdk
  20 done
  21