日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

linux如何扩展根分区,linux扩展根分区详细步骤

發(fā)布時(shí)間:2025/3/21 linux 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux如何扩展根分区,linux扩展根分区详细步骤 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。