# Sharing partitions in qemu

Apart from networking and partition sharing I've made qemu work pretty much like I want it to. I've got a bit of a special setup, I need to pass through /dev/sda, /dev/sda1 and /dev/sda2. (Is it possible to passthrough /dev/sda without passing through /dev/sda3 with it? I can live with using alternative methods.)

/dev/sda (MBR) = Windows Bootmgr on /dev/sda1

/dev/sda1 = System Reserved partition (Windows's bootloader)

/dev/sda2 = Windows 7's C:/ partition

/dev/sda3 = Arch Linux (Host)

I've got /dev/sda3's grub installed into the MBR of /dev/sdc (meaning booting /dev/sdc will boot me into my arch Linux install, booting /dev/sda will boot me into Windows) I will be passing through /dev/sdc as well but this one is easy as the host doesn't need any access to this drive after booting.

Finally I have a GPT, (NTFS) storage partition on /dev/sdb2 that I want to be easily accessible from both the host and my guest at the same time (I want to share it between both systems)

How do I proceed with /dev/sda and /dev/sdb2?

$grep . /sys/class/block/sda/**/(size|start) /sys/class/block/sda/sda1/size:224847 /sys/class/block/sda/sda1/start:63 /sys/class/block/sda/sda2/size:124820514 /sys/class/block/sda/sda2/start:224910 /sys/class/block/sda/size:125045424  If I want to hide sda2, I can create a /dev/mapper/no_sda2 where sectors 224910 to 125045424 contain zeros: • First create a loop device as otherwise dmsetup will complain because /dev/sda is in use (while loop will not complain which doesn't sound very consistent to me): losetup /dev/loop0 /dev/sda  • Then create /dev/mapper/no_sda2 as: dmsetup create no_sda2 << EOF 0 224910 linear /dev/loop0 0 224910$((125045424-224910)) zero