Selecting home directory at installing Ubuntu on Win10

I want to install the Ubuntu distro on Win10, but choose the C:/ as home directory so I can use the power of Linux commands on all the folders including the Document folders, desktop, win/app folders.

How do I do that?


Assuming that you are referring to installing Ubuntu on Windows through WSL, you really don't need to set your C:\ root as the "home directory". By default, WSL auto-mounts existing Windows drives, so you should find /mnt/c already exists in your WSL installation, and all the files/directories from that drive are available to you through Linux commands.

There's one huge caveat here, though. If you are going to do this, I highly recommend using WSL version 1, not WSL2. While WSL2 has its uses, working with the Windows/NTFS filesystem is not currently one of them. WSL1 is much faster (see this) for accessing files on your Windows drive(s).

I actually keep both WSL1 and WSL2 instance around for this very reason. If I plan on doing something with Windows files, I use the WSL1 installation.

Double-check which version you are using with wsl -l -v. If it's WSL2, then you can do one of two things.

First option, just change the version using wsl --set-version <distro> 1. Note that I would (personally) still recommend a backup first anyway (using wsl --export).

Second option, which is my preference, is to create a clone/copy of your existing instance, so that you have both WSL2 and WSL1 around. While a bit "detailed", this is how I do it ...

  • Create a directory somewhere convenient where you want to work with your WSL images. Of course, I name mine WSL. I have mine under My Documents\WSL.

  • cd to that directory.

  • Create two subdirectories, images and instances. Again, the names are really up to you.

  • wsl -l -v just to confirm your current distribution names.

  • Back up your existing 20.04 distro using something like wsl --export Ubuntu images\2021-02-05_Ubuntu20.04_snapshot.tgz (assuming your distribution is named "Ubuntu", of course).

  • Create a new instance using that snapshot using something like wsl --import Ubuntu20.04_WSL1 instances\Ubuntu20.04_clone images\2021-02-05_Ubuntu20.04_snapshot.tgz --version 1.

  • Launch that instance using wsl ~ -d Ubuntu20.04_WSL1. Or restart Windows Terminal (assuming you are using it) and the new instance should be detected automatically.

  • The new instance will launch as root by default. You will need to set your username by creating a /etc/wsl.conf with the following:

    [user]
    default=me
    

    ... of course, substituting your username.

  • Exit and restart that distribution, and confirm that your environment is operating as you'd expect.