문제

Is there a way to get the symbolic path (e.g. /dev/sda) of a computer's hard drive with a bash script executed from a flash drive inserted into the computer? Is it always /dev/sda?

도움이 되었습니까?

해결책

it could be different from sda. what if the computer has 4 hard-drives?

You could run fdisk -l as root (or sudo), check the bootable Device. usually it would be the C: drive. But it doesn't mean that device contains windows.

One can install Windows on hard-disk(II) but boot from Disk(I).

So the fdisk -l way can help you find the bootable partition/Disk on that machine. You can check the FS if it could be windows system FS (e.g. FAT32/NTFS). But it cannot tell you if that Disk has windows (those windows system files) installed.

Moreover, if the computer has 4 Disks, and install winOS on each of them, so there are 4 windows installed. say a multi-booting system. I cannot find a proper solution to find those disks except for mounting those partitions and checking FS.

다른 팁

By "computer's hard drive" I assume you mean the root file system for which Linux is booted. You can use the df utility to check what / was mounted to:

$ df / 
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             10317828   7824696   1969016  80% /
$ df / | grep / | cut -d" " -f1
/dev/sda1
$

/dev/sda1 is simply the first partition of the drive /dev/sda. In my case it is also dev/sda, but you certainly can't guarantee it will always be this. You might see /dev/hda if it is an IDE disk. /dev/sda is generally SATA or SCSI. /dev/sdb would be the second disk on the system, and so on.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top