Linux下用fdisk命令和partprobe命令不重啟系統建立分區並格式化(1)
由於工作的需要,最近一段時間一直在學習Linux。學習一門新的知識,我是喜歡根據謀一本書或者某一個學習視頻系統的學習,這樣可以對學習的新知識有一個系統全面的認識和瞭解。所以學習之前,買了一本鳥哥的私房菜做為參考書,開始系統的學習Linux。
根據鳥哥的建議,安裝虛擬機器時,預留了一塊空的容量用來練習分區使用。所以在虛擬機器上安裝Linux系統磁碟分割時,只劃分了一塊4G的容量掛載到根目錄“/”下,還有就是只劃分了一個2G的swap分區。還有14G的容量沒有分配。
在學習磁碟管理時,使用fdisk將剩餘的容量繼續分區。卻發現建立完分區後,無法通過partprobe重載分區。
具體操作如下所示:
1、使用fdisk建立分區
。。。。)分區操作記錄沒有儲存下來,執行w後,出現下列資訊
- Disk /dev/sda: 21.5 GB, 21474836480 bytes
- 255 heads, 63 sectors/track, 2610 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: 0x000b604c Device Boot Start End Blocks Id System
- /dev/sda1 * 1 523 4194304 83 Linux
- Partition 1 does not end on cylinder boundary.
- /dev/sda2 523 784 2097152 82 Linux swap / Solaris
- Partition 2 does not end on cylinder boundary.
- /dev/sda3 784 2610 14672345 5 Extended
- /dev/sda5 784 1421 5121671 83 LinuxCommand (m for help): w
- The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: 裝置或資源忙.
- 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.
-
儲存建立分區,提示“裝置或資源忙”,當時就在/dev/sda硬碟上做的操作,以為該提示為正常現象,所以忽略了,繼續下一步操作。
2、通過partprobe重載分區表,避免重啟系統
- [root@stduy /]# partprobe
- Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (裝置或資源忙). As a result, it may not reflect all of your changes until after reboot.
- Warning: 無法以讀寫方式開啟 /dev/sr0 (唯讀檔案系統)。/dev/sr0 已按照唯讀方式開啟。
- Warning: 無法以讀寫方式開啟 /dev/sr0 (唯讀檔案系統)。/dev/sr0 已按照唯讀方式開啟。
- Error: 無效的分區表 - /dev/sr0 出現遞迴資料分割。
重載分區出現的上述資訊中,當時對於警告提示“裝置或資源忙,需要重啟系統才能使更改生效”直接忽略,以為是正常現象。但是對於錯誤資訊“Error: 無效的分區表 - /dev/sr0 出現遞迴資料分割。”就有點茫然了,不過,既然提示“無效的分區表”,那我查下分區資訊。