CentOS Userland Linux 7 armv7hlのswapパーティションを削除して、swapファイルに置き換える手順例

もう少しでCentOS 7 1810だか1811だかが出るこの時期に、今更なんですが1月ぐらいに書いていた1708用のやつ1804用に更新しました。

確認手順とかはバッサリ省いてますが、この手順で作り直したイメージをWin32 Disk ImagerとかでmicroSDに書き込んで、Raspberry Pi 3 Model B/B+あたりに挿してもらえれば動くかなと思います。

※一応手もとのRaspberry Pi 3 Model B+で起動するのは確認しました(;´∀`)

以下手順通りの実行例を載せておきます。

[root@amethyst ~]# mkdir -p /tmp/centos-rpi3/{boot,rootfs}
[root@amethyst ~]#
[root@amethyst ~]#
[root@amethyst ~]# cd /tmp/centos-rpi3
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# curl -L -O http://mirror.centos.org/altarch/7/isos/armhfp/CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   297  100   297    0     0    538      0 --:--:-- --:--:-- --:--:--   538
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  226M  100  226M    0     0  12.5M      0  0:00:18  0:00:18 --:--:-- 11.4M
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# curl -L -O http://mirror.centos.org/altarch/7/isos/armhfp/sha256sum.txt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   744  100   744    0     0   1245      0 --:--:-- --:--:-- --:--:--  1246
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# grep CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw.xz sha256sum.txt | sha256sum -c -
CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw.xz: OK
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# xz -dv CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw.xz
CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw.xz (1/1)
  100 %     226.9 MiB / 2,712.0 MiB = 0.084   112 MiB/s       0:24
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# kpartx -av CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw
add map loop0p1 (253:2): 0 1368064 linear /dev/loop0 2048
add map loop0p2 (253:3): 0 999424 linear /dev/loop0 1370112
add map loop0p3 (253:4): 0 2928640 linear /dev/loop0 2369536
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# losetup
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0         0      0         0  0 /tmp/centos-rpi3/CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# dd if=/dev/mapper/loop0p3 of=./centos-rpi3_loop0p3.img bs=512
2928640+0 records in
2928640+0 records out
1499463680 bytes (1.5 GB) copied, 7.19179 s, 208 MB/s
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# parted /dev/loop0 -s rm 2 -s rm 3
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# kpartx -uv /dev/loop0
add map loop0p1 (253:2): 0 1368064 linear /dev/loop0 2048
del devmap : loop0p3
del devmap : loop0p2
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# parted /dev/loop0 -- mkpart primary ext4 1370112s -1s
Information: You may need to update /etc/fstab.

[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# kpartx -uv /dev/loop0
add map loop0p1 (253:2): 0 1368064 linear /dev/loop0 2048
add map loop0p2 (253:3): 0 4184064 linear /dev/loop0 1370112
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# dd if=./centos-rpi3_loop0p3.img of=/dev/mapper/loop0p2
2928640+0 records in
2928640+0 records out
1499463680 bytes (1.5 GB) copied, 14.9019 s, 101 MB/s
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# e2fsck -f /dev/mapper/loop0p2
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
_/: 24096/91584 files (0.2% non-contiguous), 239593/366080 blocks
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# resize2fs /dev/mapper/loop0p2
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/mapper/loop0p2 to 523008 (4k) blocks.
The filesystem on /dev/mapper/loop0p2 is now 523008 blocks long.

[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# mount /dev/mapper/loop0p1 /tmp/centos-rpi3/boot
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# sed -i".orig" -e "s/\(mmcblk0p\)./\12/" /tmp/centos-rpi3/boot/cmdline.txt
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# umount /dev/mapper/loop0p1
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# mount /dev/mapper/loop0p2 /tmp/centos-rpi3/rootfs
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# sed -i -e "s/3/2/" /tmp/centos-rpi3/rootfs/usr/bin/rootfs-expand
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# sed -i".orig" -e '/swap/c\/swapfile swap swap noatime 0 0' /tmp/centos-rpi3/rootfs/etc/fstab
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# dd if=/dev/zero of=/tmp/centos-rpi3/rootfs/swapfile bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 0.632281 s, 849 MB/s
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# chmod 600 /tmp/centos-rpi3/rootfs/swapfile
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# mkswap /tmp/centos-rpi3/rootfs/swapfile
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=5f8d69ba-b44d-463f-b19c-c853fc426f2b
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# cat > /tmp/centos-rpi3/rootfs/etc/yum.repos.d/epel.repo < [epel]
> name=Epel rebuild for armhfp
> baseurl=https://armv7.dev.centos.org/repodir/epel-pass-1/
> enabled=1
> gpgcheck=0
>
> EOF
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# umount /dev/mapper/loop0p2
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# kpartx -dv /dev/loop0
del devmap : loop0p2
del devmap : loop0p1
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# losetup -d /dev/loop0
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]# losetup
[root@amethyst centos-rpi3]#
[root@amethyst centos-rpi3]#

コメントを残す

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

ページ先頭へ ↑