dev-manual: add instructions for compacting WSLv2 VHDX files using DiskPart for those systems which lack optimize-vhd

Message ID CADmuqUfgVBj28RbjVwGGxcT2NnP2k=DxSZ8z6C=miBqtncoN4w@mail.gmail.com
State New
Headers show
Series dev-manual: add instructions for compacting WSLv2 VHDX files using DiskPart for those systems which lack optimize-vhd | expand

Commit Message

Tony McDowell March 9, 2022, 2:42 a.m. UTC
This is an alternative way to compact VHDX files for Yocto Project use
since the prior instructions depended on a Windows tool not available
on all Windows hosts.

---
 documentation/dev-manual/start.rst | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)


          C:\WINDOWS\system32> wsl --shutdown
          C:\WINDOWS\system32> optimize-vhd -Path
C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\ext4.vhdx
-Mode full
@@ -533,6 +532,16 @@ your Yocto Project build host:
       VHDX file, and storage should now be reflected correctly on the
       Windows Explorer.

+   2b. *Optimize your VHDX file using DiskPart:* The optimize-vhd
cmdlet noted in step 2a above is provided by Hyper-V.  Not all SKUs of
Windows can install Hyper-V.  As an alternative, use the DiskPart
tool.  To start, open a Windows command prompt as Administrator to
optimize your VHDX file, shutting down WSL first::
+
+         C:\WINDOWS\system32> wsl --shutdown
+         C:\WINDOWS\system32> diskpart
+
+         DISKPART> select vdisk file="<path_to_VHDX_file>"
+         DISKPART> attach vdisk readonly
+         DISKPART> compact vdisk
+         DISKPART> exit
+
 .. note::

    The current implementation of WSLv2 does not have out-of-the-box

Comments

Michael Opdenacker March 9, 2022, 7:54 a.m. UTC | #1
Hi Tony,

On 3/9/22 03:42, Tony McDowell wrote:
> This is an alternative way to compact VHDX files for Yocto Project use
> since the prior instructions depended on a Windows tool not available
> on all Windows hosts.


Many thanks for this patch.

However, did you try to apply it to the "master" branch of yocto-docs?
I'm getting this error:
error: git diff header lacks filename information when removing 1
leading pathname component (line 6)

Thanks again
Michael.
Tony McDowell March 9, 2022, 3:53 p.m. UTC | #2
On Wed, Mar 9, 2022 at 12:54 AM Michael Opdenacker
<michael.opdenacker@bootlin.com> wrote:
>
> Hi Tony,
>
> On 3/9/22 03:42, Tony McDowell wrote:
> > This is an alternative way to compact VHDX files for Yocto Project use
> > since the prior instructions depended on a Windows tool not available
> > on all Windows hosts.
>
>
> Many thanks for this patch.
>
> However, did you try to apply it to the "master" branch of yocto-docs?
> I'm getting this error:
> error: git diff header lacks filename information when removing 1
> leading pathname component (line 6)
>
> Thanks again
> Michael.
>
> --
> Michael Opdenacker, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>

Thanks, Michael.  I think the problem is that I created it with
TortoiseGit on Windows and it didn't capture the proper context of the
files.  I'll try to fix it today and resubmit.  For the etiquette of
this mailing list, should that be a new patch email or as a reply on
this one?

Thanks
Tony
Michael Opdenacker March 9, 2022, 3:57 p.m. UTC | #3
Hi Tony,

On 3/9/22 16:53, Tony McDowell wrote:
>
> Thanks, Michael.  I think the problem is that I created it with
> TortoiseGit on Windows and it didn't capture the proper context of the
> files.  I'll try to fix it today and resubmit.  For the etiquette of
> this mailing list, should that be a new patch email or as a reply on
> this one?


Thanks for asking!
I believe it's best to send the new patch as a reply on this thread, but
this is not a very strict requirement :)

I suggest you to send your patch to yourself first, save the message to
a file, create a new branch from "master" and try to apply your patch
using "git am <file>".
Thanks in advance
Michael.
Tony McDowell March 9, 2022, 11:48 p.m. UTC | #4
On Wed, Mar 9, 2022 at 8:57 AM Michael Opdenacker
<michael.opdenacker@bootlin.com> wrote:
>
> Hi Tony,
>
> On 3/9/22 16:53, Tony McDowell wrote:
> >
> > Thanks, Michael.  I think the problem is that I created it with
> > TortoiseGit on Windows and it didn't capture the proper context of the
> > files.  I'll try to fix it today and resubmit.  For the etiquette of
> > this mailing list, should that be a new patch email or as a reply on
> > this one?
>
>
> Thanks for asking!
> I believe it's best to send the new patch as a reply on this thread, but
> this is not a very strict requirement :)
>
> I suggest you to send your patch to yourself first, save the message to
> a file, create a new branch from "master" and try to apply your patch
> using "git am <file>".
> Thanks in advance
> Michael.
>
> --
> Michael Opdenacker, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>

Hi Michael:

I was able to apply my patch directly against the yocto-docs repo and
it applied without issue and I saw the change show up in start.rst
like I expected.  I have attached the .patch file that TortoiseGit
generated for me if that works more easily for you.

thanks
.tony
Michael Opdenacker March 10, 2022, 7:48 a.m. UTC | #5
Hi Tony,

On 3/10/22 00:48, Tony McDowell wrote:
> On Wed, Mar 9, 2022 at 8:57 AM Michael Opdenacker
> <michael.opdenacker@bootlin.com> wrote:
>> Hi Tony,
>>
>> On 3/9/22 16:53, Tony McDowell wrote:
>>> Thanks, Michael.  I think the problem is that I created it with
>>> TortoiseGit on Windows and it didn't capture the proper context of the
>>> files.  I'll try to fix it today and resubmit.  For the etiquette of
>>> this mailing list, should that be a new patch email or as a reply on
>>> this one?
>>
>> Thanks for asking!
>> I believe it's best to send the new patch as a reply on this thread, but
>> this is not a very strict requirement :)
>>
>> I suggest you to send your patch to yourself first, save the message to
>> a file, create a new branch from "master" and try to apply your patch
>> using "git am <file>".
>> Thanks in advance
>> Michael.
>>
>> --
>> Michael Opdenacker, Bootlin
>> Embedded Linux and Kernel engineering
>> https://bootlin.com
>>
> Hi Michael:
>
> I was able to apply my patch directly against the yocto-docs repo and
> it applied without issue and I saw the change show up in start.rst
> like I expected.  I have attached the .patch file that TortoiseGit
> generated for me if that works more easily for you.

Thanks for this update. I managed to apply the new patch.

I modified it a bit to fix a formatting issue that I had at least with
my version of Sphinx. I also added a Signed-off-by line to the commit,
which is required by the Yocto Project. Don't forget next time.

Reviewed-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
... and merged into "master-next".

Thanks again. Don't hesitate to send us more improvements!
Cheers
Michael.

Patch

diff --git a/documentation/dev-manual/start.rst
b/documentation/dev-manual/start.rst
index 9c7dde8cf..80288b607 100644
--- a/documentation/dev-manual/start.rst
+++ b/documentation/dev-manual/start.rst
@@ -523,8 +523,7 @@  your Yocto Project build host:
       Your VHDX file path is:
       ``C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\ext4.vhdx``

-   2. *Optimize your VHDX file:* Open a Windows Powershell as
-      Administrator to optimize your VHDX file, shutting down WSL first::
+   2a. *Optimize your VHDX file using Windows Powershell:* To use the
optimize-vhd cmdlet below, first install the Hyper-V option on
Windows.  Then, open a Windows Powershell as Administrator to optimize
your VHDX file, shutting down WSL first::