# How to get Partition on hard-disk from raw hard disk image when doing iPxe boot.



## ruchir15 (Mar 9, 2021)

I am using mfsbsd (https://github.com/mmatuska/mfsbsd) to create raw disk image (.img) with some my own custom change.

I am able to create a digital ocean droplet from this by uploading raw disk image (https://www.digitalocean.com/docs/images/custom-images/how-to/upload/) 

When I boot up a droplet (vm) from this machine it boots up fine. and I could see two gpt partition created on harddisk. as shown below: ( of-course I am able to recover corrupt partition using gpart recover  )


```
# gpart show
=>    40  317424  vtbd0  GPT  (80G) [CORRUPT]
      40     472      1  freebsd-boot  (236K)
     512  316952      2  freebsd-ufs  (155M)
```



I would like to replicate this setup in a network boot environment so what I did:

* Created a freebsd server with tftp, dhcp, ipxe  ngnix, Syslinux and Memdisk  ( virtualbox vm )

   my isc-dhcp config looks like below.  ( https://ipxe.org/howto/dhcpd#pxe_chainloading  )



```
subnet 192.168.29.0 netmask 255.255.255.0 {
 range 192.168.29.1 192.168.29.244;
}


# add the following to /usr/local/etc/dhcpd.conf
option client-arch code 93 = unsigned integer 16;


if exists user-class and option user-class = "iPXE" {
  filename "http://192.168.29.113/config.ipxe";
} else {
  if exists client-arch {
     if option client-arch = 00:00 {
       filename "undionly.kpxe";
     } elsif option client-arch = 00:07 {
       filename "ipxe.efi-x86_64";
     } elsif option client-arch = 00:09 {
       filename "ipxe.efi-x86_64";
     }
  }
}
```

Config.ipxe getting served via ngnix looks like below:



```
#!ipxe


initrd http://192.168.29.113/mfsbsd.img
chain http://192.168.29.113/memdisk raw harddisk
boot
```


*  then I  spin up  client vm on same network with n/w boot, which boots up fine, however as in case of digital ocean the partition were created on harddisk,
   In case of network boot, no partition gets created .i.e. output of

    gpart show is empty. 


If I need to get partitions on hard disk in network boot setup , how could I achieve it ?


----------

