在 Linux 下使用 fdisk 擴充套件分割槽容量
我們管理的伺服器可能會隨著業務量的不斷增長造成磁碟空間不足的情況,比如:共享檔案伺服器硬碟空間不足,在這個時候我們就需要增加磁碟空間,來滿足線上的業務;又或者我們在使用linux的過程中, 有時會因為安裝系統時分割槽不當導致有的分割槽空間不足,而有的分割槽空間過剩的情況,都可以是使用fdisk分割槽工具來動態調整分割槽的大小。
擴充套件磁碟空間
硬碟空間為20G,使用vSphere Client增加磁碟大小,需要再增加10G空間;
擴充套件完後,重啟系統,再次使用fdisk -l檢視,會發現硬碟空間變大了;
重新建立分割槽,調整分割槽資訊
本次實驗主要對/dev/sda4這個分割槽擴充套件,如果是生產環境,請提前做好備份儲存到其他分割槽,雖然擴充套件分割槽大小不會導致資料丟失,安全起見,請提前做好備份;
首先模擬出一些資料:
[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 ### 解除安裝磁碟分割槽
若提示磁碟忙,使用fuser找出將正在使用磁碟的程式並結束掉;
fuser -m -v /data
fuser -m -v -i -k /data
使用fdisk工具先刪除/dev/sda4分割槽,然後建立新分割槽,注意開始的磁柱號要和原來的一致(是保證資料不丟失的關鍵步驟),結束的磁柱號預設回車使用全部磁碟。
[root@linuxprobe ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It is 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: 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 ### 刪除分割槽
Partition number (1-4): 4 ### 刪除第四個
Command (m for help): p ### 再次檢視分割槽資訊,/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 ### 建立新的分割槽
Command action
e extended
p primary partition (1-4)
p #建立為主分割槽
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 ### 檢視分割槽表資訊
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 ### 儲存並退出,如果建立有誤,直接退出不要儲存即可
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@linuxprobe ~]# init 6
[root@linuxprobe ~]# e2fsck -f /dev/sda4 ### 檢查分割槽資訊
[root@linuxprobe ~]# resize2fs -p /dev/sda4 ### 調整分割槽大小
重新掛載、檢視分割槽大小、資料:
可見/dev/sda4分割槽的空間大小已經增加了。
相關文章
- linux 使用fdisk分割槽擴容Linux
- Linux主分割槽,擴充套件分割槽,邏輯分割槽Linux套件
- linux下線上擴大擴充套件分割槽的方法Linux套件
- Ubunut擴充套件分割槽套件
- Linux主分割槽,擴充套件分割槽,邏輯分割槽[final]Linux套件
- Linux LVM 擴充套件磁碟分割槽LinuxLVM套件
- 擴充套件aix交換分割槽套件AI
- Hash分割槽表的使用及擴充套件套件
- Linux下磁碟分割槽,fdisk,mkfsLinux
- Linux 格式化擴充套件分割槽(Extended)Linux套件
- 擴充套件redhat linux as 5 的swap分割槽套件RedhatLinux
- Linux 擴充套件磁碟分割槽(命令列操作)Linux套件命令列
- linux下fdisk命令的使用方法(分割槽)Linux
- Linux下擴充套件根檔案系統所在的分割槽Linux套件
- 如何在 Linux 中擴充套件 XFS 根分割槽Linux套件
- linux建立新分割槽擴充套件磁碟空間Linux套件
- Linux下分割槽詳解之--FdiskLinux
- 帶default分割槽的列表分割槽表的擴充套件套件
- linux使用fdisk新增分割槽的例子Linux
- redhat linux swap分割槽擴充套件的三種方法RedhatLinux套件
- SQL Server大分割槽表沒有空分割槽的情況下如何擴充套件分割槽的方法SQLServer套件
- Windows 8.1怎麼建立擴充套件分割槽?Windows套件
- centos 擴充套件root根分割槽的大小CentOS套件
- SRAM的容量擴充套件套件
- linux 磁碟分割槽掛載-fdiskLinux
- Linux精講——fdisk磁碟分割槽Linux
- linux下使用fdisk/mke2fs/mount新增新硬碟分割槽Linux硬碟
- 擴充套件Linux虛擬機器硬碟、分割槽一例薦套件Linux虛擬機硬碟
- linux磁碟分割槽fdisk命令詳解Linux
- linux fdisk 分割槽、格式化、掛載!Linux
- 【Linux系統】fdisk相關分割槽命令。Linux
- Linux系統 fdisk命令 建立新分割槽Linux
- Linux 分割槽擴容(根分割槽擴容,SWAP 分割槽擴容,掛載新分割槽為目錄)Linux
- 例項解說Linux中fdisk分割槽使用方法(轉)Linux
- 使用 fdisk 和 fallocate 命令建立交換分割槽
- linux磁碟分割槽格式化-fdisk命令工具Linux
- 運維實戰:Linux系統擴充套件oracle資料庫所在的分割槽運維Linux套件Oracle資料庫
- win10硬碟分割槽合併擴充套件卷沒法點怎麼解決 win10硬碟分割槽不能點擴充套件卷修復方法Win10硬碟套件