
以程式設計方式,如何檢查 lun 節點是否是開機磁碟區(lun 節點是/dev/
在 Linux 系統(例如 RHEL 或 Ubuntu 或任何其他 Linux 風格)下建立的)。
據我所知,有一種方法可以使用dd
、hexdump
、等實用程式進行檢查file
,或透過以程式設計方式讀取前 512 位元組等(透過檢查/讀取 lun 節點中的前 512 位元組)。
還有其他有效的替代方法嗎?提前致謝。
答案1
關於確定分割區是否可引導,您可以使用sfdisk
以下方法來識別:
$ sudo sfdisk -l
Disk /dev/sda: 60801 cylinders, 255 heads, 63 sectors/track
Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 63- 64- 512000 83 Linux
/dev/sda2 63+ 60801- 60738- 487873536 8e Linux LVM
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty
*
任何可啟動的都會在輸出的第二列中顯示。對於其他類型的設備,例如 LVM 和 SD 卡:
Disk /dev/mapper/fedora_greeneggs-swap: 997 cylinders, 255 heads, 63 sectors/track
Disk /dev/mapper/fedora_greeneggs-root: 6527 cylinders, 255 heads, 63 sectors/track
Disk /dev/mapper/fedora_greeneggs-home: 53212 cylinders, 255 heads, 63 sectors/track
Disk /dev/mmcblk0: 488672 cylinders, 4 heads, 16 sectors/track
sfdisk: Warning: The partition table looks like it was made
for C/H/S=*/255/63 (instead of 488672/4/16).
For this listing I'll assume that geometry.
Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/mmcblk0p1 0+ 1946- 1947- 15633408 c W95 FAT32 (LBA)
/dev/mmcblk0p2 0 - 0 0 0 Empty
/dev/mmcblk0p3 0 - 0 0 0 Empty
/dev/mmcblk0p4 0 - 0 0 0 Empty
據我所知,LVM 邏輯磁碟區 (LV) 無法啟動,且星號*
也適用於這些其他類型的介質,例如 SD 卡。