> For the complete documentation index, see [llms.txt](https://docs.hackjiji.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackjiji.org/general/environment-setup/install-a-new-os-on-seperated-boot-sector.md).

# Install a new OS on seperated boot sector

## 1. Create a VHDX&#x20;

Go to Disk management and create a new VHDX disk with Dynamicallly expanding and 80 GB of size:

<figure><img src="https://content.gitbook.com/content/C4CcD9gCTFzGtXx2V5PP/blobs/z03VSqQznkVyYCOy7dvU/image.png" alt=""><figcaption></figcaption></figure>

#### 1.1  Attach the VHDX

To make a VHD available for use (either one you've created or another existing VHD), follow these steps:

1. Open Disk management. In the search box on the taskbar, enter **Computer Management**, and select **Disk Management**.
2. On the **Action** menu, select **Attach VHD**.
3. After the *Attach Virtual Hard Disk* dialog box opens, select the **Browse** button, and find your **.vhd** file.
4. Now that you've selected the **.vhd** file, you return to the *Attach Virtual Hard Disk* dialog box. Select **OK**.

#### 1.2 Initialize the VHDX

1. In Disk Management, select and hold (or right-click) the disk you want to initialize, and then select **Initialize Disk**. If the disk is listed as *Offline*, first select and hold (or right-click) the disk, and then select **Online**.

   Some USB drives can't be initialized. These disks are only formatted and then assigned a [drive letter](https://learn.microsoft.com/en-us/windows-server/storage/disk-management/change-a-drive-letter).

   ![Screenshot that shows Disk Management for an unformatted disk with the Initialize Disk shortcut menu displayed.](https://learn.microsoft.com/en-us/windows-server/storage/disk-management/media/uninitialized-disk.png)
2. In the **Initialize Disk** dialog box, make sure the correct disk is selected, and then choose **OK** to accept the default partition style. If you need to change the partition style (GPT or MBR), see [Compare partition styles - GPT and MBR](https://learn.microsoft.com/en-us/windows-server/storage/disk-management/initialize-new-disks#compare-partition-styles---gpt-and-mbr).

   The disk status briefly changes to **Initializing** and then to the **Online** status. If initializing fails for some reason, see [A disk's status is Not Initialized or the disk is missing entirely](https://learn.microsoft.com/en-us/troubleshoot/windows-server/backup-and-storage/troubleshoot-disk-management#disks-that-are-missing-or-not-initialized).

   ![Screenshot that shows the Initialize Disk dialog box with the GPT partition style selected.](https://learn.microsoft.com/en-us/windows-server/storage/disk-management/media/initialize-disk.png)

#### 1.3 Format

&#x20;1.1 Create a Volume

<figure><img src="https://content.gitbook.com/content/C4CcD9gCTFzGtXx2V5PP/blobs/QMM76kkfoBWj6ePRT0Tm/image.png" alt=""><figcaption></figcaption></figure>

## 2. Apply the ISO image to your VHDX

1. Download an ISO image from the microsoft site and extract info about the install.wim

dism /get-wiminfo /wimfile:i:\sources\install.wim

1. Apply the image to your VHDX file where j:\ corresponds to your VHDX drive letter

dism /Apply-Image /ImageFile:install.wim /Index:5 /ApplyDir:j:\\

## 3. Create Boot Sector

1. Create your Bcdboot on the VHDX drive , assuming that your VHDX drive letter is j:

bcdboot j:/Windows

2. Detach/unmount the disk
3. Create or verify if the bcdboot entry is created and if not, add the following lines in command prompt and not powershell!!!!&#x20;

{% hint style="info" %}
You have to first identify the ID of the new bootloader using `bcdedit /v` and then replace it with the right value.

Bcdedit set {ID} description "something that makes sence for you".
{% endhint %}

```
bcdedit /set {b49af847-d3ee-11ea-a124-00d861e6520f} osdevice vhd=[e:]\Win_1909_03_2020.vhdx
bcdedit /set {b49af847-d3ee-11ea-a124-00d861e6520f} device vhd=[e:]\Win_1909_03_2020.vhdx
bcdedit /set {b49af847-d3ee-11ea-a124-00d861e6520f} description “TEST”
```

4. Restart the server and choose the new boot sector to complete the windows installation

You are done.

## Interesting resource for Microsoft activation scripts

{% embed url="<https://github.com/massgravel/Microsoft-Activation-Scripts>" %}

### Optional: Delete a boot entry in BCD

```
bcdedit /delete {b49af847-d3ee-11ea-a124-00d861e6520f}
```

## <mark style="color:red;">You have already an VHDX file - NOT TESTED YET!!</mark>

1. copy the vhdx file to your c drive from example
2. bcdedit /v to check the boot loader section

<figure><img src="https://content.gitbook.com/content/C4CcD9gCTFzGtXx2V5PP/blobs/JokpfXAm4aTa1wZX6kdY/image.png" alt=""><figcaption></figcaption></figure>

{% code lineNumbers="true" %}

```
bcdedit /v
bcdedit /copy {current} /d "Pentester-01.vhdx Boot"
bcdedit /set  {63a5720b-5bdd-11ef-b541-891552f0c234} device vhd=[C:]\VHDX\PENTESTER-01.VHDX
bcdedit /set  {63a5720b-5bdd-11ef-b541-891552f0c234} osdevice vhd=[C:]\VHDX\PENTESTER-01.VHDX

```

{% endcode %}

now we have a windows boot loader configured to boot from the vhdx&#x20;

<figure><img src="https://content.gitbook.com/content/C4CcD9gCTFzGtXx2V5PP/blobs/G8W81wG6IhLoVS0rmd2Q/image.png" alt=""><figcaption></figcaption></figure>

verify that we have another boot sector available sector

<figure><img src="https://content.gitbook.com/content/C4CcD9gCTFzGtXx2V5PP/blobs/Axv50IlLiZ9kNOeveH3Q/image.png" alt=""><figcaption></figcaption></figure>
