使用Linux主机,如何识别任意连接的硬盘驱动器的原始操作系统。

时间:2022-09-02 16:53:03

I am running a data erasure program on a Linux (Ubuntu) machine. This machine erases many hard drives each day and I would like to be able to collect basic information about the hard drives for research purposes. One thing that I would like to know about a hard drive is the operating system that the hard drive was used with. This is probably only possible if the drive in question was once the boot drive.

我在Linux (Ubuntu)机器上运行一个数据删除程序。这台机器每天擦除许多硬盘驱动器,我希望能够收集有关硬盘驱动器的基本信息以供研究之用。我想知道的一件事是硬盘是使用硬盘的操作系统。这可能只有在涉及的驱动器是一次引导驱动器时才有可能实现。

Neither of main hard drive diagnostic tools, hdparm and smartmontools, have the functionality built in to identify the associated operating system. There do not appear to be any existing tools to achieve this, so I imagine I will have to build my own.

无论是主要的硬盘驱动诊断工具hdparm还是smartmontools,都不具备识别相关操作系统的功能。似乎没有任何现有的工具可以实现这一点,所以我想我必须构建我自己的工具。

My best solution follows this basic outline:

我的最佳解决方案如下:

  1. Determine Filesystem of hard drive
  2. 确定硬盘驱动器的文件系统
  3. Mount hard drive
  4. 挂载硬盘
  5. Use clues about the directory structure, existence of files, and modification times of files to determine the OS and build.
  6. 使用有关目录结构、文件存在和文件修改时间的线索来确定操作系统和构建。

So unless there is some magical tool I'm unaware of that already does this for me, my main question is how to achieve step number 3.

所以,除非我不知道有什么神奇的工具已经在为我做这些,我的主要问题是如何实现第3步。

I know a few identifying features so far and also found this thread, where someone posted the helpful information about determining the XP service pack level, as well as some other things useful for identifying groups of Microsoft operating systems the hard drive might be a part of.

到目前为止,我知道了一些识别特性,也找到了这个线程,有人在这个线程中发布了关于确定XP服务包级别的有用信息,以及一些其他有用的东西,用于识别Microsoft操作系统组,硬盘驱动器可能是其中的一部分。

Are there any detectives on SO who can identify an operating system based on a glance the directory structure and existing files? Or does anyone know where I might go to find such knowledge?

有没有侦探可以根据目录结构和现有文件识别操作系统?或者有人知道我可以去哪里找到这样的知识吗?

1 个解决方案

#1


2  

I'd just grab the knowledge from a configuration management tool, e.g. puppet, chef, cdist, etc. cdist's OS detection code is simple - https://github.com/telmich/cdist/blob/master/conf/explorer/os - and might help.

我将从配置管理工具中获取知识,例如puppet、chef、cdist等,cdist的OS检测代码很简单——https://github.com/telmich/cdist/blob/master/conf/explorer/os——可能会有帮助。

#1


2  

I'd just grab the knowledge from a configuration management tool, e.g. puppet, chef, cdist, etc. cdist's OS detection code is simple - https://github.com/telmich/cdist/blob/master/conf/explorer/os - and might help.

我将从配置管理工具中获取知识,例如puppet、chef、cdist等,cdist的OS检测代码很简单——https://github.com/telmich/cdist/blob/master/conf/explorer/os——可能会有帮助。