2020/08/02

mdadmによるRAID1の縮小とRAID1・RAID0の拡張(fdisk実施)

2本のディスクでLinuxを走らせているが、キャッシュ的なファイルを保存しているパーティション(mdadmを使ったRAID0で構築)を広げたくなった。 RAID1で構築しているパーティションが余っていたので、その領域を縮小させ、こちらのパーティションを拡張する。

mdadmでの準備作業は終わったので、fdiskでパーティションを変更する。

忘れやすいので、swapパーティションをオフラインにすることを忘れないように注意
root@edo /
# swapoff /dev/sdb6

root@edo /
# swapon
NAME      TYPE      SIZE USED PRIO
/dev/sda6 partition   6G   0B    1

fdiskで/dev/sdbを操作。
sdb3(/パーティション用)も拡張したい。(どうやってオフラインにするかは今度考えるけど、今のタイミングでパーティション自体は拡張しておく。ファイルシステムとRAIDアレイは今のままにしておけばよい。)
root@edo /
# fdisk /dev/sdb

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


Command (m for help): p
Disk /dev/sdb: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Crucial_CT500MX2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 0D638A13-AA1D-4131-8BB7-6DE88A59EDBA

Device         Start       End   Sectors  Size Type
/dev/sdb1       2048   1050623   1048576  512M Linux RAID
/dev/sdb2    1050624   1116159     65536   32M BIOS boot
/dev/sdb3   13633536  80742399  67108864   32G Linux RAID
/dev/sdb4   80742400 923797503 843055104  402G Linux RAID
/dev/sdb5  923797504 976773134  52975631 25.3G Linux RAID
/dev/sdb6    1116160  13633535  12517376    6G Linux swap

Partition table entries are not in disk order.

Command (m for help): d
Partition number (1-6, default 6): 3

Partition 3 has been deleted.

Command (m for help): d
Partition number (1,2,4-6, default 6): 4

Partition 4 has been deleted.

Command (m for help): d
Partition number (1,2,5,6, default 6): 5

Partition 5 has been deleted.

Command (m for help): d
Partition number (1,2,6, default 6): 6

Partition 6 has been deleted.

Command (m for help): p
Disk /dev/sdb: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Crucial_CT500MX2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 0D638A13-AA1D-4131-8BB7-6DE88A59EDBA

Device       Start     End Sectors  Size Type
/dev/sdb1     2048 1050623 1048576  512M Linux RAID
/dev/sdb2  1050624 1116159   65536   32M BIOS boot

Command (m for help): n
Partition number (3-128, default 3):
First sector (1116160-976773134, default 1116160):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1116160-976773134, default 976773134): +60G

Created a new partition 3 of type 'Linux filesystem' and of size 60 GiB.
Partition #3 contains a swap signature.

Do you want to remove the signature? [Y]es/[N]o: y

The signature will be removed by a write command.

Command (m for help): p
Disk /dev/sdb: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Crucial_CT500MX2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 0D638A13-AA1D-4131-8BB7-6DE88A59EDBA

Device       Start       End   Sectors  Size Type
/dev/sdb1     2048   1050623   1048576  512M Linux RAID
/dev/sdb2  1050624   1116159     65536   32M BIOS boot
/dev/sdb3  1116160 126945279 125829120   60G Linux filesystem

Filesystem/RAID signature on partition 3 will be wiped.

Command (m for help): n
Partition number (4-128, default 4):
First sector (126945280-976773134, default 126945280):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (126945280-976773134, default 976773134): +200G

Created a new partition 4 of type 'Linux filesystem' and of size 200 GiB.

Command (m for help): n
Partition number (5-128, default 5):
First sector (546375680-976773134, default 546375680):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (546375680-976773134, default 976773134): +199G

Created a new partition 5 of type 'Linux filesystem' and of size 199 GiB.

Command (m for help): n
Partition number (6-128, default 6):
First sector (963708928-976773134, default 963708928):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (963708928-976773134, default 976773134):

Created a new partition 6 of type 'Linux filesystem' and of size 6.2 GiB.

Command (m for help): p
Disk /dev/sdb: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Crucial_CT500MX2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 0D638A13-AA1D-4131-8BB7-6DE88A59EDBA

Device         Start       End   Sectors  Size Type
/dev/sdb1       2048   1050623   1048576  512M Linux RAID
/dev/sdb2    1050624   1116159     65536   32M BIOS boot
/dev/sdb3    1116160 126945279 125829120   60G Linux filesystem
/dev/sdb4  126945280 546375679 419430400  200G Linux filesystem
/dev/sdb5  546375680 963708927 417333248  199G Linux filesystem
/dev/sdb6  963708928 976773134  13064207  6.2G Linux filesystem

Filesystem/RAID signature on partition 3 will be wiped.

Command (m for help): t
Partition number (1-6, default 6): 3
Partition type (type L to list all types): 29

Changed type of partition 'Linux filesystem' to 'Linux RAID'.

Command (m for help): t
Partition number (1-6, default 6): 4
Partition type (type L to list all types): 29

Changed type of partition 'Linux filesystem' to 'Linux RAID'.

Command (m for help): t
Partition number (1-6, default 6): 5
Partition type (type L to list all types): 29

Changed type of partition 'Linux filesystem' to 'Linux RAID'.

Command (m for help): t
Partition number (1-6, default 6):
Partition type (type L to list all types): 19

Changed type of partition 'Linux filesystem' to 'Linux swap'.

Command (m for help): p
Disk /dev/sdb: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Crucial_CT500MX2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 0D638A13-AA1D-4131-8BB7-6DE88A59EDBA

Device         Start       End   Sectors  Size Type
/dev/sdb1       2048   1050623   1048576  512M Linux RAID
/dev/sdb2    1050624   1116159     65536   32M BIOS boot
/dev/sdb3    1116160 126945279 125829120   60G Linux RAID
/dev/sdb4  126945280 546375679 419430400  200G Linux RAID
/dev/sdb5  546375680 963708927 417333248  199G Linux RAID
/dev/sdb6  963708928 976773134  13064207  6.2G Linux swap

Filesystem/RAID signature on partition 3 will be wiped.

Command (m for help): w
The partition table has been altered.
Failed to remove partition 6 from system: Device or resource busy
Failed to add partition 3 to system: Device or resource busy
Failed to add partition 6 to system: Device or resource busy

The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.


赤字にしたところのPartition 6は、swapoffができていなかったので、使用中だったため。swapoffして、fdiskをやり直しておいた。
Partition 3は不明。
でも、やり直したら何もエラーが出なかったので問題ないだろう。(本当であれば、ここで再起動すべき)
root@edo /
# fdisk /dev/sdb

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


Command (m for help): p
Disk /dev/sdb: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Crucial_CT500MX2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 0D638A13-AA1D-4131-8BB7-6DE88A59EDBA

Device         Start       End   Sectors  Size Type
/dev/sdb1       2048   1050623   1048576  512M Linux RAID
/dev/sdb2    1050624   1116159     65536   32M BIOS boot
/dev/sdb3    1116160 126945279 125829120   60G Linux RAID
/dev/sdb4  126945280 546375679 419430400  200G Linux RAID
/dev/sdb5  546375680 963708927 417333248  199G Linux RAID
/dev/sdb6  963708928 976773134  13064207  6.2G Linux swap

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.


root@edo ~ Sun 02 Aug 2020 01:01:32 PM JST JST(+0900)
# e2fsck /dev/sdb1
e2fsck 1.45.5 (07-Jan-2020)
/dev/sdb1: clean, 419/131072 files, 163642/524224 blocks


sdb6にはswap領域を作成しておく。
swaponは今はしないでおき、同期が終わったらswaponする。
root@edo ~ Sun 02 Aug 2020 01:05:30 PM JST JST(+0900)
# mkswap /dev/sdb6
Setting up swapspace version 1, size = 6.2 GiB (6688866304 bytes)
no label, UUID=54a4d9c8-ecaf-4abc-bb43-25e363ce9517

0 件のコメント: