linux如何扩展根分区,linux扩展根分区详细步骤
Linux虛擬機(jī)擴(kuò)展根分區(qū)!
虛擬機(jī)根分區(qū)空間不夠用,在虛擬機(jī)管理界面進(jìn)行單個(gè)磁盤(pán)擴(kuò)展(圖形化界面操作略),比如原來(lái)是30G,擴(kuò)展至40G,(擴(kuò)展需要關(guān)機(jī)之后操作)
其中的10G空間需要重新分區(qū),以下是分區(qū)相關(guān)操作讓擴(kuò)展的空間生效:
登錄系統(tǒng)之后:
df -h ?發(fā)現(xiàn)空間沒(méi)有發(fā)生變化:
[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 ? 發(fā)現(xiàn)總?cè)萘恳呀?jīng)擴(kuò)展。
[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
------------------------------
對(duì)擴(kuò)展的磁盤(pán)進(jìn)行分區(qū):
[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 -------查看分區(qū)后的情況
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 ?保存分區(qū)
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 ~]#
--------------------使用命令發(fā)現(xiàn)partprobe /dev/sda3發(fā)現(xiàn)分區(qū)并沒(méi)有起作用:
[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).
-----重啟系統(tǒng)。
------LVM操作。擴(kuò)展根分區(qū)
[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.
----命令操作根分區(qū)情況,發(fā)現(xiàn)已經(jīng)生效:
[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 ~]#
完成擴(kuò)展。!
總結(jié)
以上是生活随笔為你收集整理的linux如何扩展根分区,linux扩展根分区详细步骤的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: linux进程故障如何修复,33.Lin
- 下一篇: linux中popen汉字乱码,Pyth