最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Ubuntu系統(tǒng)下擴(kuò)展LVM根目錄的方法

 更新時(shí)間:2018年05月06日 16:15:20   作者:洋子  
這篇文章主要給大家介紹了關(guān)于Ubuntu系統(tǒng)下擴(kuò)展LVM根目錄的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

前言

最近手頭一臺(tái)運(yùn)行在 Hyper-V 下面抓數(shù)據(jù)的服務(wù)器 (Ubuntu 16.04) 磁盤空間不夠了,之前也沒有把數(shù)據(jù)單獨(dú)放到一個(gè)分區(qū),所以只能想辦法把根目錄給搞大一點(diǎn)。之前沒有處理過這樣的問題,網(wǎng)上搜了很多資料,現(xiàn)在把拓展方法記錄,分享出來。

建議在操作之前做好備份工作

步驟概覽

  1. 調(diào)大物理磁盤
  2. 確定要操作的磁盤
  3. 擴(kuò)展 LVM 邏輯分區(qū)所在的物理拓展分區(qū)
  4. 新增 LVM 邏輯分區(qū)
  5. 新分區(qū)合并到相應(yīng) Volumn Group
  6. 更新文件系統(tǒng)

調(diào)大物理磁盤

虛擬機(jī)關(guān)機(jī),然后直接在虛擬機(jī)管理里面操作。

現(xiàn)在把磁盤從 100G 調(diào)整到了 300G

確定要操作的磁盤

先看下磁盤使用情況,運(yùn)行命令

root@vm003:~# df -h
Filesystem  Size Used Avail Use% Mounted on
udev   3.9G 0 3.9G 0% /dev
tmpfs   798M 8.6M 789M 2% /run
/dev/mapper/Ubuntu-root 94G 88G 1.9G 98% /
tmpfs   3.9G 0 3.9G 0% /dev/shm
tmpfs   5.0M 0 5.0M 0% /run/lock
tmpfs   3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1  472M 382M 66M 86% /boot
tmpfs   100K 0 100K 0% /run/lxcfs/controllers
tmpfs   798M 0 798M 0% /run/user/0

雖然我們已經(jīng)把物理磁盤調(diào)整到了 300G,但是根目錄還是100G的樣子,已用 98%

運(yùn)行命令

root@vm003:~# fdisk -l
Disk /dev/sda: 300 GiB, 322122547200 bytes, 629145600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xa88f1366

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 209713151 208711682 99.5G 5 Extended
/dev/sda5 1001472 209713151 208711680 99.5G 8e Linux LVM

Partition 2 does not start on physical sector boundary.


Disk /dev/mapper/Ubuntu-root: 95.5 GiB, 102563315712 bytes, 200318976 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/Ubuntu-swap_1: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

可以看到 /dev/sda 已經(jīng)確實(shí)被調(diào)整到了300GiB,只是系統(tǒng)還沒用到。

也知道了我們要操作 /dev/sda

擴(kuò)大 LVM 邏輯分區(qū)所在的物理分區(qū)

運(yùn)行命令

root@vm003:~# parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print # 查看分區(qū)
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 322GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
 1 1049kB 512MB 511MB primary ext2  boot
 2 513MB 107GB 107GB extended
 5 513MB 107GB 107GB logical  lvm

(parted) resizepart 2 # 調(diào)整 sda2 分區(qū)大小
End? [107GB]? -0 # 直接充滿
(parted) print # 再次查看
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 322GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
 1 1049kB 512MB 511MB primary ext2  boot
 2 513MB 322GB 322GB extended
 5 513MB 107GB 107GB logical  lvm

(parted) q # 完成退出
Information: You may need to update /etc/fstab.

現(xiàn)在我們已經(jīng)把 /dev/sda2 給拓展出來了

新增 LVM 邏輯分區(qū)

運(yùn)行命令

root@vm003:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p # 查看現(xiàn)在的分區(qū)情況
Disk /dev/sda: 300 GiB, 322122547200 bytes, 629145600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xa88f1366

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 629145599 628144130 299.5G 5 Extended
/dev/sda5 1001472 209713151 208711680 99.5G 8e Linux LVM

Partition 2 does not start on physical sector boundary.

Command (m for help): n # 新增分區(qū),選擇邏輯分區(qū),起止點(diǎn)看情況輸入,默認(rèn)值是填充滿整個(gè)磁盤

All space for primary partitions is in use.
Adding logical partition 6
First sector (209715200-629145599, default 209715200):
Last sector, +sectors or +size{K,M,G,T,P} (209715200-629145599, default 629145599):

Created a new partition 6 of type 'Linux' and of size 200 GiB.

Command (m for help): p # 查看新增的分區(qū)
Disk /dev/sda: 300 GiB, 322122547200 bytes, 629145600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xa88f1366

Device Boot Start End Sectors Size Id Type
/dev/sda1 *  2048 999423 997376 487M 83 Linux
/dev/sda2  1001470 629145599 628144130 299.5G 5 Extended
/dev/sda5  1001472 209713151 208711680 99.5G 8e Linux LVM
/dev/sda6 209715200 629145599 419430400 200G 83 Linux

Partition 2 does not start on physical sector boundary.

Command (m for help): t # 改變分區(qū)類型為 Linux LVM
Partition number (1,2,5,6, default 6): 6 # sda6
Partition type (type L to list all types): 8e # LVM 類型的 Id 代碼

Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): p # 再次查看分區(qū)情況
Disk /dev/sda: 300 GiB, 322122547200 bytes, 629145600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xa88f1366

Device Boot Start End Sectors Size Id Type
/dev/sda1 *  2048 999423 997376 487M 83 Linux
/dev/sda2  1001470 629145599 628144130 299.5G 5 Extended
/dev/sda5  1001472 209713151 208711680 99.5G 8e Linux LVM
/dev/sda6 209715200 629145599 419430400 200G 8e Linux LVM

Partition 2 does not start on physical sector boundary.

Command (m for help): wq # 確認(rèn)沒有問題,保存退出

The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: 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).

新分區(qū)合并到相應(yīng) Volumn Group

運(yùn)行命令

root@vm003:~# vgdisplay
 --- Volume group ---
 VG Name  Ubuntu
 System ID
 Format  lvm2

可以看出我們要操作的VG Name 為 Ubuntu,記錄下來。

接著運(yùn)行命令

root@vm003:~# vgextend Ubuntu /dev/sda6 # /dev/sda6 是剛剛增加的 LVM 分區(qū)
 Device /dev/sda6 not found (or ignored by filtering).
 Unable to add physical volume '/dev/sda6' to volume group 'Ubuntu'.

呃,,,提示沒有找到 /dev/sda6 這個(gè)設(shè)備,還是重啟一下好了。

root@vm003:~# reboot

重啟后再次執(zhí)行

root@vm003:~# vgextend Ubuntu /dev/sda6 # /dev/sda6 是剛剛增加的 LVM 分區(qū)
 Physical volume "/dev/sda6" successfully created
 Volume group "Ubuntu" successfully extended

再查看一下 Volumn Group 的狀態(tài),運(yùn)行命令

root@vm003:~# vgs
 VG #PV #LV #SN Attr VSize VFree
 Ubuntu 2 2 0 wz--n- 299.52g 200.00g

確實(shí)加進(jìn)去了。

然后運(yùn)行

root@vm003:~# lvdisplay
 --- Logical volume ---
 LV Path  /dev/Ubuntu/root
 LV Name  root
 VG Name  Ubuntu

我們知道了 Ubuntu VG 的 LV Path 是 /dev/Ubuntu/root,記錄下來。

然后運(yùn)行

root@vm003:~# lvresize -l +100%FREE /dev/Ubuntu/root # /dev/Ubuntu/root 是 LV Path
 Size of logical volume Ubuntu/root changed from 95.52 GiB (24453 extents) to 295.52 GiB (75652 extents).
 Logical volume root successfully resized.

這就成功啦。

警告: 如果操作時(shí)出現(xiàn)下面這樣的 warning,就說明現(xiàn)在 logic volumn 的總大小還不對,resize 不但不增加空間,反而在縮小空間,如果繼續(xù)操作下去,必將丟失數(shù)據(jù)。應(yīng)立即停止!按 n 取消。

WARNING: Reducing active and open logical volume to 32.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce root? [y/n]*

更新文件系統(tǒng)

最后一步,運(yùn)行命令

root@vm003:~# resize2fs -p /dev/mapper/Ubuntu-root # /dev/mapper/Ubuntu-root 是從 df 命令看到的文件系統(tǒng)信息
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mapper/Ubuntu-root is mounted on /; on-line resizing required
old_desc_blocks = 6, new_desc_blocks = 19

The filesystem on /dev/mapper/Ubuntu-root is now 77467648 (4k) blocks long.

這個(gè)過程可能會(huì)花幾分鐘時(shí)間,耐心等待就好了。

然后運(yùn)行 df 命令查看磁盤使用

root@vm003:~# df -h
Filesystem  Size Used Avail Use% Mounted on
udev   3.9G 0 3.9G 0% /dev
tmpfs   798M 8.6M 789M 2% /run
/dev/mapper/Ubuntu-root 291G 88G 191G 32% /
tmpfs   3.9G 0 3.9G 0% /dev/shm
tmpfs   5.0M 0 5.0M 0% /run/lock
tmpfs   3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1  472M 382M 66M 86% /boot
tmpfs   100K 0 100K 0% /run/lxcfs/controllers
tmpfs   798M 0 798M 0% /run/user/0

大功告成!

參考:

http://m.fzitv.net/article/139565.htm

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

相關(guān)文章

  • 使用GDB調(diào)試多線程實(shí)例詳解

    使用GDB調(diào)試多線程實(shí)例詳解

    這篇文章主要介紹了使用GDB調(diào)試多線程實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • 在Apache上隱藏服務(wù)器簽名的方法

    在Apache上隱藏服務(wù)器簽名的方法

    這篇文章主要介紹了在Apache上隱藏服務(wù)器簽名的方法,示例基于Debian系的Linux,需要的朋友可以參考下
    2015-06-06
  • apache配置文件httpd.conf使用詳解

    apache配置文件httpd.conf使用詳解

    Apache HTTP服務(wù)器的配置文件通常稱為 httpd.conf,本文主要介紹了apache配置文件httpd.conf使用詳解,該文件包含了各種指令,用于定義 Apache 的行為和功能,感興趣的可以了解一下
    2024-07-07
  • 詳解linux grep命令

    詳解linux grep命令

    本篇文章主要介紹了linux grep命令,現(xiàn)在分享給大家,也給大家做個(gè)參考。正在學(xué)習(xí)的同學(xué)可以了解一下。
    2016-11-11
  • Linux系統(tǒng)中日志詳細(xì)介紹

    Linux系統(tǒng)中日志詳細(xì)介紹

    大家好,本篇文章主要講的是Linux系統(tǒng)中日志詳細(xì)介紹,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • Linux中的awk命令使用詳解

    Linux中的awk命令使用詳解

    這篇文章主要介紹了Linux中的awk命令使用詳解的相關(guān)資料,需要的朋友可以參考下
    2023-11-11
  • linux下如何將無線網(wǎng)卡工作模式切換為監(jiān)聽模式

    linux下如何將無線網(wǎng)卡工作模式切換為監(jiān)聽模式

    這篇文章主要介紹了linux下如何將無線網(wǎng)卡工作模式切換為監(jiān)聽模式問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • CentOS7下實(shí)現(xiàn)終端輸入中文設(shè)置詳解

    CentOS7下實(shí)現(xiàn)終端輸入中文設(shè)置詳解

    這篇文章主要給大家介紹了關(guān)于CentOS7下實(shí)現(xiàn)終端輸入中文設(shè)置的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用CentOS7系統(tǒng)具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-07-07
  • ubuntu18.04 安裝qt5.12.8及環(huán)境配置的詳細(xì)教程

    ubuntu18.04 安裝qt5.12.8及環(huán)境配置的詳細(xì)教程

    這篇文章主要介紹了ubuntu18.04 安裝qt5.12.8及環(huán)境配置的教程,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-05-05
  • 自建FTP和SFTP服務(wù)器過程介紹

    自建FTP和SFTP服務(wù)器過程介紹

    大家好,本篇文章主要講的是自建FTP和SFTP服務(wù)器過程介紹,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12

最新評論

邢台市| 昂仁县| 来安县| 永川市| 瑞金市| 平塘县| 清新县| 黑山县| 容城县| 离岛区| 遵义市| 洛宁县| 孟连| 鞍山市| 葵青区| 芒康县| 新安县| 土默特左旗| 保康县| 册亨县| 鄂尔多斯市| 邻水| 彰武县| 鲁甸县| 乐亭县| 揭东县| 镇坪县| 沙坪坝区| 宿迁市| 建始县| 含山县| 宣汉县| 青海省| 德清县| 固始县| 壶关县| 江山市| 黄石市| 平顺县| 木兰县| 朝阳市|