[メモ] (らずぱい) Raspbian: busterから bullseyeへアップグレード

Debian 11.0 "bullseye" が2021年8月14日に[リリースされた](https://www.debian.org/News/2021/20210814)、
ので、RaspiOSもBullseyeにしてみよう。

- こんな感じ。

    ```shell-session
    pi@raspberrypi:~ $ uname -a
    Linux raspberrypi 5.10.52-v7l+ #1441 SMP Tue Aug 3 18:11:56 BST 2021 armv7l GNU/Linux
    pi@raspberrypi:~ $ cat /etc/os-release
    PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
    NAME="Raspbian GNU/Linux"
    VERSION_ID="11"
    VERSION="11 (bullseye)"
    VERSION_CODENAME=bullseye
    ID=raspbian
    ID_LIKE=debian
    HOME_URL="http://www.raspbian.org/"
    SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
    BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
    pi@raspberrypi:~ $ gcc --version
    gcc (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110
    Copyright (C) 2020 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    pi@raspberrypi:~ $ python3 --version
    Python 3.9.2
    pi@raspberrypi:~ $
    ```


## 概要
- Raspberry Pi OSを Buster(Debian 10)から、Bullseye(Debian 11)にアップグレード 
- 素のままのらずびあん(他のパッケージをインストールしない)からのアップグレードのみ確認。
- これ↓と同様の手順

    > [\[メモ\] (らずぱい) Raspbian: Jessie から Stretchへアップグレード](https://qiita.com/mt08/items/278ef51e1d6c1259e098)
- 公式が対応するまでは、無理に移行しないほうがよいかと思う.


# 環境
- Raspberry Pi 4B
- Raspbian: 
    - `2021-05-07-raspios-buster-armhf-lite`
    - ※ `2021-05-07-raspios-buster-armhf`は、↓のようなメッセージが出てくる。`sudo apt install gcc-8-base`をすると先へはすすめる.

        ```
        The following packages have unmet dependencies:
        libc6-dev : Breaks: libgcc-8-dev (< 8.4.0-2~) but 8.3.0-6+rpi1 is to be installed
        E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
        ```

## 手順
1. Raspbianを焼いて、起動。
2. 現状のパッケージを更新・再起動

	```bash
	# 現状のパッケージを更新・再起動
	sudo sh -c 'apt update && apt upgrade -y && reboot'
	```
3. bullseyeへアップグレード

	```bash
	# パッケージレポジトリを `buster` から、`bullseye`へ変更
	sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list
	sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list.d/raspi.list
	
	# パッケージ情報更新
	sudo apt update

	# シミュレートモードで、様子見
	# apt --simulate upgrade -y

	# パッケージ更新・再起動 ... 途中、設定とかどうするかとか、きかれる。。とりあえず、Y.
	time sudo sh -c 'apt upgrade -y && apt dist-upgrade -y'

	# 再起動
	sudo reboot
	```


4. 再起動後

	```bash:お好みで
	# 不要なパッケージ削除
	sudo apt-get autoremove --purge -y
	```
    - ※python 2.xx系は削除される。



## 実行例

```
pi@raspberrypi:~ $ sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list
pi@raspberrypi:~ $ sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list.d/raspi.list
pi@raspberrypi:~ $ sudo apt update
Get:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB]
Get:2 http://archive.raspberrypi.org/debian bullseye InRelease [23.5 kB]
Get:3 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB]
Get:4 http://archive.raspberrypi.org/debian bullseye/main armhf Packages [115 kB]
Get:5 http://raspbian.raspberrypi.org/raspbian bullseye/contrib armhf Packages [60.2 kB]
Get:6 http://raspbian.raspberrypi.org/raspbian bullseye/non-free armhf Packages [106 kB]
Get:7 http://raspbian.raspberrypi.org/raspbian bullseye/rpi armhf Packages [1,360 B]
Fetched 13.5 MB in 7s (1,875 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
1061 packages can be upgraded. Run 'apt list --upgradable' to see them.
pi@raspberrypi:~ $
pi@raspberrypi:~ $ time sudo sh -c 'apt upgrade -y && apt dist-upgrade -y'
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  ...
  ...
  ...
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  ...
  ...
  ...
The following packages have been kept back:
  ...
  ...
  ...
The following packages will be upgraded:
  ...
  ...
  ...
319 upgraded, 38 newly installed, 0 to remove and 79 not upgraded.
Need to get 96.9 MB of archives.
After this operation, 38.9 MB of additional disk space will be used.
Get:1 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf base-files armhf 11.1+rpi1 [70.2 kB]
  ...
  ...
  ...
Get:357 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf xauth armhf 1:1.1-1 [36.6 kB]
Fetched 96.9 MB in 13s (7,226 kB/s)
apt-listchanges: Reading changelogs...
apt-listchanges: News
---------------------
  ...
  ...
  ...
Extracting templates from packages: 100%
Preconfiguring packages ...
(Reading database ... 98827 files and directories currently installed.)
  ...
  ...
  ...
Setting up passwd (1:4.8.1-1) ...

Configuration file '/etc/default/useradd'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** useradd (Y/I/N/O/D/Z) [default=N] ? Y
Installing new version of config file /etc/default/useradd ...
Removing obsolete conffile /etc/cron.daily/passwd ...
Selecting previously unselected package libmd0:armhf.
  ...
  ...
  ...
Processing triggers for initramfs-tools (0.140) ...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  ...
  ...
  ...
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  ...
  ...
  ...
The following NEW packages will be installed:
  ...
  ...
  ...
The following packages will be upgraded:
  ...
  ...
  ...
79 upgraded, 50 newly installed, 11 to remove and 0 not upgraded.
Need to get 126 MB of archives.
After this operation, 228 MB of additional disk space will be used.
Get:1 http://archive.raspberrypi.org/debian bullseye/main armhf python3-spidev armhf 20200602~200721-1 [12.1 kB]
  ...
  ...
  ...
Get:129 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf wpasupplicant armhf 2:2.9.0-21 [1,027 kB]
Fetched 126 MB in 13s (9,643 kB/s)
apt-listchanges: Reading changelogs...
apt-listchanges: News
---------------------
  ...
  ...
  ...
Extracting templates from packages: 100%
Preconfiguring packages ...
(Reading database ... 41433 files and directories currently installed.)
  ...
  ...
  ...
Processing triggers for mailcap (3.69) ...

real    11m35.158s
user    4m19.591s
sys     2m43.023s
pi@raspberrypi:~ $
pi@raspberrypi:~ $ sudo reboot



```

- ↓パッケージのアップデート中に確認しないで、サービスの再起動していいか？、と...  
[Yes] を選択
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/75594/9e5d19a5-b36c-a443-9af7-e62893ff07e0.png)


## その他