濮阳杆衣贸易有限公司

主頁 > 知識庫 > centos下如何使用fdisk擴展分區(qū)容量大小

centos下如何使用fdisk擴展分區(qū)容量大小

熱門標簽:怎樣在北斗地圖標注商戶 日立hgp外呼線路圖 電話外呼系統(tǒng)解決方案 貴港便宜外呼系統(tǒng)報價 400外呼系統(tǒng) 配置要求 辦理400電話的好處都有哪些 仙桃外呼系統(tǒng) 廣州點撥外呼系統(tǒng)多少錢一個月 太原外呼電銷機器人軟件

擴展磁盤空間

硬盤空間為20G,使用vSphere Client增加磁盤大小,需要再增加10G空間;

擴展完后,重啟系統(tǒng),再次使用fdisk -l查看,會發(fā)現硬盤空間變大了;

[root@linuxprobe ~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x0005210c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        1301    10240000   83  Linux
/dev/sda3            1301        1497     1572864   82  Linux swap / Solaris
/dev/sda4            1497        2611     8952832   83  Linux
[root@linuxprobe ~]# df -hT
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/sda2      ext4   9.7G  1.5G  7.7G  16% /
tmpfs          tmpfs  939M     0  939M   0% /dev/shm
/dev/sda1      ext4   194M   34M  151M  19% /boot
/dev/sda4      ext4   8.5G  148M  7.9G   2% /data

重新創(chuàng)建分區(qū),調整分區(qū)信息

本次實驗主要對/dev/sda4這個分區(qū)擴展,如果是生產環(huán)境,請?zhí)崆白龊脗浞荼4娴狡渌謪^(qū),雖然擴展分區(qū)大小不會導致數據丟失,安全起見,請?zhí)崆白龊脗浞荩?/p>

首先模擬出一些數據:

[root@linuxprobe data]# mkdir test
[root@linuxprobe data]# echo "we are Linuxer" > linuxprobe
[root@linuxprobe data]# ll
total 24
-rw-r--r--. 1 root root    15 May 23 21:59 linuxprobe
drwx------. 2 root root 16384 May 23 15:07 lost+found
drwxr-xr-x. 2 root root  4096 May 23 21:51 test
[root@linuxprobe ~]# umount /dev/sda4          #卸載磁盤分區(qū)

若提示磁盤忙,使用fuser找出將正在使用磁盤的程序并結束掉;

fuser -m -v /data
fuser -m -v -i -k /data

使用fdisk工具先刪除/dev/sda4分區(qū),然后創(chuàng)建新分區(qū),注意開始的磁柱號要和原來的一致(是保證數據不丟失的關鍵步驟),結束的磁柱號默認回車使用全部磁盤。

[root@linuxprobe ~]# 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        #查看分區(qū)表信息Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x0005210c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        1301    10240000   83  Linux
/dev/sda3            1301        1497     1572864   82  Linux swap / Solaris
/dev/sda4            1497        2611     8952832   83  Linux

Command (m for help): d           #刪除分區(qū)Partition number (1-4): 4         #刪除第四個Command (m for help): p       #再次查看分區(qū)信息,/dev/sda4已被刪除Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x0005210c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        1301    10240000   83  Linux
/dev/sda3            1301        1497     1572864   82  Linux swap / Solaris

Command (m for help): n      #創(chuàng)建新的分區(qū)Command action
   e   extended
   p   primary partition (1-4)
p             #創(chuàng)建為主分區(qū)
Selected partition 4
First cylinder (1497-3916, default 1497):          #經對比,正好和上一個磁盤柱一致,默認即可Using default value 1497
Last cylinder, +cylinders or +size{K,M,G} (1497-3916, default 3916): 
Using default value 3916              #直接默認就可以Command (m for help): p               #查看分區(qū)表信息Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x0005210c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        1301    10240000   83  Linux
/dev/sda3            1301        1497     1572864   82  Linux swap / Solaris
/dev/sda4            1497        3916    19436582   83  Linux

Command (m for help): wp       #保存并退出,如果創(chuàng)建有誤,直接退出不要保存即可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.

重新創(chuàng)建分區(qū)后,需要重啟一下;

[root@linuxprobe ~]# init 6
[root@linuxprobe ~]# e2fsck -f /dev/sda4                #檢查分區(qū)信息[root@linuxprobe ~]# resize2fs -p /dev/sda4             #調整分區(qū)大小

重新掛載、查看分區(qū)大小、數據

[root@linuxprobe ~]# mount /dev/sda4 /data
[root@linuxprobe ~]# df -hT
[root@linuxprobe ~]# cat /data/linuxprobe
we are  Linuxer

標簽:雅安 麗水 河源 青島 公主嶺 商丘 廣安 六盤水

巨人網絡通訊聲明:本文標題《centos下如何使用fdisk擴展分區(qū)容量大小》,本文關鍵詞  centos,下,如何,使用,fdisk,;如發(fā)現本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《centos下如何使用fdisk擴展分區(qū)容量大小》相關的同類信息!
  • 本頁收集關于centos下如何使用fdisk擴展分區(qū)容量大小的相關信息資訊供網民參考!
  • 推薦文章
    长顺县| 清丰县| 阳信县| 临江市| 西吉县| 阳江市| 锡林浩特市| 东安县| 山西省| 兴业县| 陆川县| 太仆寺旗| 宜君县| 汤原县| 出国| 绥滨县| 沙洋县| 玉林市| 错那县| 谢通门县| 华阴市| 留坝县| 镇远县| 益阳市| 乐清市| 阿拉善右旗| 都昌县| 古田县| 旬阳县| 巴东县| 福鼎市| 囊谦县| 汉寿县| 平利县| 凤城市| 南充市| 墨脱县| 藁城市| 专栏| 称多县| 迁西县|