CentOS7ではfdiskによるディスク拡張ができない
CentOS6.5のときは下記の記事通りにすればディスク拡張することができた。http://knowledge.sakura.ad.jp/tech/925/
しかし、CentOS7.0でディスクを作成した場合、記事通りにfdiskを使ったディスクをすることができない。
ディスクパーティションがMBRからGPTという仕組みに変わっているためだ。
partedとgdiskを使う
GPTのディスクのパーティションを行うにはpartedとgdiskというツールが使えます。さくらの記事のfdiskによる作業の変わりに以下の作業を行うことでディスク拡張ができました。
partedによる使用可能セクターの変更
[root]#parted /dev/vdb
GNU Parted 3.1
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the disk is smaller. Fix, by moving the backup to the end (and
removing the old backup)?
Fix/Ignore/Cancel?
Fix/Ignore/Cancel? Fix
Warning: Not all of the space available to /dev/vdb appears to be used, you can fix the GPT to use all of the space (an extra 83886080 blocks) or continue with the current setting?
Fix/Ignore? Fix
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: pmbr_boot
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB Linux filesystem bios_grub
2 2097kB 4301MB 4299MB linux-swap(v1) Linux swap
3 4301MB 21.5GB 17.2GB ext4 Linux filesystem
(parted) q
gdiskによるパーティションの再作成
[root]#gdisk /dev/vdb
GPT fdisk (gdisk) version 0.8.6
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): p
Disk /dev/vdb: 125829120 sectors, 60.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 30A18C9A-0775-4F3C-A870-92BF1D93F0C1
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 125829086
Partitions will be aligned on 2048-sector boundaries
Total free space is 83888094 sectors (40.0 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 4095 1024.0 KiB EF02 Linux filesystem
2 4096 8400895 4.0 GiB 8200 Linux swap
3 8400896 41943006 16.0 GiB 8300 Linux filesystem
Command (? for help): d ^H
Partition number (1-3): 3
Command (? for help): n
Partition number (3-128, default 3):
First sector (34-125829086, default = 8400896) or {+-}size{KMGTP}:
Last sector (8400896-125829086, default = 125829086) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Command (? for help): p
Disk /dev/vdb: 125829120 sectors, 60.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 30A18C9A-0775-4F3C-A870-92BF1D93F0C1
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 125829086
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 4095 1024.0 KiB EF02 Linux filesystem
2 4096 8400895 4.0 GiB 8200 Linux swap
3 8400896 125829086 56.0 GiB 8300 Linux filesystem
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/vdb.
The operation has completed successfully.
その他
e2fsckでブロックのカウントが違うと言われましたがFixにしたら問題なく動きました。
原因がよくわからないので怖いですが。
[root@]# e2fsck -f /dev/vdb3
e2fsck 1.42.9 (28-Dec-2013)
/dev/vdb3: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (3587294, counted=3587642).
Fix? yes
Free inodes count wrong (996737, counted=996734).
Fix? yes
/dev/vdb3: ***** FILE SYSTEM WAS MODIFIED *****
/dev/vdb3: 51842/1048576 files (0.1% non-contiguous), 605121/4192763 blocks
0 件のコメント:
コメントを投稿