hard-drive

Serial number of Hard Disk or Hard Drive

拈花ヽ惹草 提交于 2019-11-27 13:17:25
问题 At first it may seems it is very easy question and some body may be trying to give me advice to try Google, it may be so. But for me it is very hard I have try Google, Stack Overflow and can’t find any good solution. Just want to get Serial number of Hard Disk or Hard Drive using C# Please read carefully: serial number of Hard Disk, but not Serial number of Volume of Hard Disk (e.g. C, D, E, etc). For getting serial no of volume of hard disk I have found solution on net and its work well but

How can I find the Harddisk Device Serial Number without using the WMI in .NET?

本秂侑毒 提交于 2019-11-27 08:10:22
问题 I want to get the hardwired serial number from the hard disk but NOT using WMI. I tried using WMI code, and it doesn't work on my machine for sure. So is there any alternative in .NET for finding the Serial Number of a physical hard disk? 回答1: This should help get started: How to get Physical HDD serial number without WMI Regarding your problem with WMI not returning data; Are you sure how to the right privileges to get data from WMI? You can use WMI Tools to check/fix this. 回答2: Use the

Direct access to hard disk with no FS from C program on Linux

自作多情 提交于 2019-11-27 08:02:40
I want to access the whole hard disk directly from a C program. There's no FS on it and never's gonna be one. I just want to open /dev/sda (for example) and do I/O at the block/sector level of the disk. I'm planning to write some programs for learning C programming in the Linux environment (I know C language, Python, Perl and Java) but lack confidence with the Linux environment. For my learning purposes I'm thinking about playing with kyoto-cabinet and saving the value corresponding to the computed hash directly into a "block/sector" of the hard disk, recording the pair: "hash, block/sector

How to get hard disk serial number using Python

淺唱寂寞╮ 提交于 2019-11-27 07:05:57
How can I get the serial number of a hard disk drive using Python on Linux ? I would like to use a Python module to do that instead of running an external program such as hdparm . Perhaps using the fcntl module? Linux As you suggested, fcntl is the way to do this on Linux. The C code you want to translate looks like this: static struct hd_driveid hd; int fd; if ((fd = open("/dev/hda", O_RDONLY | O_NONBLOCK)) < 0) { printf("ERROR opening /dev/hda\n"); exit(1); } if (!ioctl(fd, HDIO_GET_IDENTITY, &hd)) { printf("%.20s\n", hd.serial_no); } else if (errno == -ENOMSG) { printf("No serial number

How do I get the disk drive serial number in C/C++

我怕爱的太早我们不能终老 提交于 2019-11-27 05:47:46
问题 This has been already answered but it's a C# solution. How do I do this in C or C++? 回答1: There are a few ways to do this. You could make calls using system to get the information. For Linux: system("hdparm -i /dev/hda | grep -i serial"); Without using system: static struct hd_driveid hd; int fd; if ((fd = open("/dev/hda", O_RDONLY | O_NONBLOCK)) < 0) { printf("ERROR opening /dev/hda\n"); exit(1); } if (!ioctl(fd, HDIO_GET_IDENTITY, &hd)) { printf("%.20s\n", hd.serial_no); } else if (errno ==

Is there any way of detecting if a drive is a SSD?

左心房为你撑大大i 提交于 2019-11-27 03:50:00
I'm getting ready to release a tool that is only effective with regular hard drives, not SSD (solid state drive). In fact, it shouldn't be used with SSD's because it will result in a lot of read/writes with no real effectiveness. Anyone knows of a way of detecting if a given drive is solid-state? Detecting SSDs is not as impossible as dseifert makes out. There is already some progress in linux's libata ( http://linux.derkeiler.com/Mailing-Lists/Kernel/2009-04/msg03625.html ), though it doesn't seem user-ready yet. And I definitely understand why this needs to be done. It's basically the

How to detect if any specific drive is a hard drive?

给你一囗甜甜゛ 提交于 2019-11-26 23:03:26
问题 In C# how do you detect is a specific drive is a Hard Drive, Network Drive, CDRom, or floppy? 回答1: The method GetDrives() returns a DriveInfo class which has a property DriveType that corresponds to the enumeration of System.IO.DriveType: public enum DriveType { Unknown, // The type of drive is unknown. NoRootDirectory, // The drive does not have a root directory. Removable, // The drive is a removable storage device, // such as a floppy disk drive or a USB flash drive. Fixed, // The drive is

Getting a list of logical drives

折月煮酒 提交于 2019-11-26 20:47:58
问题 How can I get the list of logial drives (C#) on a system as well as their capacity and free space? 回答1: System.IO.DriveInfo.GetDrives() 回答2: foreach (var drive in DriveInfo.GetDrives()) { double freeSpace = drive.TotalFreeSpace; double totalSpace = drive.TotalSize; double percentFree = (freeSpace / totalSpace) * 100; float num = (float)percentFree; Console.WriteLine("Drive:{0} With {1} % free", drive.Name, num); Console.WriteLine("Space Remaining:{0}", drive.AvailableFreeSpace); Console

Read and write hard disk sector directly and efficiently [duplicate]

感情迁移 提交于 2019-11-26 18:32:44
问题 This question already has answers here : Direct access to hard disk with no FS from C program on Linux (3 answers) Read a single sector from a disk (4 answers) Closed 12 months ago . I have a special need for block data storage. My data are formatted data blocks in size of 4096. For high efficiency, I want to directly manipulate the block on hard disk sector and do not want to treat the data block as file. I think one way is to treat the device as a file such as /dev/sda1 and to use lseek()

How to get hard disk serial number using Python

家住魔仙堡 提交于 2019-11-26 17:37:26
问题 How can I get the serial number of a hard disk drive using Python on Linux ? I would like to use a Python module to do that instead of running an external program such as hdparm. Perhaps using the fcntl module? 回答1: Linux As you suggested, fcntl is the way to do this on Linux. The C code you want to translate looks like this: static struct hd_driveid hd; int fd; if ((fd = open("/dev/hda", O_RDONLY | O_NONBLOCK)) < 0) { printf("ERROR opening /dev/hda\n"); exit(1); } if (!ioctl(fd, HDIO_GET