Listing Disks and Drives on Ubuntu via WSL for UltraLinux

This guide provides step-by-step instructions for listing disks and drives on Ubuntu using the Windows Subsystem for Linux (WSL) on a Windows system, tailored for users interested in the UltraLinux project (https://ultralinux.org/). While UltraLinux focuses on Linux for SPARC processors, this tutorial helps users explore disk and drive management commands in a Linux-like environment on Windows using WSL. These commands are useful for understanding storage configurations, which can be relevant for UltraLinux system administration.

Prerequisites

  • A Windows 10 or 11 system with WSL2 enabled.
  • Basic familiarity with terminal commands.
  • Internet access to install packages if needed.

Step 1: Enable and Install WSL2

  1. Enable WSL2:
    • Open PowerShell as Administrator and run:
      wsl --install
      
    • This enables WSL and installs Ubuntu by default. Restart your computer if prompted.
    • Alternatively, enable WSL manually:
      • Go to Settings > Apps > Optional Features.
      • Select Windows Subsystem for Linux, click OK, and restart.
  2. Install Ubuntu:
    • From the Microsoft Store, search for “Ubuntu” (e.g., Ubuntu 22.04 LTS) and click Install.
    • Launch Ubuntu from the Start menu and set up a username and password when prompted.
  3. Set WSL2 as Default:
    • In PowerShell, run:
      wsl --set-default-version 2
      
    • Verify Ubuntu is using WSL2:
      wsl -l -v
      

Step 2: Update Ubuntu and Install Disk Utilities

  1. Update Ubuntu:
    • Open the Ubuntu terminal and update the package list:
      sudo apt update && sudo apt upgrade -y
      
  2. Install Disk Management Tools:
    • Install common tools for listing and managing disks:
      sudo apt install -y fdisk util-linux parted
      

Step 3: Commands to List Disks and Drives

Below are key commands to list disks, partitions, and drives in Ubuntu on WSL. Note that WSL virtualizes disk access, so some commands may show limited information compared to a native Linux system. These commands are still relevant for learning disk management for UltraLinux environments.

  1. List Block Devices with lsblk:
    • Display all block devices (disks and partitions):
      lsblk
      
    • Output shows devices like /dev/sda, their mount points, and sizes. In WSL, you may see virtual disks and mounted Windows drives (e.g., /mnt/c).
  2. List Disks with fdisk:
    • List all disk devices:
      sudo fdisk -l
      
    • This requires sudo and shows detailed partition tables. In WSL, physical disk access may be limited, but you’ll see virtual disks or mounted Windows partitions.
  3. Use parted to List Partitions:
    • List all partitions:
      sudo parted -l
      
    • This displays disk and partition details, including file system types.
  4. Check Disk Usage with df:
    • Show disk usage and mount points:
      df -h
      
    • The -h flag makes sizes human-readable (e.g., GB, MB). This is useful for checking mounted Windows drives in /mnt.
  5. List Devices with blkid:
    • Display device UUIDs and file system types:
      sudo blkid
      
    • This helps identify devices by their unique identifiers, useful for UltraLinux system configuration.
  6. Inspect Disks with ls /dev:
    • List device files:
      ls /dev/sd*
      
    • This shows available disk devices (e.g., /dev/sda, /dev/sdb). In WSL, you may see fewer devices due to virtualization.

Step 4: Create and Run a Test Script

To automate disk listing, you can use a shell script. This is useful for UltraLinux users managing SPARC systems where disk configurations are critical.

  1. Create a Shell Script:
    • Create a file named list_disks.sh:
      nano ~/list_disks.sh
      
    • Add the following code:
      #!/bin/bash
      echo "Listing Disks and Drives for UltraLinux Environment"
      echo "-----------------------------------------------"
      echo "1. Block Devices (lsblk):"
      lsblk
      echo
      echo "2. Disk Usage (df -h):"
      df -h
      echo
      echo "3. Device UUIDs (blkid):"
      sudo blkid
      echo
      echo "4. Disk Devices in /dev:"
      ls /dev/sd*
      echo
      echo "For detailed partition info, run 'sudo fdisk -l' or 'sudo parted -l' manually."
      
  2. Make the Script Executable:
    • Set execute permissions:
      chmod +x ~/list_disks.sh
      
  3. Run the Script:
    • Execute the script:
      ./list_disks.sh
      
    • The script outputs a summary of disks, partitions, and usage. Some commands (e.g., blkid) require sudo and may prompt for your password.

Step 5: Additional Tips for UltraLinux Users

  • SPARC Considerations: On SPARC hardware for UltraLinux, these commands are directly applicable. However, in WSL, disk access is virtualized, so results may differ. Test these commands on a native SPARC system for accurate hardware details, and consult UltraLinux documentation (https://ultralinux.org/) for SPARC-specific disk configurations.
  • File System Support: UltraLinux supports various file systems (e.g., ext2, ext3). Use blkid or parted to verify file system types when working with SPARC disks.
  • Community Resources: For UltraLinux-specific disk management questions, refer to the mailing lists or FAQ on https://ultralinux.org/.
  • Storage Monitoring: For ongoing monitoring, consider installing ncdu for a detailed disk usage breakdown:
    sudo apt install ncdu
    ncdu /
    

Conclusion

You’ve now learned how to list disks and drives on Ubuntu via WSL using essential Linux commands, preparing you for storage management tasks relevant to UltraLinux. These commands provide insights into disk configurations, which are critical for system administration on SPARC-based systems. For further details, explore https://ultralinux.org/ for UltraLinux-specific resources, including mailing lists and the FAQ.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top