linux如何扩展根分区,linux扩展根分区详细步骤
Linux虚拟机扩展根分区!虚拟机根分区空间不够用,在虚拟机管理界面进行单个磁盘扩展(图形化界面操作略),比如原来是30G,扩展至40G,(扩展需要关机之后操作)其中的10G空间需要重新分区,以下是分区相关操作让扩展的空间生效:登录系统之后:df -h 发现空间没有发生变化:[root@lub ~]# df -hFilesystemSize Used Avail Use...
Linux虚拟机扩展根分区!
虚拟机根分区空间不够用,在虚拟机管理界面进行单个磁盘扩展(图形化界面操作略),比如原来是30G,扩展至40G,(扩展需要关机之后操作)
其中的10G空间需要重新分区,以下是分区相关操作让扩展的空间生效:
登录系统之后:
df -h 发现空间没有发生变化:
[root@lub ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
25G 19G 4.2G 82% /
tmpfs 642M 0 642M 0% /dev/shm
/dev/sda1 485M 34M 426M 8% /boot
fdisk -l 发现总容量已经扩展。
[root@lub ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00069f1c
------------------------------
对扩展的磁盘进行分区:
[root@lub ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00069f1c
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 4047 31992832 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
3
Invalid partition number for type `3'
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (4047-5221, default 4047):
Using default value 4047
Last cylinder, +cylinders or +size{K,M,G} (4047-5221, default 5221):
Using default value 5221
Command (m for help): p -------查看分区后的情况
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00069f1c
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 4047 31992832 8e Linux LVM
/dev/sda3 4047 5221 9431826+ 83 Linux
---新增的sda3
Command (m for help): w 保存分区
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@lub ~]#
--------------------使用命令发现partprobe /dev/sda3发现分区并没有起作用:
[root@lub ~]# partprobe /dev/sda3
Error: Could not stat device /dev/sda3 - No such file or directory.
[root@lub ~]# pvcreate /dev/sda3
Device /dev/sda3 not found (or ignored by filtering).
-----重启系统。
------LVM操作。扩展根分区
[root@lub ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@lub ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 2 0 wz--n- 30.51g 0
[root@lub ~]# vgextend VolGroup /dev/sda3
Volume group "VolGroup" successfully extended
[root@lub ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 2 2 0 wz--n- 39.50g 8.99g
[root@lub ~]# lvextend -L +8.99G /dev/mapper/VolGroup-lv_root
Rounding size to boundary between physical extents: 8.99 GiB
Extending logical volume lv_root to 33.50 GiB
Logical volume lv_root successfully resized
[root@lub ~]# resize2fs /dev/mapper/VolGroup-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 8781824 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 8781824 blocks long.
----命令操作根分区情况,发现已经生效:
[root@lub ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
33G 19G 13G 60% /
tmpfs 642M 0 642M 0% /dev/shm
/dev/sda1 485M 34M 426M 8% /boot
[root@lub ~]#
完成扩展。!
更多推荐
所有评论(0)