成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Linux下用fdisk命令和partprobe命令不重啟系統新建分區并格式化

系統 Linux
在學習磁盤管理時,使用fdisk將剩余的容量繼續分區。卻發現新建完分區后,無法通過partprobe重載分區。

由于工作的需要,最近一段時間一直在學習Linux。學習一門新的知識,我是喜歡根據謀一本書或者某一個學習視頻系統的學習,這樣可以對學習的新知識有一個系統全面的認識和了解。所以學習之前,買了一本鳥哥的私房菜做為參考書,開始系統的學習Linux。

根據鳥哥的建議,安裝虛擬機時,預留了一塊空的容量用來練習分區使用。所以在虛擬機上安裝Linux系統分區時,只劃分了一塊4G的容量掛載到根目錄“/”下,還有就是只劃分了一個2G的swap分區。還有14G的容量沒有分配。

在學習磁盤管理時,使用fdisk將剩余的容量繼續分區。卻發現新建完分區后,無法通過partprobe重載分區。

具體操作如下所示:

1、使用fdisk新建分區

(。。。。)分區操作記錄沒有保存下來,執行w后,出現下列信息

  1. Disk /dev/sda: 21.5 GB, 21474836480 bytes  
  2. 255 heads, 63 sectors/track, 2610 cylinders  
  3. Units = cylinders of 16065 * 512 = 8225280 bytes  
  4. Sector size (logical/physical): 512 bytes / 512 bytes  
  5. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  6. Disk identifier: 0x000b604c Device Boot Start End Blocks Id System  
  7. /dev/sda1 * 1 523 4194304 83 Linux  
  8. Partition 1 does not end on cylinder boundary.  
  9. /dev/sda2 523 784 2097152 82 Linux swap / Solaris  
  10. Partition 2 does not end on cylinder boundary.  
  11. /dev/sda3 784 2610 14672345 5 Extended  
  12. /dev/sda5 784 1421 5121671 83 LinuxCommand (m for help): w  
  13. The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: 設備或資源忙.  
  14. The kernel still uses the old table. The new table will be used at  
  15. the next reboot or after you run partprobe(8) or kpartx(8)  
  16. Syncing disks.  
  17.  

保存新建分區,提示“設備或資源忙”,當時就在/dev/sda硬盤上做的操作,以為該提示為正常現象,所以忽略了,繼續下一步操作。

2、通過partprobe重載分區表,避免重啟系統

  1. [root@stduy /]# partprobe   
  2. 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.  
  3. Warning: 無法以讀寫方式打開 /dev/sr0 (只讀文件系統)。/dev/sr0 已按照只讀方式打開。  
  4. Warning: 無法以讀寫方式打開 /dev/sr0 (只讀文件系統)。/dev/sr0 已按照只讀方式打開。  
  5. Error: 無效的分區表 - /dev/sr0 出現遞歸分區。 

重載分區出現的上述信息中,當時對于警告提示“設備或資源忙,需要重啟系統才能使更改生效”直接忽略,以為是正常現象。但是對于錯誤信息“Error: 無效的分區表 - /dev/sr0 出現遞歸分區。”就有點茫然了,不過,既然提示“無效的分區表”,那我查下分區信息。

#p#

3、使用fdisk -l 命令查看分區信息

  1. [root@stduy /]# fdisk -l  
  2. Disk /dev/sda: 21.5 GB, 21474836480 bytes  
  3. 255 heads, 63 sectors/track, 2610 cylinders  
  4. Units = cylinders of 16065 * 512 = 8225280 bytes  
  5. Sector size (logical/physical): 512 bytes / 512 bytes  
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  7. Disk identifier: 0x000b604c Device Boot Start End Blocks Id System  
  8. /dev/sda1 * 1 523 4194304 83 Linux  
  9. Partition 1 does not end on cylinder boundary.  
  10. /dev/sda2 523 784 2097152 82 Linux swap / Solaris  
  11. Partition 2 does not end on cylinder boundary.  
  12. /dev/sda3 784 2610 14672345 5 Extended  
  13. /dev/sda5 784 1421 5121671 83 Linux 

查看分區信息,正常啊,并且剛才新建的擴展分區/dev/sda3和邏輯分區/dev/sda5都在。于是直接對新建的分區/dev/sda5進行格式化。

4、格式化新建的邏輯分區/dev/sda5

  1. [root@stduy /]# mkfs -t ext3 /dev/sda5  
  2. mke2fs 1.41.12 (17-May-2010) 

無法對 /dev/sda5 進行 stat 調用 --- 沒有那個文件或目錄
The device apparently does not exist; did you specify it correctly?

格式化時,提示“沒有那個文件或目錄”。這就奇怪了,操作是根據參考書上一步一步來的,怎么就不行了呢?于是百度Linux下新建分區的一些信息,希望可以的找到類似的錯誤,借鑒解決辦法。找了一圈下來,倒是有個類似的錯誤,但是沒有給出解決辦法。

重新分析新建分區并重載分區表的過程,對于“設備或資源忙”的提示,因為當時就是在/dev/sda這塊硬盤上操作的,提示“設備或資源忙”應該是正常的,重啟下應該就可以了。但是重啟后,還是找不到/dev/sda5,但是fdisk -l 查看是有的。于是懷疑是不是重載分區表時的“Error: 無效的分區表 - /dev/sr0 出現遞歸分區。”錯誤信息導致的呢?

查看了下/dev下的sr0

  1. [root@stduy dev]# ls -lh | grep sr0  
  2. lrwxrwxrwx. 1 root root 3 8月 5 00:12 cdrom -> sr0  
  3. lrwxrwxrwx. 1 root root 3 8月 5 00:12 cdrw -> sr0  
  4. lrwxrwxrwx. 1 root root 3 8月 5 00:12 dvd -> sr0  
  5. lrwxrwxrwx. 1 root root 3 8月 5 00:12 dvdrw -> sr0  
  6. lrwxrwxrwx. 1 root root 3 8月 5 00:12 scd0 -> sr0  
  7. brw-rw----. 1 root cdrom 11, 0 8月 5 00:12 sr0 

從上面的結果看,sr0是光驅設備,百度了下/dev/sr0這個設備,也所是光驅。于是管它重載分區表失敗是不是由于“Error: 無效的分區表 - /dev/sr0 出現遞歸分區。”引起的,先把光驅移除了再說,反正是虛擬機上。

把虛擬機上的光驅設備移除后,重新啟動系統,再重新新建分區,并重新執行partprobe命令重載分區表,錯誤信息“Error: 無效的分區表 - /dev/sr0 出現遞歸分區。”沒有了,只是警告提示“設備或資源忙”還在。這時直接格式化新建的邏輯分區/dev/sda5還是提示“沒有那個文件或目錄”。于是重啟系統,再格式化/dev/sda5,這回成功了。

也就是,之前新建分區格式化失敗,是由于虛擬機的光驅/dev/sr0設備導致了分區表遞歸。另外由于是在同一塊硬盤上操作,所以必須要重啟系統才能使新建的分區寫入分區表生效。

那鳥哥的私房菜中,說的預留一塊容量用于分區練習,鳥哥是怎么成功的呢?

于是又找了一些Linux磁盤管理相關的視頻和資料,發現,他們使用fdisk新建分區都是使用的多塊硬盤實現的。再重新回去看鳥哥的私房菜,發現鳥哥預留的硬盤是/dev/hdc,那么鳥哥的環境中肯定還有/dev/hda和/dev/hdb,那么鳥哥試驗也是在多快硬盤的基礎上完成的。

那我再給虛擬機分配一塊硬盤試試。于是關閉系統,在虛擬機上又給系統分配了一塊5G的虛擬磁盤空間。再開機進入系統重新對新加的磁盤空間進行分區、格式化等操作。

#p#

步驟還是和上面一樣,分區、重載分區表、查看分區、格式化,這里不再按步驟,直接給出完成的操作記錄。

  1. [root@stduy ~]# fdisk -l  
  2.  
  3. Disk /dev/sda: 21.5 GB, 21474836480 bytes  
  4. 255 heads, 63 sectors/track, 2610 cylinders  
  5. Units = cylinders of 16065 * 512 = 8225280 bytes  
  6. Sector size (logical/physical): 512 bytes / 512 bytes  
  7. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  8. Disk identifier: 0x000b604c  
  9.  
  10. Device Boot Start End Blocks Id System  
  11. /dev/sda1 * 1 523 4194304 83 Linux  
  12. Partition 1 does not end on cylinder boundary.  
  13. /dev/sda2 523 784 2097152 82 Linux swap / Solaris  
  14. Partition 2 does not end on cylinder boundary.  
  15. /dev/sda3 784 2610 14672345 5 Extended  
  16. /dev/sda5 784 2610 14672313+ 83 Linux  
  17.  
  18. Disk /dev/sdb: 5368 MB, 5368709120 bytes  
  19. 255 heads, 63 sectors/track, 652 cylinders  
  20. Units = cylinders of 16065 * 512 = 8225280 bytes  
  21. Sector size (logical/physical): 512 bytes / 512 bytes  
  22. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  23. Disk identifier: 0x00000000  
  24.  
  25. [root@stduy ~]# fdisk /dev/sdb  
  26. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel  
  27. Building a new DOS disklabel with disk identifier 0x851e79cc.  
  28. Changes will remain in memory only, until you decide to write them.  
  29. After that, of course, the previous content won't be recoverable.  
  30.  
  31. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)  
  32.  
  33. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to  
  34. switch off the mode (command 'c') and change display units to  
  35. sectors (command 'u').  
  36.  
  37. Command (m for help): p  
  38.  
  39. Disk /dev/sdb: 5368 MB, 5368709120 bytes  
  40. 255 heads, 63 sectors/track, 652 cylinders  
  41. Units = cylinders of 16065 * 512 = 8225280 bytes  
  42. Sector size (logical/physical): 512 bytes / 512 bytes  
  43. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  44. Disk identifier: 0x851e79cc  
  45.  
  46. Device Boot Start End Blocks Id System  
  47.  
  48. Command (m for help): n  
  49. Command action  
  50. e extended  
  51. p primary partition (1-4)  
  52. p  
  53. Partition number (1-4): 1  
  54. First cylinder (1-652, default 1):   
  55. Using default value 1  
  56. Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652):   
  57. Using default value 652  
  58.  
  59. Command (m for help): p  
  60.  
  61. Disk /dev/sdb: 5368 MB, 5368709120 bytes  
  62. 255 heads, 63 sectors/track, 652 cylinders  
  63. Units = cylinders of 16065 * 512 = 8225280 bytes  
  64. Sector size (logical/physical): 512 bytes / 512 bytes  
  65. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  66. Disk identifier: 0x851e79cc  
  67.  
  68. Device Boot Start End Blocks Id System  
  69. /dev/sdb1 1 652 5237158+ 83 Linux  
  70.  
  71. Command (m for help): w  
  72. The partition table has been altered!  
  73.  
  74. Calling ioctl() to re-read partition table.  
  75. Syncing disks.  
  76. [root@stduy ~]# partprobe /dev/sdb  
  77. [root@stduy ~]# mkfs -t ext4 /dev/sdb1  
  78. mke2fs 1.41.12 (17-May-2010) 

文件系統標簽=操作系統:Linux塊大小=4096 (log=2)分塊大小=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks327680 inodes, 1309289 blocks65464 blocks (5.00%) reserved for the super user
***個數據塊=0Maximum filesystem blocks=134217728040 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736
正在寫入inode表: 完成

  1. Creating journal (32768 blocks): 完成  
  2. Writing superblocks and filesystem accounting information: 完成  
  3. This filesystem will be automatically checked every 36 mounts or180 days, whichever comes first.   
  4. Use tune2fs -c or -i to override. 

這回不管是新建分區,還是重載分區表都沒有警告或錯誤提示了。成功實現在不重啟系統的情況下添加硬盤并對新增硬盤進行分區、格式化等操作。

原文鏈接:http://www.cnblogs.com/tschengbin/p/3891368.html

責任編輯:牛小雨 來源: 他們叫我兔子的博客
相關推薦

2022-01-11 15:10:18

Linuxfdiskparted

2012-05-10 10:10:19

Linuxfdisk

2018-01-15 14:59:35

Linux命令交換分區

2010-02-03 15:07:15

2022-12-30 08:30:28

Linux命令行json

2023-01-12 09:30:31

Linux命令行xml

2019-08-08 14:47:07

Linux命令行JSON

2022-08-01 21:38:25

Linux fmt命令

2023-04-11 10:37:40

bash命令printf

2013-07-02 10:25:03

LinuxUSB設備

2018-12-03 09:10:07

Linux驅動器命令

2018-11-01 09:45:40

2021-09-22 15:00:24

Linuxwatch 命令

2011-08-22 16:23:29

2010-08-03 09:53:50

Linux NFS

2012-03-27 09:42:57

JavaScriptCSS

2012-05-10 10:19:42

Linuxmke2fsk格式化

2012-05-02 16:51:41

Linux

2010-12-24 10:25:20

SCP 命令

2009-11-18 09:26:36

Ubuntulinux關機
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: av一区二区三区四区 | 精品av | 色噜噜亚洲男人的天堂 | 欧美999| 日本小电影在线 | 日本午夜视频 | 亚洲高清一区二区三区 | 一级毛片在线播放 | 国产日产精品一区二区三区四区 | 欧美一级欧美三级在线观看 | 99精品视频免费在线观看 | 日韩成人专区 | 成人天堂 | 国产极品91 | 国产丝袜一区二区三区免费视频 | 免费看a| 成人在线视频免费观看 | 91综合网 | 免费成人午夜 | 国产精品国产自产拍高清 | 日韩午夜电影在线观看 | 最新国产视频 | 国产精品中文字幕在线 | 一级a爱片久久毛片 | 91麻豆蜜桃一区二区三区 | 日韩精品a在线观看图片 | 国内精品久久久久 | 欧美八区 | 亚洲激情在线观看 | 亚洲免费高清 | 粉嫩一区二区三区国产精品 | 欧美久久久久久久 | 亚洲精品一区在线观看 | 91精品一区二区三区久久久久久 | 精品无码久久久久久国产 | av一级毛片 | 在线欧美日韩 | 久久91 | 精品一区二区在线观看 | 日日日视频 | 午夜小电影|