원시 디스크 이미지를 생성하고 복구 모드에서 QEMU에 마운트하는 중에 문제 발생

원시 디스크 이미지를 생성하고 복구 모드에서 QEMU에 마운트하는 중에 문제 발생

원시 디스크 이미지에서 부팅 시스템을 만들려고 합니다. 이것이 내가 한 일입니다:

$ dd if=/dev/zero of=system2.img bs=1M count=6000
6000+0 records in
6000+0 records out
6291456000 bytes (6.3 GB) copied, 69.3662 s, 90.7 MB/s
$ sudo fdisk system2.img
Command (m for help): o
Building a new DOS disklabel with disk identifier 0xdd22ed22.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): w
The partition table has been altered!

Syncing disks.
$ sudo fdisk system2.img

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-12287999, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-12287999, default 12287999):
Using default value 12287999

Command (m for help): a
Partition number (1-4): 1

Command (m for help): w
The partition table has been altered!

Syncing disks.
$ sudo kpartx -avs system2.img
add map loop1p1 (252:0): 0 120832 linear /dev/loop1 2048
$ sudo mkfs.ext4 -U c0f21c98-ebf4-4f27-91b8-205da17c7893 /dev/mapper/loop1p1
mke2fs 1.42 (29-Nov-2011)
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
15104 inodes, 60416 blocks
3020 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=61865984
8 block groups
8192 blocks per group, 8192 fragments per group
1888 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

그런 다음 이 디스크 이미지를 QEMU 및 복구 모드(debian netinst ISO에서 부팅)와 함께 사용해 보았습니다. 설치할 수 있었지만 /dev/sda1실패했습니다. FAT를 /var/log/syslog보는 것 같습니다 ./dev/sda1

복구 모드에서 작동하는 다른 디스크 이미지가 있습니다. 내가 찾을 수 있는 유일한 차이점은 작업 이미지를 보면 cfdisk첫 번째 파티션 유형이 ext4실패한 이미지에 표시된다는 것입니다.Linux

답변1

분명히 버그 가 있습니다 kpartx. 다음 명령 순서는 유효합니다.

$ sudo losetup --show --find system2.img
/dev/loop5
$ sudo kpartx -avs /dev/loop5

디스크 이미지 파일은 직접 제공되어서는 안 됩니다.kpartx

우분투 12.04에서 테스트됨

관련 정보