ラベル コンピュータ(ソフト) の投稿を表示しています。 すべての投稿を表示
ラベル コンピュータ(ソフト) の投稿を表示しています。 すべての投稿を表示

2023/07/14

mdmadmでのRAID1の再構成後に、OSが起動しない場合の対処法

OSを再起動した際、下記のようなエラーが出た。/パーティションがみつからないというエラー。

>>Determining root device (trying UUID=0c0ea181-ccdd-428b-820e-0f1f039470eb) ....
!! Block device UUID=0c0ea181-ccdd-428b-820e-0f1f039470eb is not a valid root device ...
!! Could not find the root block device in UUID=0c0ea181-ccdd-428b-820e-0f1f039470eb.
!! Please specify another value or:
!! - press Enter for the same
!! - type "shell" for a shell
!! - type "q" to skip ...
root block device(UUID=0c0ea181-ccdd-428b-820e-0f1f039470eb) ::


【解決】mdadmでのRAID1にNVMe SSDを追加後、再起動したらOSが起動しない(RAID Arrayが起動しない)

mdadmで構成管理しているRAID1の構成を変更した。これまではSATA SSD 2本(1本は内蔵、もう一本はUSB Type-Cでの外付け)であったが、外付けのSSDをNVMe SSD(内蔵)に変更した。

変更自体はサクッと終わったが、再起動したらRAID1 Arrayが立ち上がってこない(/パーティションのArrayが上がってこないので、ブートに失敗する)。何度再構成しても、再起動したら消える。

2023/07/08

【解決】virsh attach-diskで、Windows仮想PCへCD-ROMがマウントできない

Windows11をQEMU上で動かしており、CD-ROMをマウントさせようとした。

# virsh attach-disk --domain Win11VM --type cdrom --target sda --source /path-to/Win11_22H2_Japanese_x64v2.iso --mode readonly --config
Disk attached successfully


--taragetはsdaやsdb、vdaやvdcといったディスクドライブを指しているようだ。

コマンドの反応からは登録できているように見えるが、OSを立ち上げてみるとCD-ROMドライブがエクスプローラ上に出てこない

2022/08/27

【解決】Windows10/11の「切り取り&スケッチ」が前回利用したファイル形式を覚えてくれない

Windows10/11で、「切り取り&スケッチ」(切り取り領域とスケッチ)を使ってスクリーンショットを撮り、PNG形式で保存した際、前回使用したファイル形式を覚えてくれず、「ファイル名」に表示される拡張子はPNGだが、「ファイルの種類」としてはJPG形式が選ばれる。


PNGで保存するには、ファイル形式をPNGに変換しなければならず、非常に不便であった。

2022/08/13

Google Code PrettifyからPrism.jsへ移行(Blogger)

Google Code Prettifyは、2020年4月22日にメンテされていないのでアーカイブしますというメッセージが残され、更新が止まっている。また、プログラムコードではないことを指すlanguate-noneの設定ができないので、何でもかんでも色付けされてしまうこともあり、Prism.jsを利用することにした。

外付けUSB SATAディスクのS.M.A.R.T.監視

smartdの起動が失敗している

# /etc/init.d/smartd start
 * Starting smartd ...
 * start-stop-daemon: failed to start `/usr/sbin/smartd'
 * Failed to start smartd
 * ERROR: smartd failed to start

これだけでは何が原因かわからず放置していたが、調査することに。

2022/08/12

Hexダンプのやり方に関するメモ

文字コードについて調べていて、Hexダンプのやり方を気をつけないと、表記がビッグエンディアンなのか、リトルエンディアンなのか、わからなくなるのでメモ。

xxd(Vim付属)、hexdump、odあたりのコマンドが使われると思うので、その3つについて。

2022/06/11

LinuxのRAIDディスクの移植(PCの機体を交換)

サーバにしていたPCの電源が入らなくなったので、PC本体を交換し、ディスクはそのまま移植することにした。

新PCではSSDのスロットが1個しかないので、今まではSATA SSD x2で運用していたが、SATA SSD + M.2 SSDの構成に変更する。


学んだこと

SATAのディスクをそのまま付け替えてもBIOS(UEFIだった)が起動可能ディスクとして認識しない。USBブートで起動させると、認識はしているのでディスクが壊れているわけではない。

旧PCはBIOS機、新PCはUEFI機であり、そのままディスクを差し替えても、起動可能ディスクとして認識されない。

UEFIで起動できるようにパーティション構成を変更する必要がある。

運良く、GPTで構成していたので最小限で済んだ。


RAIDは片系のみ

このLinuxはGentooなので、GentooのAdmin CD(Minumal Installation CDではコマンドが足りない。と思うが、それは試行錯誤したせいで、最短コースで進めばMinimal Installation CDでも良かったのかもしれない。)をダウンロードして、Rufus等でUSBに書き込む。

USBブートで起動して、RAIDの状況を確認する。

# cat /proc/mdstat
Personalities : [raid1]
md125 : inactive sda4[2](S)
      209584128 blocks super 1.2

md126 : inactive raid1 sda3[2](S)
      62913536 blocks super 1.2

md127 : inactive raid1 sda1[0](S)
      524224 blocks

unused devices: <none>

一応、RAIDのディスクであることは認識されているようだ。ただし、どれもinactive。RAIDを一旦停止して、再度登録する。例えば、/dev/md127を停止した後に、Scanさせると/dev/md1として認識され、activeになった。

# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda1[0]
      524224 blocks [2/1] [U_]

md125 : inactive sda4[2](S)
      209584128 blocks super 1.2

md126 : inactive raid1 sda3[2](S)
      62913536 blocks super 1.2

unused devices: <none>

具体的なコマンド(/dev/md126についての例)

# mdadm --detail /dev/md126
/dev/md126:
           Version : 1.2
        Raid Level : raid0
     Total Devices : 1
       Persistence : Superblock is persistent

             State : inactive
   Working Devices : 1

Consistency Policy : resync

              Name : edo:/
              UUID : 1a4518b9:879d5121:f1651760:8b1a1f02
            Events : 35387

    Number   Major   Minor   RaidDevice

       -       8        3        -      /dev/sda3

# mdadm --examine /dev/md126
#
# mdadm --stop /dev/md126
mdadm: stopped /dev/md126
# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda1[0]
      524224 blocks [2/1] [U_]

md125 : inactive sda4[2](S)
      209584128 blocks super 1.2

unused devices: <none>

# mdadm --assemble --scan
mdadm: /dev/md/edo:- has been started with 1 drive (out of 2).
# cat /proc/mdstat
Personalities : [raid1]
md127 : active raid1 sda3[2](S)
      62913536 blocks super 1.2 [2/1] [U_]

md1 : active raid1 sda1[0]
      524224 blocks [2/1] [U_]

md125 : inactive sda4[2](S)
      209584128 blocks super 1.2

unused devices: <none>

こんな感じで/dev/md126はなくなり、/dev/md127としてactiveな状態になった。/dev/md125も同様。

# mdadm --detail /dev/md125
/dev/md125:
           Version : 1.2
        Raid Level : raid0
     Total Devices : 1
       Persistence : Superblock is persistent

             State : inactive
   Working Devices : 1

Consistency Policy : resync

              Name : edo:/data
              UUID : 8f55590b:38f15e8a:4ea20fad:c34229d8
            Events : 11921

    Number   Major   Minor   RaidDevice

       -       8        3        -      /dev/sda4

# mdadm --examine /dev/md125
#
# mdadm --stop /dev/md125
mdadm: stopped /dev/md125
# cat /proc/mdstat
Personalities : [raid1]
md127 : active raid1 sda3[2](S)
      62913536 blocks super 1.2 [2/1] [U_]

md1 : active raid1 sda1[0]
      524224 blocks [2/1] [U_]

unused devices: <none>

# mdadm --assemble --scan
mdadm: /dev/md/edo:- has been started with 1 drive (out of 2).
# cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sda4[2](S)
      209584128 blocks super 1.2 [2/1] [U_]
      bitmap: 0/2 pages [0KB], 65536KB chunk

md127 : active raid1 sda3[2](S)
      62913536 blocks super 1.2 [2/1] [U_]

md1 : active raid1 sda1[0]
      524224 blocks [2/1] [U_]

unused devices: <none>

これでRAID全部がactiveになった。ネットの記事ではこの後リブートさせるとあったが、手元の環境ではリブートすると元に戻っていた(3つともinactiveになっていた)。

同じ作業を繰り返し、ごちゃごちゃいじったあとに再起動した際は、activeのままだったので、直後にリブートしてはいけないのかもしれない。

ともあれ、activeになったあとはmountできるようになる

# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda1[0]
      524224 blocks [2/1] [U_]

md126 : active raid1 sda3[2]
      62913536 blocks super 1.2 [2/1] [U_]

md125 : active raid1 sda4[2]
      209584128 blocks super 1.2 [2/1] [U_]
      bitmap: 1/2 pages [4KB], 65536KB chunk

unused devices: <none>

# mount /dev/md1 /boot

grub2のインストールを試みる(が、失敗する。これのやり方はBIOS用なので当然失敗する)

# grub-install /dev/sda
Installing for x86_64-efi platform.
grub-instsall: error: cannot find EFI directory.

EFIディレクトリがないと言われるので、/etc/fstabにマウントポイントの情報が必要っぽいが、USBブートなので今の/etc/fstabに書き込んでも仕方がない。chrootする。

# umount /boot
# mount /dev/md127 /mnt/gentoo
# mount /dev/md1 /mnt/gentoo/boot
# mount /dev/md126 /mnt/gentoo/data
# chroot /mnt/gentoo
# grub-install /dev/sda
Installing for i386-pc platform.
grub-install: error: cannot find a devcie for /boot/grub (Is /dev/ mounted?)
#

chrootの前には/devや/sysなどのシステム関連をマウントする必要があった。マウントすべきものはGentoo handbookのchrootの所を参照:

# exit
# mount --types proc /proc /mnt/gentoo/proc
# mount --rbind /sys /mnt/gentoo/sys
# mount --make-rslave /mnt/gentoo/sys
# mount --rbind /dev /mnt/gentoo/dev
# mount --make-rslave /mnt/gentoo/dev
# mount --bind /run /mnt/gentoo/run
# mount --make-slave /mnt/gentoo/run
# chroom /mnt/gentoo
# grub-install /dev/sda
installing for x86_64-efi platform.
grub-install: error: cannot find EFI directory.
#

またエラー。/mnt/gentoo/etc/fstabに入力されている/dev/mdXXXの番号と、今回表示されている番号が異なるので、fstabを更新してみたが同じエラー。

grub-install時にefiのディレクトリの場所を指定する必要があるのかと思い、調べて下記を実行

# grub-install --target=x86_64-efi --efi-directory=/boot
Installing for x86_64-efi platform.
grub-install: error: /boot doesn't look like an EFI pertition.

このEFI pertitionに見えないというエラーがヒントになり、ネットの情報から、BIOSとEFIでGrub2用のパーティションが違うことに気がついた。

https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Bootloader/ja

    • BIOS を利用する場合:
root #grub-install /dev/sda
    • UEFI を利用する場合:
 Important
grub-install を実行する前に EFI システムパーティションがマウントされているか必ず確認してください。 grub-install が GRUB EFI ファイル (grubx64.efi) を間違ったディレクトリにインストールしてしまい、しかも間違ったディレクトリが使われた形跡をまったく残さないということが起こりえます。
root #grub-install --target=x86_64-efi --efi-directory=/boot
 Note
--efi-directory オプションは、 EFI システムパーティションのルートに変更してください。これは /boot パーティションが FAT の亜種でフォーマットされていない場合、必須です。


 https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Disks/ja

EFI システムパーティション (ESP) とは

オペレーティングシステムを起動するのに (BIOS ではなく) UEFI を使うシステムに Gentoo をインストールするときは、EFI システムパーティションを作成することが重要です。この手順については後述の説明でも述べます。BIOS/Legacy モードで起動する場合には、EFI システムパーティションは不要です。


ということで、パーティションの切り直しが必要。

もともとのパーティション

# fdisk -l /dev/sda
Disk /dev/sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 850
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 431735A7-BD0D-410F-A96C-C292628A24CA

Device         Start       End   Sectors  Size Type
/dev/sda1       2048   1050623   1048576  512M Linux RAID
/dev/sda2    1050624   1116159     65536   32M BIOS boot
/dev/sda3    1116160 126945279 125829120   60G Linux RAID
/dev/sda4  126945280 546375679 419430400  200G Linux RAID
/dev/sda5  546375680 963708927 417333248  199G Linux RAID
/dev/sda6  963708928 976773134  13064207  6.2G Linux swap


UEFI対応にするにはGPTでパーティションを切る必要があるとのことだが、運良く、GPTで作成していたのでディスク全体でのパーティションの切り直しは不要。

/dev/sda1 (=/boot) のパーティションのタイプをEFI Systemに変更し、FAT32でフォーマットすれが良さそう。/bootの中身をコピーしておく。

fdiskを立ち上げると「This disk is currentl in use」と警告が生じされたので、再起動をしたが表示される。swapを全てoffにしても表示されるので、使っていないはず!と考えて無視した。(実際にはRAIDになっているので使われていたのだが。)

# cp -a /boot /boot_tmp
# swapoff --all
# fdisk /dev/sda
---中略----
Command (m for help): t
Pertition number (1-6, default 6): 1
Pertition type or alias (Type L to list all): 1

Changed type of partition 'Linux RAID' to 'EFI System'. 

Command (m for help): w
The partition table has been altered. 
Syncing disks. 

# mkfs.vfat -F 32 /dev/sda1
mkfs.fat 4.2 (2021-01-31)
mkfs.vfat: unable to open /dev/sda1: Device or resource busy

fdiskでの警告と同様、mkfs.vfatでもエラーが出た。lsofでみると確かに/dev/mdXXXにアクセスしている人がいるのだが、よくわからない。いろいろ調べて、再度再起動もして、mountはされていない、/etc/mtabにも記載はない、multipath -llでも何も返ってこない(multipathdも動いていない)、fuser /dev/sdaもfuser /dev/sda1も何も返さない、ということでわからず。ふと、RAIDを止めたらどうなるんだ?と思い、停止したらできた。

# mdadm --stop /dev/md127
# mkfs.vfat -F 32 /dev/sda1
mkfs.fat 4.2 (2021-01-31)
# 

FAT32でのフォーマットが成功。

# mount /dev/md127 /mnt/gentoo
# mount --types proc /proc /mnt/gentoo/proc
# mount --rbind /sys /mnt/gentoo/sys
# mount --make-rslave /mnt/gentoo/sys
# mount --rbind /dev /mnt/gentoo/dev
# mount --make-rslave /mnt/gentoo/dev
# mount --bind /run /mnt/gentoo/run
# mount --make-slave /mnt/gentoo/run
# mount /dev/md1 /mnt/gentoo/boot
mount /mnt/gentoo/boot: unknown filesystem type 'linux_raid_member'
#

フォーマットはしたものの、RAIDの情報が残っているようだ。RAIDのsuper blockを消す。

# mdadm --zero-superblock /dev/sda1
mdadm: Couldn't open /dev/sda1 for write - not zeroing
# 

なぜだろうと思ってmountコマンドで見るけれど、マウントはされていない。が、/proc/mdstatを見るといつの間にかに勝手にRAIDが起動していた。

# mount | grep sda
# cat /proc/mdstat
Personalities : [raid1]
md127 : active raid1 sda1[0]
      524224 blocks [2/1] [U_]

md125 : active raid1 sda4[2]
      209584128 blocks super 1.2 [2/1] [U_]
      bitmap: 1/2 pages [4KB], 65536KB chunk

md126 : active raid1 sda3[2]
      62913536 blocks super 1.2 [2/1] [U_]

unused devices: <none>
# mdadm --stop /dev/md127
mdadm: stopped /dev/md127
# mdadm --zero-superblock /dev/sda1

その後、念のため、fdiskでパーティションタイプのEFI Systemに再設定して、mkfs.vfatで初期化も再度行っておいた

# mount /dev/sda1 /mnt/gentoo/boot
# chroot /mnt/gentoo
# grub-install --target=x86_64-efi --efi-directory=/boot
Installing for x86_64-efi platform.
Installation finished. No error reported.

# ls /boot
./  ../  EFI/  grub/

# cp -a /boot_tmp/System.map-* /boot
# cp -a /boot_tmp/config-* /boot
# cp -a /boot_tmp/initramfs-* /boot
# cp -a /boot_tmp/vmlinuz-* /boot
# grub-mkconfig -o /boot/grub/grub.cfg
---中略---
/user/sbin/grub-probe: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
Warning: os-prober will not be executed to detect other bootable partitions. 
Systems on them will not be added to the GRUB boot configuration. 
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

#

/boot/grub/grub.cfgを軽く見てみたが、カーネルは登録されているようなので問題なさそう。

# exit
exit
# umount -l /mnt/gentoo/dev
# umount -R /mnt/gentoo
# reboot

再起動時にboot optionを確認すると、SATA 1が認識されており、Linuxを起動できるようになった。

起動可能になってからのパーティション

# fdisk -l /dev/sda
Disk /dev/sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 850
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 431735A7-BD0D-410F-A96C-C292628A24CA

Device         Start       End   Sectors  Size Type
/dev/sda1       2048   1050623   1048576  512M EFI System
/dev/sda2    1050624   1116159     65536   32M BIOS boot
/dev/sda3    1116160 126945279 125829120   60G Linux RAID
/dev/sda4  126945280 546375679 419430400  200G Linux RAID
/dev/sda5  546375680 963708927 417333248  199G Linux RAID
/dev/sda6  963708928 976773134  13064207  6.2G Linux swap

/dev/sda2は使っていない。/dev/sda5はLVMを使ってもう一台のSSDとRAID 0を構成した領域で、日次バックアップファイルやportageのリポジトリを入れてあった所なので、なくなっても問題はない領域。





 

2022/02/08

【解決】DaVinci Resolve 17でメディア オフライン(H.265コーデック)

DaVinci Resolveの勉強を始めようとして、Pixel5で撮ったビデオを開こうとするとデカデカと「メディア オフライン」のエラーが表示される。



メディアストレージからメディアプールに入れる前の段階なので、ネットの記事によくある「再リンクすれば良い」は該当しない。

どうも4Kで撮影されていたようで、H.265 HEVCエンコードされたMP4ビデオであったことが発端のようだ。試しにWindows Media Playerで再生させようとしても、音声だけしか聞こえない。

2021/04/18

clamavとamavisd-newの連携

clamavとamavisd-newに以下のようなエラーログが出ていたので対応した。

Apr 18 11:28:26 hostname clamd[4731]: lstat() failed on: /var/lib/amavishome/tmp/amavis-20210418T112723-10120-wxSrl3Uw/parts
Apr 18 11:28:26 hostname amavis[10120]: (10120-02-4) (!)run_av (ClamAV-clamd) FAILED - unexpected , output="/var/lib/amavishome/tmp/amavis-20210418T112723-10120-wxSrl3Uw/parts: lstat() failed: Permission denied. ERROR\n"
Apr 18 11:28:26 hostname amavis[10120]: (10120-02-4) (!)ClamAV-clamd av-scanner FAILED: CODE(0x564868cfcda0) unexpected , output="/var/lib/amavishome/tmp/amavis-20210418T112723-10120-wxSrl3Uw/parts: lstat() failed: Permission denied. ERROR\n" at (eval 98) line 951.
Apr 18 11:28:26 hostname amavis[10120]: (10120-02-4) (!)WARN: all primary virus scanners failed, considering backups

2021/04/03

【解決】Java 11をGentooにインストールする方法

この記事を書いている2021年4月3日現在、GentooではJava 11はportageには入っているもののmaskがかかっていてインストールができない。

package.accept_keywordsで~amd64 (Intel 64ビット環境の場合)をつけても、emerge @worldでインストールすることもできない。
emerge dev-java/openjdk-binなどによりインストールすることはできるが、この場合、eselect java-vm listに表示されないので、javaを呼び出す際にはフルパスで指定してやる必要がある。

これでは不便なので、どうするか。

2021/01/30

ディスクイメージにパーティションを作成する

ディスクのRAWイメージの中に、パーティションを作成したい。どうするか。

ディスクイメージにGrub2をインストールする

ディレクトリをQEMUのディスクイメージに変換する作業において、ディスクイメージにブートローダーをインストールする必要があったのでやってみた。

ディレクトリをQEMU / KVM仮想ディスクイメージに変換

USBブートのUnixをディレクトリに展開して、中身をアップデートした。そのディレクトリをQEMUからブートできないものだろうか。

ということで、まずはこのディレクトリをRAWファイルに取り込む。それができれば、qemu-imgでQCOW2に変換できる。

qemu-img convert -f /dev/sdc -O qcow2 disk.qcow2

2021/01/19

cpによるディレクトリのコピー

よく忘れるのでメモ。

cpコマンドでディレクトリをコピーするとき、ディレクトリの中身だけをコピーしたい。

Could not access KVM kernel module: No such file or directory

今まで動いていたQEMUのVMが立ち上がらなくなった。

qemu-system-x86_64を起動させると、次のようなエラーが表示されて終わり。

Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize kvm: No such file or directory

2021/01/04

PostgreSQL ver.12からver.13へのアップグレード

何回かやっているはずだが、覚えていないのでPostgreSQLのアップグレードのメモ。

eselect postgresql listでインストールされているPostgreSQLのバージョンの一覧が表示されるし、デフォルトのバージョンをeselect postgresql setで指定できる。

まず、postgresql-12は停止する

続いて、/etc/conf.d/postgresql-12と、/etc/conf.d/postgresql-13の整合性を取る。

以下はrootではエラーになるので、su postgresしておく。

postgres@edo /data/lib/postgresql Mon Jan  4 21:45:37 2021 JST(+0900)
$ mkdir data13

postgres@edo /data/lib/postgresql Mon Jan  4 21:45:40 2021 JST(+0900)
$ chmod og= data13

postgres@edo /data/lib/postgresql Mon Jan  4 21:45:41 2021 JST(+0900)
$ initdb13 -E UTF8 --locale=en_US.UTF-8 --lc-collate=C /data/lib/postgresql/data13/
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locales
  COLLATE:  C
  CTYPE:    en_US.UTF-8
  MESSAGES: en_US.UTF-8
  MONETARY: en_US.UTF-8
  NUMERIC:  en_US.UTF-8
  TIME:     en_US.UTF-8
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /data/lib/postgresql/data13 ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... JST-09
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb13: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /data/lib/postgresql/data13/ -l logfile start


postgres@edo /data/lib/postgresql Mon Jan  4 21:46:00 2021 JST(+0900)
$ pg_upgrade13 -d /data/lib/postgresql/data12 -D /data/lib/postgresql/data13 -b /usr/lib64/postgresql-12/bin/ -B /usr/lib64/postgresql-13/bin/
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Creating dump of global objects                             ok
Creating dump of database schemas
                                                            ok
Checking for presence of required libraries                 ok
Checking database user is the install user                  ok
Checking for prepared transactions                          ok
Checking for new cluster tablespace directories             ok

If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.

Performing Upgrade
------------------
Analyzing all rows in the new cluster                       ok
Freezing all rows in the new cluster                        ok
Deleting files from new pg_xact                             ok
Copying old pg_xact to new server                           ok
Setting next transaction ID and epoch for new cluster       ok
Deleting files from new pg_multixact/offsets                ok
Copying old pg_multixact/offsets to new server              ok
Deleting files from new pg_multixact/members                ok
Copying old pg_multixact/members to new server              ok
Setting next multixact ID and offset for new cluster        ok
Resetting WAL archives                                      ok
Setting frozenxid and minmxid counters in new cluster       ok
Restoring global objects in the new cluster                 ok
Restoring database schemas in the new cluster
                                                            ok
Copying user relation files
                                                            ok
Setting next OID for new cluster                            ok
Sync data directory to disk                                 ok
Creating script to analyze new cluster                      ok
Creating script to delete old cluster                       ok

Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,
once you start the new server, consider running:
    ./analyze_new_cluster.sh

Running this script will delete the old cluster's data files:
    ./delete_old_cluster.sh

postgres@edo /data/lib/postgresql Mon Jan  4 21:46:19 2021 JST(+0900)
$ exit
exit


rootに戻って、PostgreSQLを起動した上で、analyze_new_cluster.shを実行。

root@edo /data/lib/postgresql Mon Jan  4 21:47:33 2021 JST(+0900)
# /etc/init.d/postgresql-13 start
 * /run/postgresql: correcting mode
 * Starting PostgreSQL 13 ...                                                                                                                                         [ ok ]

root@edo /data/lib/postgresql Mon Jan  4 21:47:39 2021 JST(+0900)
# ./analyze_new_cluster.sh
This script will generate minimal optimizer statistics rapidly
so your system is usable, and then gather statistics twice more
with increasing accuracy.  When it is done, your system will
have the default level of optimizer statistics.

If you have used ALTER TABLE to modify the statistics target for
any tables, you might want to remove them and restore them after
running this script because they will delay fast statistics generation.

If you would like default statistics as quickly as possible, cancel
this script and run:
    "/usr/lib64/postgresql-13/bin/vacuumdb" --all --analyze-only

vacuumdb: error: could not connect to database template1: FATAL:  role "root" does not exist

Done

root@edo /data/lib/postgresql Mon Jan  4 21:48:03 2021 JST(+0900)
#

で終わり。

initdbするときのEncodingやLocaleの設定が、PostgreSQL 12の設定と違うと、下記のようなエラーが出るので、適宜調整する

postgres@edo ~ Mon Jan  4 21:37:05 2021 JST(+0900)
$ pg_upgrade13 -d /data/lib/postgresql/data12 -D /data/lib/postgresql/data13 -b /usr/lib64/postgresql-12/bin/ -B /usr/lib64/postgresql-13/bin/
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Creating dump of global objects                             ok
Creating dump of database schemas
                                                            ok

encodings for database "postgres" do not match:  old "UTF8", new "SQL_ASCII"
Failure, exiting

postgres@edo ~ Mon Jan  4 21:37:44 2021 JST(+0900)
$ 
$ pg_upgrade13 -d /data/lib/postgresql/data12 -D /data/lib/postgresql/data13 -b /usr/lib64/postgresql-12/bin/ -B /usr/lib64/postgresql-13/bin/
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Creating dump of global objects                             ok
Creating dump of database schemas
                                                            ok

lc_ctype values for database "postgres" do not match:  old "en_US.UTF-8", new "C"
Failure, exiting

postgres@edo /data/lib/postgresql Mon Jan  4 21:44:19 2021 JST(+0900)
$