無法掛載鏡像文件

無法掛載鏡像文件

我正在嘗試將image_file_name.img具有多個分割區的目錄掛載到一個目錄,但沒有成功。

分區詳細資料:

sfdisk -l -uS image_file_name.img 
Disk image_file_name.img: cannot get geometry

Disk image_file_name.img: 11 cylinders, 255 heads, 63 sectors/track
Warning: The partition table looks like it was made
  for C/H/S=*/4/63 (instead of 11/255/63).
For this listing I'll assume that geometry.
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
image_file_name.img1           252       503        252  83  Linux
image_file_name.img2           504    177407     176904  83  Linux
image_file_name.img3             0         -          0   0  Empty
image_file_name.img4             0         -          0   0  Empty


我正在運行以下mount命令:

mount -o offset=$((252*512)) image_file_name.img /tmp/abc/

錯誤訊息:

mount: mounting /dev/loop0 on /tmp/abc/ failed: Invalid argument

對應的錯誤dmesg

[106359.764567] NTFS-fs error (device loop0): parse_options(): Unrecognized mount option offset.

這是在沒有諸如kpartx.

任何幫助表示讚賞。

答案1

鑑於您在 中看到的錯誤dmesg,我會跳過offset作為mount選項並依賴它losetup

透過util-linuxs losetup,您可以使用分區處理:

losetup -P -f --show image_file_name.img

這將顯示所使用的循環設備的名稱;用它來安裝,使用

mount /dev/loop0p1 /tmp/abc

但替換loop0不是 p1) 作為適當的。其他分區可以使用p2etc來存取。

使用busyboxs losetup,您需要直接指定偏移量:

losetup -o $((252*512)) -f image_file_name.img

然後直接安裝loop設備,例如

mount /dev/loop0 /tmp/abc

如果卸載檔案系統,也應該使用 釋放循環設備losetup -d

相關內容