Open chatenilesh opened 5 years ago
Hi again @chatenilesh :) It seems you've indeed stumbled on a bug here.
Are you interested in submitting a fix? Keep in mind that the fix should try as much as possible to read from non-privileged (pseudo)files like /proc/partitions (not the MBR itself which I'm pretty sure would require root privileges and not a shell out to fdisk
since that also requires root privileges to execute).
I would be interested to see patches (and possibly separate github issues) that address the following apparent bugs:
1) extended partitions clearly are not being properly sized. As your output shows, the size shown by ghw
is 1K but the actual size of the extended partition (sdb2) is the sum of all its component partitions (sdb5, sdb6, sdb7).
2) ghw
isn't even picking up the HPFS/NTFS/exFAT partition (sdb8). I'm not sure why and would appreciate some investigation here into what exactly that partition contains on your system. Is that a swap partition of some sort? Is it a USB drive that has been temporarily inserted?
Can you do me a favor and show me what the output of the follow is?
go run cmd/ghwc/main.go block -f yaml
Thanks! -jay
Hi, I too what a solution without parsing command outputs or reading MBR as it requires root privileges. So far I haven't come across any clean solution, so for now I am reading details from MBR. I would like to avoid reading MBR and submit a fix once I get a better solution.
nyc@nyc:~/go/src/github.com/chatenilesh/ghw$ go run cmd/ghwc/main.go block -f yaml
block:
disks:
- bus_path: pci-0000:00:0d.0-ata-1
drive_type: hdd
model: VBOX_HARDDISK
name: sda
partitions:
- label: ""
mount_point: /
name: sda1
read_only: false
size_bytes: 107372085248
type: ext4
physical_block_size_bytes: 512
serial_number: VB4d5f4f53-a3364e08
size_bytes: 107374182400
storage_controller: scsi
vendor: ATA
wwn: unknown
- bus_path: pci-0000:00:0d.0-ata-2
drive_type: ssd
model: VBOX_HARDDISK
name: sdb
partitions:
- label: ""
mount_point: ""
name: sdb1
read_only: true
size_bytes: 963171581952
type: ""
- label: ""
mount_point: ""
name: sdb2
read_only: true
size_bytes: 1024
type: ""
- label: ""
mount_point: ""
name: sdb5
read_only: true
size_bytes: 52451868672
type: ""
- label: ""
mount_point: ""
name: sdb6
read_only: true
size_bytes: 47436529664
type: ""
- label: ""
mount_point: ""
name: sdb7
read_only: true
size_bytes: 25248661504
type: ""
- label: ""
mount_point: ""
name: sdb8
read_only: true
size_bytes: 4109369344
type: ""
physical_block_size_bytes: 512
serial_number: VB6386b7e6-97617c1b
size_bytes: 1099511627776
storage_controller: scsi
vendor: ATA
wwn: unknown
- bus_path: pci-0000:00:01.1-ata-2
drive_type: odd
model: VBOX_CD-ROM
name: sr0
partitions: []
physical_block_size_bytes: 2048
serial_number: VB2-01700376
size_bytes: 85917696
storage_controller: scsi
vendor: VBOX
wwn: unknown
total_size_bytes: 1206971727872
Of all the systems I checked, only
/sys/block/sdb/size
(disk size) was reliable, partition size was wrong for special partitions like extended, boot, swap, etc. I think getting size from/sys/block/sdb/sdb2/size
is not correct?. I think partition size must be obtained from/proc/partitions
or readMBR
, any thoughts?