sudo echo <HOSTNAME> | sudo tee /etc/hostname
sudo hostnamectl set-hostname <HOSTNAME>
$ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 kumarin.co kumarin ...
サービススペック変更で自動的にディスクが拡張された場合も必要。
fdisk や growpart でやる方法は さくら公式 にあるので、別のやり方で(?)。
ルートパーティション拡張はできなさそうなので、新規に追加する。
parted でパーティション一覧を出すと、GPT の修正を提案されるので受け入れる。
$ parted
$ (parted) print Warning: Not all of the space available to /dev/vda appears to be used, you can fix the GPT to use all of the space (an extra 41943040 blocks) or continue with the current setting? Fix/Ignore? # F
まだパーティションの合計は 30GB のときのまま。
Model: Virtio Block Device (virtblk) Disk /dev/vda: 53.7GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 263MB 262MB ext4 Linux filesystem 2 263MB 2411MB 2147MB linux-swap(v1) Linux swap 3 2411MB 32.2GB 29.8GB ext4 Linux filesystem
新しいパーティションを作る。
$ (parted) mkpart Partition name? []? # data File system type? [ext2]? # ext2 Start? # 32.2GB End? # 53.7GB
ext4 は対応していないようで怒られてしまった。
No Implementation: Support for creating ext4 file systems is not implemented yet.
警告が出るけど気にしない。
Warning: WARNING: the kernel failed to re-read the partition table on /dev/vda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.
パーティション一覧を再表示。
(parted) print Model: Virtio Block Device (virtblk) Disk /dev/vda: 53.7GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 263MB 262MB ext4 Linux filesystem 2 263MB 2411MB 2147MB linux-swap(v1) Linux swap 3 2411MB 32.2GB 29.8GB ext4 Linux filesystem 4 32.2GB 53.7GB 21.5GB ext2 data
パーティションが追加されたので parted を閉じる。ありがたいお知らせ付き。
$ (parted) quit Information: You may need to update /etc/fstab.
パーティションテーブルが再読み込みできなかったそうなのでリブートする。
その後 /dev/vda4 が追加されているか確認する。
ext4 にするには以下を入力してまたリブート。
mkfs.ext4 /dev/vda4
fstab に作成したパーティションを追加する。
mkdir /data id=$(blkid -o value -s UUID /dev/vda4) echo "UUID=${id} /data ext4 defaults 0 2" | sudo tee /etc/fstab
https://manual.sakura.ad.jp/vps/server/disk-expansion/index.html
https://www.tecmint.com/parted-command-to-create-resize-rescue-linux-disk-partitions/