国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦>學(xué)習(xí)電腦>操作系統(tǒng)>Linux教程>

    Linux系統(tǒng)擴(kuò)容根目錄磁盤空間的操作方法

    時(shí)間: 加城1195 分享

      Linu_繼承了Uni_以網(wǎng)絡(luò)為核心的設(shè)計(jì)思想,是一個(gè)性能穩(wěn)定的多用戶網(wǎng)絡(luò)操作系統(tǒng)。有網(wǎng)友感覺(jué)Linu_根目錄磁盤空間不夠用了,怎么解決呢?這篇文章主要介紹了Linu_系統(tǒng)擴(kuò)容根目錄磁盤空間的操作方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

      一、使用背景

      Linu_根目錄磁盤空間不夠用了,當(dāng)修改了虛擬機(jī)模版增加磁盤大小或者插入了一塊新硬盤,但是發(fā)現(xiàn)系統(tǒng)里的大小還是沒(méi)改變。

      產(chǎn)生的原因是沒(méi)有給磁盤格式化,沒(méi)有增加分區(qū)。

      二、操作方法

      1. 查看磁盤空間大小,使用df -h 命令,發(fā)現(xiàn)掛載根目錄節(jié)點(diǎn)的/dev/mapper/ubuntu14--vg-root 只有28G容量。

      root@ubuntu14:/opt# df -h

      文件系統(tǒng) 容量 已用 可用 已用% 掛載點(diǎn)

      /dev/mapper/ubuntu14--vg-root 28G 23G 3.3G 88% /

      none 4.0K 0 4.0K 0% /sys/fs/cgroup

      udev 3.9G 4.0K 3.9G 1% /dev

      tmpfs 799M 384K 799M 1% /run

      none 5.0M 0 5.0M 0% /run/lock

      none 3.9G 0 3.9G 0% /run/shm

      none 100M 0 100M 0% /run/user

      /dev/vda1 236M 37M 188M 17% /boot

      2. 增加磁盤空間,例如下圖使用VM虛擬機(jī)增加的方式。

      3.使用fdisk -l命令查看磁盤信息。當(dāng)看到第一行Disk /dev/vda: 161.1 GB與實(shí)際df -h顯示內(nèi)容不符時(shí),說(shuō)明增加磁盤成功了。

      root@ubuntu14:/opt# fdisk -l

      Disk /dev/vda: 161.1 GB, 161061273600 bytes

      16 heads, 63 sectors/track, 312076 cylinders, total 314572800 sectors

      Units = 扇區(qū) of 1 _512 = 512 bytes

      Sector size (logical/physical): 512 bytes / 512 bytes

      I/O size (minimum/optimal): 512 bytes / 512 bytes

      Disk identifier: 0_0001a023

      設(shè)備 啟動(dòng) 起點(diǎn) 終點(diǎn) 塊數(shù) Id 系統(tǒng)

      /dev/vda1 _2048 499711 248832 83 Linu_

      /dev/vda2 501758 62912511 31205377 5 擴(kuò)展

      /dev/vda5 501760 62912511 31205376 8e Linu_ LVM

      Disk /dev/mapper/ubuntu14--vg-root: 29.8 GB, 29804724224 bytes

      255 heads, 63 sectors/track, 3623 cylinders, total 58212352 sectors

      Units = 扇區(qū) of 1 _512 = 512 bytes

      Sector size (logical/physical): 512 bytes / 512 bytes

      I/O size (minimum/optimal): 512 bytes / 512 bytes

      Disk identifier: 0_00000000

      Disk /dev/mapper/ubuntu14--vg-root doesn't contain a valid partition table

      Disk /dev/mapper/ubuntu14--vg-swap_1: 2147 MB, 2147483648 bytes

      255 heads, 63 sectors/track, 261 cylinders, total 4194304 sectors

      Units = 扇區(qū) of 1 _512 = 512 bytes

      Sector size (logical/physical): 512 bytes / 512 bytes

      I/O size (minimum/optimal): 512 bytes / 512 bytes

      Disk identifier: 0_00000000

      Disk /dev/mapper/ubuntu14--vg-swap_1 doesn't contain a valid partition table

      4.使用fdisk /dev/vda, 創(chuàng)建新分區(qū)。

      注意:不同操作系統(tǒng)的磁盤命名方式不同,有些是/dev/sda。具體使用方式參考第三步中fdisk -l首行顯示Disk。如筆者在該系統(tǒng)中首行顯示為Disk /dev/vda: 161.1 GB, 161061273600 bytes ,故使用命令fdisk /dev/vda)

      按照下面Linu_操作進(jìn)行分區(qū)。

      root@ubuntu14:/opt# fdisk /dev/vda

      命令(輸入 m 獲取幫助): m

      命令操作

      a toggle a bootable flag

      b edit bsd disklabel

      c toggle the dos compatibility flag

      d delete a partition

      l list known partition types

      m print this menu

      n add a new partition

      o create a new empty DOS partition table

      p print the partition table

      q quit without saving changes

      s create a new empty Sun disklabel

      t change a partition's system id

      u change display/entry units

      v verify the partition table

      w write table to disk and e_it

      _ e_tra functionality (e_perts only)

      命令(輸入 m 獲取幫助): n #new 新分區(qū)

      Partition type:

      p primary (1 primary, 1 e_tended, 2 free)

      l logical (numbered from 5)

      Select (default p): p #選擇主分區(qū)

      分區(qū)號(hào) (1-4,默認(rèn)為 3): 3 #分區(qū)序號(hào)

      起始 sector (499712-314572799,默認(rèn)為 499712): #分區(qū)開(kāi)始回車默認(rèn)

      將使用默認(rèn)值 499712

      Last sector, +扇區(qū) or +size{K,M,G} (499712-501757,默認(rèn)為 501757):

      將使用默認(rèn)值 501757

      命令(輸入 m 獲取幫助): n #new 新分區(qū)

      Partition type:

      p primary (2 primary, 1 e_tended, 1 free)

      l logical (numbered from 5)

      Select (default p): p #選擇主分區(qū)

      Selected partition 4 #分區(qū)序號(hào)

      起始 sector (62912512-314572799,默認(rèn)為 62912512): #分區(qū)開(kāi)始回車默認(rèn)

      將使用默認(rèn)值 62912512

      Last sector, +扇區(qū) or +size{K,M,G} (62912512-314572799,默認(rèn)為 314572799):

      將使用默認(rèn)值 314572799

      命令(輸入 m 獲取幫助): t #修改分區(qū)格式

      分區(qū)號(hào) (1-5): 4 #修改分區(qū)號(hào)

      He_ code (type L to list codes): 8e #格式選擇8e linu_ LVM

      Changed system type of partition 4 to 8e (Linu_ LVM)

      命令(輸入 m 獲取幫助): p #顯示分區(qū)信息

      Disk /dev/vda: 161.1 GB, 161061273600 bytes

      16 heads, 63 sectors/track, 312076 cylinders, total 314572800 sectors

      Units = 扇區(qū) of 1 _512 = 512 bytes

      Sector size (logical/physical): 512 bytes / 512 bytes

      I/O size (minimum/optimal): 512 bytes / 512 bytes

      Disk identifier: 0_0001a023

      設(shè)備 啟動(dòng) 起點(diǎn) 終點(diǎn) 塊數(shù) Id 系統(tǒng)

      /dev/vda1 _2048 499711 248832 83 Linu_

      /dev/vda2 501758 62912511 31205377 5 擴(kuò)展

      /dev/vda3 499712 501757 1023 83 Linu_

      /dev/vda4 62912512 314572799 125830144 8e Linu_ LVM

      /dev/vda5 501760 62912511 31205376 8e Linu_ LVM

      Partition table entries are not in disk order

      命令(輸入 m 獲取幫助): w #保存信息

      The partition table has been altered!

      Calling ioctl() to re-read partition table.

      WARNING: Re-reading the partition table failed with error 16: 設(shè)備或資源忙.

      The kernel still uses the old table. The new table will be used at

      the ne_t reboot or after you run partprobe(8) or kpart_(8)

      Syncing disks.

      5. 重啟Linu_操作系統(tǒng),使用reboot命令。

      6. 創(chuàng)建物理卷,使用pvcreate /dev/vda4命令。

      root@ubuntu14:~# pvcreate /dev/vda4

      Physical volume "/dev/vda4" successfully created

      7.查看新建的物理卷和大小,使用pvdisplay命令。

      root@ubuntu14:~# pvdisplay

      --- Physical volume ---

      PV Name ubuntu14-vg

      PV Size 29.76 GiB / not usable 2.00 MiB

      Allocatable yes (but full)

      PE Size 4.00 MiB

      Total PE 7618

      Free PE 0

      Allocated PE 7618

      PV UUID _R32TY-aRQC-IQC6-oC_7-aa9_-KdJe-bHmaBd

      "/dev/vda4" /dev/vda5

      VG Name is a new physical volume of "120.00 GiB"

      --- NEW Physical volume ---

      PV Name /dev/vda4

      VG Name

      PV Size 120.00 GiB

      Allocatable NO

      PE Size 0

      Total PE 0

      Free PE 0

      Allocated PE 0

      PV UUID MVK0IT-LDgP-eWwZ-fzQM-tdyY-kRQ-nbk122

      8. 將添加新的物理卷,加載到ubuntu14-vg卷組,使用vge_tend ubuntu14-vg /dev/vda4命令。

      root@ubuntu14:~# vge_tend ubuntu14-vg /dev/vda4

      Volume group "ubuntu14-vg" successfully e_tended

      9. 查看卷組信息,使用vgdisplay命令。

      root@ubuntu14:~# vgdisplay

      --- Volume group ---

      VG Name ubuntu14-vg

      System ID

      Format lvm2

      Metadata Areas 2

      Metadata Sequence No 4

      VG Access read/write

      VG Status resizable

      MA_ LV 0

      Cur LV 2

      Open LV 2

      Ma_ PV 0

      Cur PV 2

      Act PV 2

      VG Size 149.76 GiB

      PE Size 4.00 MiB

      Total PE 38338

      Alloc PE / Size 7618 / 29.76 GiB

      Free PE / Size 30720 / 120.00 GiB

      VG UUID cq2Z6G-P6j1-S2gM-mibz-d63V-NjkS-dHYe7D

      10.增加ubuntu14-vg大小,增加120G。使用lvresize -L +120G /dev/mapper/ubuntu14--vg-root命令。

      root@ubuntu14:~# lvresize -L +120G /dev/mapper/ubuntu14--vg-root

      E_tending logical volume root to 147.76 GiB

      Logical volume root successfully resized

      11. 重新識(shí)別ubuntu14-vg大小,使用resize2fs /dev/mapper/ubuntu14--vg-root命令。

      root@ubuntu14:~# resize2fs /dev/mapper/ubuntu14--vg-root

      resize2fs 1.42.9 (4-Feb-2014)

      Filesystem at /dev/mapper/ubuntu14--vg-root is mounted on /; on-line resizing required

      old_desc_blocks = 2, new_desc_blocks = 10

      The filesystem on /dev/mapper/ubuntu14--vg-root is now 38733824 blocks long.

      12.查看擴(kuò)容后的大小 ,使用df -h命令。

      root@ubuntu14:~# df -h

      文件系統(tǒng) 容量 已用 可用 已用% 掛載點(diǎn)

      /dev/mapper/ubuntu14--vg-root 146G 23G 117G 17% /

      none 4.0K 0 4.0K 0% /sys/fs/cgroup

      udev 3.9G 4.0K 3.9G 1% /dev

      tmpfs 799M 388K 799M 1% /run

      none 5.0M 0 5.0M 0% /run/lock

      none 3.9G 0 3.9G 0% /run/shm

      none 100M 0 100M 0% /run/user

      /dev/vda1 236M 37M 188M 17% /boot

      當(dāng)看到/dev/mapper/ubuntu14--vg-root 已經(jīng)更新到新的大小時(shí),則表示增加成功。

      補(bǔ)充:Linu_基本命令

     ?、賚s 意為list 列出當(dāng)前文件夾中的文件

      -l 顯示文件的屬性 可用ll來(lái)表示

      ②alias 別名 看看是否有別名的文件

     ?、踓d dir 跳躍目錄 -P選項(xiàng) 將路徑中的鏈接文件替換成鏈接指向的文件路徑

     ?、躳wd 查看當(dāng)前工作的文件夾名 使用-P的選項(xiàng),會(huì)直接進(jìn)入到其中,相當(dāng)于cd

      相關(guān)閱讀:Linu_shell腳本不執(zhí)行問(wèn)題實(shí)例分析

      shell腳本不執(zhí)行問(wèn)題:某天研發(fā)某同事找我說(shuō)幫他看看他寫的shell腳本,死活不執(zhí)行,報(bào)錯(cuò)。我看了下,腳本很簡(jiǎn)單,也沒(méi)有常規(guī)性的錯(cuò)誤,報(bào)&ldquo;:badinterpreter:Nosuchfileordirectory&rdquo;錯(cuò)??催@錯(cuò),我就問(wèn)他是不是在windows下編寫的腳本,然后在上傳到linu_服務(wù)器的&hellip;&hellip;果然。原因:在DOS/windows里,文本文件的換行符為rn,而在_i_系統(tǒng)里則為n,所以DOS/Windows里編輯過(guò)的文本文件到了_i_里,每一行都多了個(gè)^M。解決:

      1)重新在linu_下編寫腳本;

      2)vi:%s/r//g:%s/^M//g(^M輸入用Ctrl+v,Ctrl+m)附:sh-_腳本文件名,可以單步執(zhí)行并回顯結(jié)果,有助于排查復(fù)雜腳本問(wèn)題。

    Linu_系統(tǒng)擴(kuò)容根目錄磁盤空間的操作方法相關(guān)文章:

    1.linu_的進(jìn)入磁盤命令

    2.linu_中系統(tǒng)中根目錄文件夾中文詳解

    3.linu_系統(tǒng)硬盤安裝教程

    4.NT與Linu_雙系統(tǒng)完全解決方案

    5.U盤安裝Linu_系統(tǒng)步驟

    4016927