Raspberry pi Zero2WのSSD化−3

前回の記事で/dev/sda2のSSDルートで立ち上がった、次にSSDのファイル拡張とSWAPファイル追加をする

⑦SSDのファイル拡張・・・raspi-config–> Advanced Options –> Expand Filesystem –> rebbot

root@iot008:/home/pi# df
Filesystem     1K-blocks    Used Available Use% Mounted on
udev               75508       0     75508   0% /dev
tmpfs              42832    2920     39912   7% /run
/dev/sda2        6897176 3265900   3259616  51% /
tmpfs             214152       0    214152   0% /dev/shm
tmpfs               5120       8      5112   1% /run/lock
tmpfs             102400       0    102400   0% /tmp
tmpfs              65536      60     65476   1% /var/log
tmpfs             204800    6656    198144   4% /www
/dev/sda1         523244   62896    460348  13% /boot/firmware
tmpfs              42828       4     42824   1% /run/user/1000

root@iot008:/home/pi# raspi-config

Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.


Command (m for help):
Disk /dev/sda: 223.57 GiB, 240057409536 bytes, 468862128 sectors
Disk model: ESD-EC_R
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: dos
Disk identifier: 0xa168ebd8

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1          8192  1056767  1048576  512M  c W95 FAT32 (LBA)
/dev/sda2       1056768 15267839 14211072  6.8G 83 Linux

Command (m for help): Partition number (1,2, default 2):
Partition 2 has been deleted.

Command (m for help): Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): Partition number (2-4, default 2): First sector (2048-468862127, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (1056768-468862127, default 468862127):
Created a new partition 2 of type 'Linux' and of size 223.1 GiB.
Partition #2 contains a ext4 signature.

Command (m for help):
Disk /dev/sda: 223.57 GiB, 240057409536 bytes, 468862128 sectors
Disk model: ESD-EC_R
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: dos
Disk identifier: 0xa168ebd8

Device     Boot   Start       End   Sectors   Size Id Type
/dev/sda1          8192   1056767   1048576   512M  c W95 FAT32 (LBA)
/dev/sda2       1056768 468862127 467805360 223.1G 83 Linux

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


Broadcast message from root@iot008 on pts/1 (Sun 2024-06-16 18:01:26 JST):

The system will reboot now!

⑧再起動後再度ログイン、拡張された事を確認しSWAPファイルの追加

pi@iot008:~ $ sudo su
root@iot008:/home/pi# df
Filesystem     1K-blocks    Used Available Use% Mounted on
udev               75508       0     75508   0% /dev
tmpfs              42832    3004     39828   8% /run
/dev/sda2      230165024 3265900 217459940   2% /
tmpfs             214152       0    214152   0% /dev/shm
tmpfs               5120       8      5112   1% /run/lock
tmpfs             102400       0    102400   0% /tmp
tmpfs              65536      56     65480   1% /var/log
tmpfs             204800    6656    198144   4% /www
/dev/sda1         523244   62896    460348  13% /boot/firmware
tmpfs              42828       4     42824   1% /run/user/1000
root@iot008:/home/pi#
# free
               total        used        free      shared  buff/cache   available
Mem:          428308      225740       96216        9960      173812      202568
Swap:              0           0           0

root@iot008:/home/pi# dphys-swapfile swapon
root@iot008:/home/pi# free
               total        used        free      shared  buff/cache   available
Mem:          428308      225140       91800        9460      178156      203168
Swap:         102396         520      101876
root@iot008:/home/pi#
# ll /var/swap
-rw------- 1 root root 104857600 Nov 23  2023 /var/swap

スワップファイル/var/sawpが追加された

この後upgradeで中にSSDアクセス・ランプ点滅で長時間固まったなので/etc/dphys-swapfileを編集して容量を増やす・・・SD版IOT-HouseはSDのスワップを無効化しているSSD版で運用する場合はdphys-swapfile有効化が必要

# vim.tiny /etc/dphys-swapfile
#   you most likely don't want this, unless you have an special disk situationCONF_SWAPSIZE=200
#CONF_SWAPSIZE=200
CONF_SWAPSIZE=1000

# systemctl enable dphys-swapfile
.
# systemctl restart dphys-swapfile
.
# uname -a
Linux iot008 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux

root@iot008:/www/remote-hand/tmp# free 
               total        used        free      shared  buff/cache   available
Mem:          428308      150168      144404         348      199696      278140
Swap:        9285564      107688     9177876

以下次回に続く

Follow me!

IOT

前の記事

Raspberry pi Zero2WのSSD化−2
IOT

次の記事

Raspberry pi Zero2WのSSD化まとめ