日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux下使用fdisk命令进行硬盘分区

發布時間:2025/3/17 linux 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux下使用fdisk命令进行硬盘分区 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

添加一塊硬盤

#?fdisk?-l Disk?/dev/vdb:?53.7?GB,?53687091200?bytes 16?heads,?63?sectors/track,?104025?cylinders Units?=?cylinders?of?1008?*?512?=?516096?bytes Sector?size?(logical/physical):?512?bytes?/?512?bytes I/O?size?(minimum/optimal):?512?bytes?/?512?bytes Disk?identifier:?0x00000000


用fdisk命令進入分區界面

#?fdisk?/dev/vdb Device?contains?neither?a?valid?DOS?partition?table,?nor?Sun,?SGI?or?OSF?disklabel Building?a?new?DOS?disklabel?with?disk?identifier?0xb5f18769. Changes?will?remain?in?memory?only,?until?you?decide?to?write?them. After?that,?of?course,?the?previous?content?won't?be?recoverable. Warning:?invalid?flag?0x0000?of?partition?table?4?will?be?corrected?by?w(rite) WARNING:?DOS-compatible?mode?is?deprecated.?It's?strongly?recommended?toswitch?off?the?mode?(command?'c')?and?change?display?units?tosectors?(command?'u'). Command?(m?for?help):



Command?(m?for?help):?n????//?輸入n新建一個分區 Command?actione???extended????//e是擴展分區p???primary?partition?(1-4)????//p是主分區 p???//選擇p Partition?number?(1-4):?1?????//分區號 First?cylinder?(1-104025,?default?1):?????//默認回車就行 Using?default?value?1 Last?cylinder,?+cylinders?or?+size{K,M,G}?(1-104025,?default?104025):?25600M??//可以輸入具體要分多少空間給這個分區,這里我分25G參考://Supported:?10^N:?KB?(KiloByte),?MB?(MegaByte),?GB?(GigaByte)2^N:?K??(KibiByte),?M?(MebiByte),?G??(GibiByte)


分第二個分區

Command?(m?for?help):?n Command?actione???extendedp???primary?partition?(1-4) p Partition?number?(1-4):?2 First?cylinder?(52015-104025,?default?52015):? Using?default?value?52015 Last?cylinder,?+cylinders?or?+size{K,M,G}?(52015-104025,?default?104025):????????//這里直接回車默認所有空間 Using?default?value?104025


查看剛剛分的2個區。可以看到vdb1和vdb2

Command?(m?for?help):?p????//輸入p查看分區 Disk?/dev/vdb:?53.7?GB,?53687091200?bytes 16?heads,?63?sectors/track,?104025?cylinders Units?=?cylinders?of?1008?*?512?=?516096?bytes Sector?size?(logical/physical):?512?bytes?/?512?bytes I/O?size?(minimum/optimal):?512?bytes?/?512?bytes Disk?identifier:?0xb7a8f045Device?Boot??????Start?????????End??????Blocks???Id??System /dev/vdb1???????????????1???????52014????26215024+??83??Linux /dev/vdb2???????????52015??????104025????26213544???83??Linux


保存分區退出(一定要保存,不然得重來了。)

Command?(m?for?help):?w????//輸入w保存退出 The?partition?table?has?been?altered! Calling?ioctl()?to?re-read?partition?table. Syncing?disks.


查看分好的分區

#?fdisk?-l Disk?/dev/vdb:?53.7?GB,?53687091200?bytes 16?heads,?63?sectors/track,?104025?cylinders Units?=?cylinders?of?1008?*?512?=?516096?bytes Sector?size?(logical/physical):?512?bytes?/?512?bytes I/O?size?(minimum/optimal):?512?bytes?/?512?bytes Disk?identifier:?0xb7a8f045Device?Boot??????Start?????????End??????Blocks???Id??System /dev/vdb1???????????????1???????52014????26215024+??83??Linux /dev/vdb2???????????52015??????104025????26213544???83??Linux


格式化分區

#?mkfs.ext3?/dev/vdb1#?mkfs.ext3?/dev/vdb2


創建掛載文件夾

#?mkdir?/vdb1?/vdb2


掛載分區到文件夾

#?mount?/dev/vdb1?/vdb1 #?mount?/dev/vdb2?/vdb2


分區完成,數據寫入掛載的文件夾就寫入到硬盤了。


但是重啟之后linux不會自動掛載,需要在/etc/fstab文件添加后面2條。保存之后下次重啟就會自動掛載了。

#?vim?/etc/fstab tmpfs??????????/dev/shm????????tmpfs???defaults????????0?0 devpts??????????/dev/pts????????devpts???gid=5,mode=620????????0?0 sysfs??????????/sys??????????sysfs???defaults????????0?0 proc???????????/proc???????????proc???defaults????????0?0 /dev/vdb1????????/vdb1??????????ext3???defaults????????1?2 /dev/vdb2????????/vdb2??????????ext3???defaults????????1?2


另外:可通過cat /proc/partitions 查看分區信息

[root@myslaver?~]#?cat?/proc/partitions major????minor??#blocks?name252????????0???52428800?vda252????????1?????512000?vda1252????????2????7875584?vda2252???????16???52428800?vdb252???????17???26215024?vdb1252???????18???26213544?vdb2253????????0????7036928?dm-0253????????1?????835584?dm-1


轉載于:https://blog.51cto.com/kurolz/1873063

總結

以上是生活随笔為你收集整理的linux下使用fdisk命令进行硬盘分区的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。