In this document, you will find instructions on how to get started using Linsk on Windows.
# How Linsk works
As you probably have realized from the initial README, Linsk takes use of a lightweight Alpine Linux virtual machine to tap into the rich world of Linux filesystems.
Linsk will pass through the disk as a raw block device to an ephemeral virtual machine, set up a file share, and then expose it to your host computer, along with logging the file share connection details. It's as simple as that.
**IMPORTANT NOTE:** Please ensure that the physical device you are trying to pass through is not mounted anywhere else on the host machine. Otherwise, you run serious risks. No further warnings will be issued.
time=2023-09-03T10:37:35.728+01:00 level=WARN msg="Using raw block device passthrough. Please note that it's YOUR responsibility to ensure that no device is mounted in your OS and the VM at the same time. Otherwise, you run serious risks. No further warnings will be issued." caller=vm
time=2023-09-03T10:37:35.730+01:00 level=INFO msg="Booting the VM" caller=vm
time=2023-09-03T10:37:45.742+01:00 level=INFO msg="The VM is up, setting it up" caller=vm
time=2023-09-03T10:37:48.578+01:00 level=INFO msg="The VM is ready" caller=vm
You should ignore the `vda` drive as this is the system drive you have the Alpine Linux installation on. Assuming that you used raw device passthrough, commonly, `vdb` is going to be the drive you passed through. But please note that this may not always be the case, and you should inspect the output above and confirm that the partitions shown match your drive.
**Having an LVM volume group behind an encrypted LUKS container?** Extra configuration is required. Please see the [Use an LVM volume group contained inside a LUKS volume](#use-an-lvm-volume-group-contained-inside-a-luks-volume) section.
**Pro Tip**: If the entire drive is just a single filesystem (without a partition table), you can omit the second parameter that specifies the VM device to mount. It will be automatically set to `vdb` as the default.
Upon running, you will see logs similar to this in your terminal:
```
# linsk command output
time=2023-09-03T10:53:57.385+01:00 level=WARN msg="Using raw block device passthrough. Please note that it's YOUR responsibility to ensure that no device is mounted in your OS and the VM at the same time. Otherwise, you run serious risks. No further warnings will be issued." caller=vm
time=2023-09-03T10:53:57.387+01:00 level=INFO msg="Booting the VM" caller=vm
time=2023-09-03T10:54:07.397+01:00 level=INFO msg="The VM is up, setting it up" caller=vm
time=2023-09-03T10:54:11.662+01:00 level=INFO msg="The VM is ready" caller=vm
At this point, you can open the file explorer -> Right-click "This PC" -> Show more options (if you're on Windows 11) -> Map network drive. Afterward, you should specify the share URL (the one that starts with `\\`), the static `linsk` username, and a randomly generated password.
**That's it!** After that, you should see the network share mounted successfully. That means that you can now access the files on the `vdb2` volume right from your Mac.
Linsk supports LVM2. You can mount LVM2 drives by specifying `mapper/<device name>` as the VM device name. Let's assume that you want to mount `vghdd-media` you found in the `linsk ls` output above. To do so, you may run:
As well as with LVM2, LUKS via `cryptsetup` is natively supported by Linsk. To mount LUKS volumes, you may specify the `-l` flag in `linsk run` command. Let's assume that we want to access LUKS-encrypted volume `vghdd-archive` we found in the `linsk ls` example provided in step 2. To mount it, you may execute:
```powershell
# This should be run in a terminal open with administrator privileges.
`-l` flag tells Linsk that it is a LUKS volume, and Linsk will prompt you for the password. Combined, your terminal will look like this:
```
# linsk command output
time=2023-09-03T11:44:55.962+01:00 level=WARN msg="Using raw block device passthrough. Please note that it's YOUR responsibility to ensure that no device is mounted in your OS and the VM at the same time. Otherwise, you run serious risks. No further warnings will be issued." caller=vm
time=2023-09-03T11:44:55.964+01:00 level=INFO msg="Booting the VM" caller=vm
time=2023-09-03T11:45:05.975+01:00 level=INFO msg="The VM is up, setting it up" caller=vm
time=2023-09-03T11:45:08.472+01:00 level=INFO msg="The VM is ready" caller=vm
This example showed how you can use LUKS with LVM2 volumes, but that doesn't mean that you can't use volumes without LVM. You can specify plain device paths like `vdb3` without any issue.
## Use an LVM volume group contained inside a LUKS volume
This is a common scenario that is widely used to enable full-disk encryption on various Linux distributions. It implies having a master LUKS volume that, once decrypted, exposes an LVM volume group (vg).
Linsk supports this by exposing `--luks-container` flag. You can use it with both `linsk ls` and `linsk run`.
## `linsk ls` with LUKS Container
Let's assume that you have a similar file system structure:
```
NAME FSTYPE
vdb
├─vdb1 vfat
├─vdb2 ext4
└─vdb3 crypto_LUKS
└─cryptroot LVM2_member
├─vgubuntu-lvswap swap
└─vgubuntu-lvroot ext4
```
If you run `linsk ls` without `--luks-container` flag like this:
```powershell
linsk ls dev:\\.\PhysicalDriveX
```
You are going to get this:
```
NAME FSTYPE
vdb
├─vdb1 vfat
├─vdb2 ext4
└─vdb3 crypto_LUKS
```
As you see, `vdb3` is locked, and the partitions inside thus remain invisible to the `linsk ls` command.
To tell Linsk to decrypt the `vdb3` container before going with anything, you may specify the `--luks-container` flag. Here is an example:
```powershell
linsk ls dev:\\.\PhysicalDriveX --luks-container vdb3
```
You will then get prompted a password, and once the LUKS container is open, you will see all of your partitions under the `vdb3` LUKS container. Your `lsblk` output will look like this:
```
NAME FSTYPE
vdb
├─vdb1 vfat
├─vdb2 ext4
└─vdb3 crypto_LUKS
└─cryptcontainer LVM2_member
├─vgubuntu-lvswap swap
└─vgubuntu-lvroot ext4
```
## `linsk run` with LUKS Container
Let's assume that you want to mount `vgubuntu-lvroot`.
You need to use the same `--luks-container vdb3` flag we used with `linsk ls`. Combined, your command should look like the following:
```powershell
# This should be run in a terminal open with administrator privileges.
linsk run dev:\\.\PhysicalDriveX --luks-container vdb3 mapper/vgubuntu-lvroot
```
**Pro Tip**: If the entire passed-through volume is a LUKS container (i.e., you are attempting to run with `--luks-container vdb`), you may use the `-c` flag as a shortcut (or long `--luks-container-entire-drive`). It is equivalent to `--luks-container vdb`.