【问题标题】:linux file system layout -partiton - fdisklinux文件系统布局-partiton-fdisk
【发布时间】:2019-08-26 22:11:28
【问题描述】:

我很想了解 linux 文件系统布局。为什么该命令在虚拟框内有效,但在 Windows 的 linux shell 上无效?

我尝试在我的虚拟机(Ubuntu)和 Windows 上的 Ubuntu(来自微软商店)上使用命令 sudo fdisk -l dev/sda。它对它们中的任何一个都不起作用,但是当我将命令更改为sudo fdisk -l 时,它在虚拟框内起作用,但在 Windows 上的 linux bash shell 上不起作用。

Windows 上的 linux shell 内部:

:~$ sudo fdisk -l /dev/sda
.

fdisk: cannot open /dev/sda: No such file or directory

:~$ sudo fdisk -l

fdisk: cannot open /proc/partitions: No such file or directory

:~$ man fdisk

:~$ whereis fdisk

fdisk: /sbin/fdisk /usr/share/man/man8/fdisk.8.gz

【问题讨论】:

    标签: shell ubuntu command-line ubuntu-18.04 partition


    【解决方案1】:

    Windows Subsystem for Linux (WSL) 的基础 - Ubuntu 是一个类似于Cygwin 的环境的 POSIX 模拟器,有助于将一些在 Windows 平台上运行的基于 Linux 的命令/应用程序移植为 Windows 进程。

    它包含一个虚拟文件系统 (vfs) 的抽象层,它具有只读的应用程序映像和基于 RAM 的可写 tmpfs,它既没有访问控制来读取主机系统上的原始设备,也没有模拟原始设备对于子系统。

    来自人(fdisk):

    说明

    此命令用于创建和修改分区表,以及安装主引导(仅限 IA)记录 放在固定磁盘的第一个扇区。该表由 用于识别磁盘部分的第一阶段引导程序(或固件) 为不同的操作系统保留,并识别 包含第二阶段引导程序的分区(活动的 Solaris 划分)。 必须使用 rdevice 参数来指定原始 与固定磁盘关联的设备,例如, /dev/rdsk/c0t0d0p0.

    所以 WSL-Ubuntu 无法成功执行 fdisk 命令,因为它没有自己的内核来管理主机资源。

    另一方面,Oracle 的 VirtualBox 是一个虚拟化系统,它模仿在裸机上运行的全功能操作系统。它在虚拟化管理程序的帮助下模拟自己的系统空间和用户空间,并通过来宾操作系统内核管理虚拟资源。这就是为什么在 VirtualBox 上 fdisk 命令执行成功的原因

    参考: https://www.microsoft.com/en-us/research/wp-content/uploads/2013/01/posix-emulation-submitted.pdf

    致谢:https://www.quora.com/How-is-Windows-Subsystem-for-Linux-different-from-running-Linux-on-Windows-in-a-VM

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多