0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Fedora Arm イメージを分解する(kpartx)

Posted at

Fedora Arm イメージを分解します

準備

$ rpm -q kpartx

インストールされていなければ、インストールします。

# dnf install kpartx

Fedora の ARM イメージを解凍します。

$ unxz Fedora-Workstation-armhfp-28-1.1-sda.raw.xz

解凍されると、以下のようになります。

Fedora-Workstation-armhfp-28-1.1-sda.raw

file コマンドで確認します。

$ file Fedora-Workstation-armhfp-28-1.1-sda.raw
Fedora-Workstation-armhfp-28-1.1-sda.raw: DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x4,4,1), end-CHS (0x78,119,2), startsector 2048, 59392 sectors; partition 2 : ID=0x83, active, start-CHS (0x78,120,1), end-CHS (0x3ff,254,2), startsector 61440, 999424 sectors; partition 3 : ID=0x82, start-CHS (0x3ff,254,2), end-CHS (0x3ff,254,2), startsector 1060864, 999424 sectors; partition 4 : ID=0x83, start-CHS (0x3ff,254,2), end-CHS (0x3ff,254,2), startsector 2060288, 12109824 sectors

.raw を、 .img にリネームします。

$ mv Fedora-Workstation-armhfp-28-1.1-sda.raw Fedora-Workstation-armhfp-28-1.1-sda.img

kpartx を実行します。

# kpartx -a Fedora-Workstation-armhfp-28-1.1-sda.img

/dev/mapper を確認します。

# ls -l /dev/mapper/
合計 0
crw-------. 1 root root 10, 236 7月 13 19:07 control
lrwxrwxrwx. 1 root root 7 7月 13 19:07 docker-253:0-3154371-pool -> ../dm-3
lrwxrwxrwx. 1 root root 7 7月 13 19:07 fedora-home -> ../dm-2
lrwxrwxrwx. 1 root root 7 7月 13 19:07 fedora-root -> ../dm-0
lrwxrwxrwx. 1 root root 7 7月 13 19:07 fedora-swap -> ../dm-1
lrwxrwxrwx. 1 root root 7 7月 13 19:54 loop2p1 -> ../dm-4
lrwxrwxrwx. 1 root root 7 7月 13 19:54 loop2p2 -> ../dm-5
lrwxrwxrwx. 1 root root 7 7月 13 19:54 loop2p3 -> ../dm-6
lrwxrwxrwx. 1 root root 7 7月 13 19:54 loop2p4 -> ../dm-7

loop2p1 から、loop2p4 までが、Fedora Arm と思われます。

以下の手順でマウントします。

# mkdir /mnt/{Fedora,Fedora-2,Fedora-3,Fedora-4}
# mount /dev/mapper/loop0p1 /mnt/fedora-1
# mount /dev/mapper/loop0p1 /mnt/fedora-2
# mount /dev/mapper/loop0p1 /mnt/fedora-3
# mount /dev/mapper/loop0p1 /mnt/fedora-4

では、それぞれを確認してみます。

# ls -l /mnt/Fedora
合計 13006
-rwxr-xr-x. 1 root root 52064 4月 25 15:37 bootcode.bin
-rwxr-xr-x. 1 root root 1105 4月 25 15:37 config-64.txt
-rwxr-xr-x. 1 root root 1181 4月 25 15:37 config.txt
-rwxr-xr-x. 1 root root 6575 4月 25 15:37 fixup.dat
-rwxr-xr-x. 1 root root 2599 4月 25 15:37 fixup_cd.dat
-rwxr-xr-x. 1 root root 9726 4月 25 15:37 fixup_db.dat
-rwxr-xr-x. 1 root root 9730 4月 25 15:37 fixup_x.dat
drwxr-xr-x. 2 root root 12288 4月 25 15:37 overlays
-rwxr-xr-x. 1 root root 410560 4月 25 15:37 rpi2-u-boot.bin
-rwxr-xr-x. 1 root root 421224 4月 25 15:37 rpi3-u-boot.bin
-rwxr-xr-x. 1 root root 2825124 4月 25 15:37 start.elf
-rwxr-xr-x. 1 root root 673444 4月 25 15:37 start_cd.elf
-rwxr-xr-x. 1 root root 4968292 4月 25 15:37 start_db.elf
-rwxr-xr-x. 1 root root 3912164 4月 25 15:37 start_x.elf
# ls -l /mnt/Fedora-2
合計 65056
drwxr-xr-x. 3 root root 4096 4月 25 15:32 239f94d4501440c9b6524057b3972fc4
-rw-------. 1 root root 3436883 4月 24 09:48 System.map-4.16.3-301.fc28.armv7hl
-rw-r--r--. 1 root root 209896 4月 24 09:48 config-4.16.3-301.fc28.armv7hl
lrwxrwxrwx. 1 root root 27 4月 25 15:32 dtb -> dtb-4.16.3-301.fc28.armv7hl
drwxr-xr-x. 2 root root 36864 4月 25 15:23 dtb-4.16.3-301.fc28.armv7hl
drwxr-xr-x. 2 root root 4096 4月 25 15:37 extlinux
drwxrwxr-x. 2 root root 4096 4月 25 15:13 fw
drwxrwxr-x. 2 root root 4096 4月 25 15:37 grub
drwxr-xr-x. 3 root root 4096 4月 25 15:19 grub2
-rw-------. 1 root root 56166524 4月 25 15:34 initramfs-4.16.3-301.fc28.armv7hl.img
drwx------. 2 root root 16384 4月 25 15:13 lost+found
-rwxr-xr-x. 1 root root 6672896 4月 24 09:49 vmlinuz-4.16.3-301.fc28.armv7hl
# ls -l /mnt/Fedora-3
合計 0
# ls -l /mnt/Fedora-4
合計 84
lrwxrwxrwx. 1 root root 7 2月 7 19:27 bin -> usr/bin
drwxrwxr-x. 2 root root 4096 4月 25 15:13 boot
drwxr-xr-x. 4 root root 4096 4月 25 15:32 dev
drwxr-xr-x. 131 root root 12288 4月 25 15:37 etc
drwxr-xr-x. 2 root root 4096 2月 7 19:27 home
lrwxrwxrwx. 1 root root 7 2月 7 19:27 lib -> usr/lib
drwx------. 2 root root 16384 4月 25 15:13 lost+found
drwxr-xr-x. 2 root root 4096 2月 7 19:27 media
drwxr-xr-x. 2 root root 4096 2月 7 19:27 mnt
drwxr-xr-x. 2 root root 4096 2月 7 19:27 opt
drwxrwxr-x. 2 root root 4096 4月 25 15:13 proc
dr-xr-x---. 2 root root 4096 4月 25 15:37 root
drwxr-xr-x. 32 root root 4096 4月 25 15:31 run
lrwxrwxrwx. 1 root root 8 2月 7 19:27 sbin -> usr/sbin
drwxr-xr-x. 2 root root 4096 2月 7 19:27 srv
drwxrwxr-x. 2 root root 4096 4月 25 15:13 sys
drwxrwxrwt. 2 root root 4096 4月 25 15:37 tmp
drwxr-xr-x. 11 root root 4096 4月 25 15:15 usr
drwxr-xr-x. 22 root root 4096 4月 25 15:31 var

好きな作業をしてください。
アンマウントします。

# umount /mnt/Fedora-4
# umount /mnt/Fedora-3
# umount /mnt/Fedora-2
# umount /mnt/Fedora

ファイルを戻します。

# kpartx -d Fedoara-Workstation-armhfp-28-1.1-sda.img

確認します。

$ ls
Fedora-Workstation-armhfp-28-1.1-sda.img

ファイル名も戻します。

$ mv Fedora-Workstation-armhfp-28-1.1-sda.img Fedora-Workstation-armhfp-28-1.1-sda.raw

圧縮します(かなりの時間がかかります)。

# xz Fedora-Workstation-armhfp-28-1.1-sda.raw

SDカードに書き込みます。

# dnf install -y fedora-arm-installer

以下のコマンドを実行します。

# shred -v /dev/mmcblk0p1
# shred -v /dev/mmcblk0p2
# mkfs.vfat /dev/mmcblk0p1
# mkfs.ext4 /dev/mmcblk0p2
# arm-image-installer --image=Fedora-Workstation-armhfp-28-1.1-sda.raw.xz --target=Bananapi --media=/dev/mmcblk0

(参考)
https://fedoraproject.org/wiki/Architectures/ARM/Raspberry_Pi
https://linuxconfig.org/how-to-extract-xz-compressed-archive-on-linux
https://medium.com/@madhav2code/how-to-mount-fedora-atomic-host-image-to-local-directory-file-system-98bae20751c1

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?