Centos
附加新卷後如何擴展根卷?
我在 OpenStack 項目中創建了新的虛擬機。
在我想在 VM 中添加大小可用空間之後。
我添加了新卷並附加到虛擬機。
啟動 VM 後,我嘗試檢查狀態 HDD。
fdisk -l
Disk /dev/vda: 5368 MB, 5368709120 bytes, 10485760 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000ad846 Device Boot Start End Blocks Id System /dev/vda1 * 2048 10485759 5241856 83 Linux Disk /dev/vdb: 155.7 GB, 155692564480 bytes, 304087040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT vda └─vda1 xfs b22f809d-38b7-43fd-8eda-22acb001877f / vdb
df -h
Filesystem Size Used Avail Use% Mounted on devtmpfs 7.7G 0 7.7G 0% /dev tmpfs 7.8G 0 7.8G 0% /dev/shm tmpfs 7.8G 17M 7.7G 1% /run tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/vda1 5.0G 2.4G 2.6G 48% / tmpfs 1.6G 0 1.6G 0% /run/user/20226
在我嘗試創建新的主分區之後
fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xa9dbcbca. Command (m for help): p Disk /dev/vdb: 155.7 GB, 155692564480 bytes, 304087040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xa9dbcbca Device Boot Start End Blocks Id System Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-304087039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-304087039, default 304087039): Using default value 304087039 Partition 1 of type Linux and of size 145 GiB is set Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
fdisk -l
Disk /dev/vda: 5368 MB, 5368709120 bytes, 10485760 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000ad846 Device Boot Start End Blocks Id System /dev/vda1 * 2048 10485759 5241856 83 Linux Disk /dev/vdb: 155.7 GB, 155692564480 bytes, 304087040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xa9dbcbca Device Boot Start End Blocks Id System /dev/vdb1 2048 304087039 152042496 8e Linux LVM
如何擴展根卷 /dev/vda1 5.0G 2.4G 2.6G 48% / 新卷 /dev/vdb1 ?
我不相信您可以將一個硬碟擴展到另一個硬碟。您可以將 vda 複製到 vdb,然後使用 vdb 作為您的“/”硬碟。嘗試 dd 或任何卷複製工具。複製後,您可以將分區擴展到所需的大小。