您好來
列出文件系統的整自體磁碟空間使用情況。可以用來查看磁碟已被使用多少空間和還剩餘多少空間。
df-h
當前分區裡面沒有任何信息,繼續操作
---------------------
作者:dongsir 董先生
原文:Linux 分區和掛載
本文為博主原創文章,轉載請附上博文鏈接!
版權聲明:本作品採用知識共享署名-非商業性使用-相同方式共享 4.0 國際許可協議進行許可,轉載時請標注 https://blog.csdn.net/qq6759/article/details/85319274
② linux鏍煎紡鍖栨寕杞界佺洏linux鏍煎紡鍖栨寕杞
linux紓佺洏鍒嗛厤鍚庢庝箞鏍煎紡鍖栵紵
1銆佺偣鍑葷數鑴戝乏涓嬭掔殑綆澶翠綅緗鏍囧織錛岀劧鍚庨夋嫨鍚鍔ㄧ粓絝錛屽湪緇堢涓婇潰杈撳叆鍛戒護鍥炶濺錛岀劧鍚庢壘鍒扮數鑴戜笂闈㈢殑紜鐩橈紝鍏朵腑sda鍒欐槸絎涓涓紜鐩橈紝sdb鏄絎浜屼釜紜鐩樸
2銆佸湪緇堢杈撳叆鍛戒護鍥劇墖閲岀殑鍛戒護錛岀劧鍚庢寜鍥炶濺閿錛屾寕杞芥垚鍔熷悗鐐瑰嚮宸︿笅瑙掔殑絎﹀彿錛岀劧鍚庣偣鍑繪枃浠剁$悊鍣ㄣ
3銆佸懡浠ゅ洖杞﹀悗錛屼細寮瑰嚭鐧懼垎姣旂殑鍥劇墖錛岃愬績絳夊緟涓夊埌浜斿垎閽熷嵆鍙錛屾渶鍚庢垚鍔熷悗浼氭樉紺篶ompletedsuccessfully錛岃瘉鏄庢垚鍔熸牸寮忓寲銆
闃塊噷浜戦儴緗睱inux濡備綍鏍煎紡鍖栧拰鎸傝澆鏁版嵁鐩橈紵
姝ラ4錛氭牸寮忓寲鍜屾寕杞芥暟鎹鐩樺傛灉鎮ㄥ湪鍒涘緩瀹炰緥鏃墮夋嫨浜嗘暟鎹鐩橈紝鍦ㄧ櫥褰曞疄渚嬪悗錛岀郴緇熼渶瑕佸厛鏍煎紡鍖栨暟鎹鐩橈紝鐒跺悗鎸傝澆鏁版嵁鐩樸傚彟澶栵紝鎮ㄨ繕鍙浠ユ牴鎹涓氬姟闇瑕侊紝瀵規暟鎹鐩樿繘琛屽氬垎鍖洪厤緗銆傚緩璁浣跨敤緋葷粺鑷甯︾殑宸ュ叿榪涜屽垎鍖烘搷浣溿傛敞鎰忥細浜戞湇鍔″櫒ECS浠呮敮鎸佸規暟鎹鐩樿繘琛屼簩嬈″垎鍖猴紝鑰屼笉鏀鎸佸圭郴緇熺洏榪涜屼簩嬈″垎鍖(涓嶇℃槸Windows榪樻槸Linux緋葷粺)銆傚傛灉鎮ㄥ己琛屼嬌鐢ㄧ涓夋柟宸ュ叿瀵圭郴緇熺洏榪涜屼簩嬈″垎鍖烘搷浣滐紝鍙鑳藉紩鍙戞湭鐭ラ庨櫓錛屽傜郴緇熷穿婧冦佹暟鎹涓㈠け絳夈傛湰鎿嶄綔閫傜敤浜庨潪I/O浼樺寲+SSD浜戠洏Linux(Redhat銆丆entOS銆丏ebian銆乁buntu)瀹炰緥銆傚逛簬I/O浼樺寲瀹炰緥+SSD浜戠洏鏁版嵁鐩樺垎鍖烘寕杞斤紝寤鴻浣跨敤鑴氭湰宸ュ叿錛歛uto_fdisk_ssd.sh1銆佷嬌鐢ㄨ繙紼嬭繛鎺ュ伐鍏鳳紝杈撳叆鐢ㄦ埛鍚峳oot鍜屽瘑鐮佺櫥褰曞埌瀹炰緥銆2銆佽繍琛宖disk-l鍛戒護鏌ョ湅鏁版嵁鐩樸傛敞鎰忥細鍦ㄦ病鏈夊垎鍖哄拰鏍煎紡鍖栨暟鎹鐩樹箣鍓嶏紝浣跨敤df-h鍛戒護鏄鏃犳硶鐪嬪埌鏁版嵁鐩樼殑銆傚湪涓嬮潰鐨勭ず渚嬩腑錛屾湁涓涓5GB鐨勬暟鎹鐩橀渶瑕佹寕杞姐傚傛灉鎵ц屼簡fdisk-l鍛戒護鍚庯紝娌℃湁鍙戠幇/dev/xvdb錛屽垯琛ㄧず鎮ㄧ殑瀹炰緥娌℃湁鏁版嵁鐩橈紝鍥犳ゆ棤闇鎸傝澆銆傚彲浠ュ拷鐣ヨ繖涓絝犮3銆佽繍琛宖disk/dev/xvdb錛屽規暟鎹鐩樿繘琛屽垎鍖恆傛牴鎹鎻愮ず錛屼緷嬈¤緭鍏n錛宲錛1錛屼袱嬈″洖杞︼紝wq錛屽垎鍖哄氨寮濮嬩簡銆4銆佽繍琛宖disk-l鍛戒護錛屾煡鐪嬫柊鐨勫垎鍖恆傛柊鍒嗗尯xvdb1宸茬粡鍒涘緩濂姐傚備笅闈㈢ず渚嬩腑鐨/dev/xvdb1銆傘5銆佽繍琛宮kfs.ext3/dev/xvdb1錛屽規柊鍒嗗尯榪涜屾牸寮忓寲銆傛牸寮忓寲鎵闇鏃墮棿鍙栧喅浜庢暟鎹鐩樺ぇ灝忋傛偍涔熷彲鑷涓誨喅瀹氶夌敤鍏朵粬鏂囦歡鏍煎紡錛屽俥xt14絳夈6銆佽繍琛宔cho鈥/dev/xvdb1/mntext3defaults00鈥>>/etc/fstab鍐欏叆鏂板垎鍖轟俊鎮銆傚畬鎴愬悗錛屽彲浠ヤ嬌鐢╟at/etc/fstab鍛戒護鏌ョ湅銆傛敞鎰忥細Ubuntu12.04涓嶆敮鎸乥arrier錛屾墍浠ュ硅ョ郴緇熸g『鐨勫懡浠ゆ槸錛歟cho鈥/dev/xvdb1/mntext3barrier=000鈥>>/etc/fstab濡傛灉闇瑕佹妸鏁版嵁鐩樺崟鐙鎸傝澆鍒版煇涓鏂囦歡澶癸紝姣斿傚崟鐙鐢ㄦ潵瀛樻斁緗戦〉錛屽彲浠ヤ慨鏀逛互涓婂懡浠や腑鐨/mnt閮ㄥ垎銆7銆佽繍琛宮ount/dev/xvdb1/mnt鎸傝澆鏂板垎鍖猴紝鐒跺悗鎵ц宒f-h鏌ョ湅鍒嗗尯銆傚傛灉鍑虹幇鏁版嵁鐩樹俊鎮錛岃存槑鎸傝澆鎴愬姛錛屽彲浠ヤ嬌鐢ㄦ柊鍒嗗尯浜嗐
linux鐜澧冧笅鎬庝箞淇鏀瑰垎鍖虹殑鎸傝澆鐩褰曪紵
鏍煎紡鍖栧垎鍖哄傛灉鍒涘緩鐨勬槸涓誨垎鍖猴紝灝嗘柊鍒嗗尯鏍煎紡鍖栦負鐩稿簲鐨勬枃浠剁郴緇燂紙鏌ョ湅鍙鐢╠f-T錛
#mkfs-text4/dev/sdb2鎸傝澆紜鐩樺厛鍒涘緩鎸傝澆鐐,鏂板緩涓涓鐩褰#mkdir/storage灝嗙‖鐩樻寕杞藉埌鏂板緩鐩褰曚笅#mount/dev/sdb2/storage
linuxx鏁戞彺妯″紡濡備綍鎸傝澆鏍圭洰褰曪紵
浣跨敤浠ヤ笅鍛戒護錛
1銆佹壘鐨勬湭鎸傝澆紓佺洏
fdisk-l
2銆佹牸寮忓寲
mkfs-text4/dev/xvdc
3銆佹寕杞界洰褰
mount/dev/xvdc/data
4銆佸紑鏈哄惎鍔
vi/etc/fstab
/dev/xvdc/dataext4defaults12
linux鏈鍒嗛厤絀洪棿鎬庝箞浣跨敤錛
鍙浠ュ皢鏈鍒嗛厤鐨勭殑紓佺洏絀洪棿鏍煎紡鍖栧苟鎸傝澆鍒頒竴涓鐩褰曚笅浣跨敤銆
浣跨敤fdisk-l鍛戒護鐪嬩竴涓嬬‖鐩樹俊鎮錛屾瘮濡傛槸/dev/sda榪欎釜紜鐩樿懼囨湁鏈鍒嗛厤鐨勭┖闂寸殑璇濓紝浣跨敤fdisk/dev/sda榪涘叆紜鐩樺垎鍖虹晫闈銆
榪樻湁鍙︿竴涓鏂規硶灝辨槸鐢↙VM閫昏緫鍗風$悊鐨勮瘽錛屾墿灞曟枃浠剁郴緇熸墍鍦ㄧ殑閫昏緫鍗鳳紝鍐嶆墿灞曟枃浠剁郴緇熷氨鏄浜嗭紝鐒跺悗鎵ц宒f-hmount錛屽氨鍙浠ヤ簡銆
③ Linux涓嬫坊鍔犳柊紜鐩橈紝鍒嗗尯騫惰劇疆鍚鍔ㄨ嚜鍔ㄦ寕杞
Linux涓嬬殑鍒嗗尯鐩稿筗indows鑰岃█瑕佺◢寰澶嶆潅涓鐐癸紝涓嬮潰灝辯敱鎴戠粰澶у跺甫鏉ュ湪Linux涓嬫柊娣誨姞紜鐩橈紝鍒嗗尯騫跺疄鐜扮郴緇熷惎鍔ㄦ椂鑷鍔ㄦ寕杞界殑榪囩▼
媯鏌ュ彂鐜扮郴緇熶笂鐩鍓嶅苟娌℃湁鎸傝澆鏂扮殑紜鐩橈紝濡備笅鍥炬墍紺猴細
娣誨姞紜鐩樺悗鎴戜滑鍚鍔ㄧ數鑴戝苟鍐嶆℃鏌ワ紝鎴戜滑鍙浠ョ湅鍒版渶涓嬮潰澶氫簡涓琛屸淒isk /dev/sdb doesn't contain a valid partition table鈥濓紝鍛婅瘔鎴戜滑鏈変竴鍧楁柊鐨勭‖鐩橈紝浣嗘槸榪樻病鏈夊垎鍖猴紱濡備笅鍥炬墍紺猴細
鏍規嵁浠ヤ笂鎻愮ず寮濮嬪規柊鐨勭‖鐩樿繘琛屽垎鍖烘搷浣滐紝鐢變簬鎴鍥炬瘮杈冮夯鐑︽墍浠ュ憿鎴戞妸鍛介噷鍑烘潵浜嗭紝闇瑕佹搷浣滅殑閮ㄥ垎鎴戜細鏍囪板嚭鏉 [root@Linux ~]#fdisk /dev/sdb //鏍規嵁鎻愮ず,瀵規柊紜鐩樿繘琛屽垎鍖烘搷浣淒evice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes will remain in memory only,until you decide to write them. After that, of course, the previouscontent won't be recoverable.The number of cylinders for this disk is set to 2610.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help):h //甯鍔╀俊鎮痟: unknown commandCommand action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition //鍒犻櫎鍒嗗尯 l list known partition types m print this menu //鏌ョ湅鎿嶄綔鎸囦護鐨勫府鍔╀俊鎮 n add a new partition //鏂板緩鍒嗗尯 o create a new empty DOS partition table p print the partition table //鍒楄〃鏌ョ湅鍒嗗尯淇℃伅 q quit without saving changes //鏀懼純鍒嗗尯璁劇疆騫墮鍑 s create a new empty Sun disklabel t change a partition's system id //鍙樻洿鍒嗗尯綾誨瀷 u change display/entry units v verify the partition table w write table to disk and exit //淇濆瓨鍒嗗尯璁劇疆騫墮鍑 x extra functionality (experts only) Command (m for help):n //杈撳叆 n錛屾柊寤哄垎鍖篊ommand action e extended //鏂板緩閫昏緫鍒嗗尯 p primary partition (1-4) //鏂板緩涓誨垎鍖簆 //杈撳叆 p錛屽緩絝嬩富鍒嗗尯Partition number (1-4):1 //涓鍏卞彲浠ュ垎4涓涓誨垎鍖猴紝杈撳叆 1錛屽緩絝嬬涓涓涓誨垎鍖篎irst cylinder (1-2610, default 1)://閫夋嫨璇ュ垎鍖虹殑璧峰嬬佺洏鏁幫紝濡傛棤鐗規畩闇奼傚己鐑堝緩璁閫夋嫨榛樿わ紝涔熷氨鏄榛樿ょ敤1 鏉ュ垎鍖猴紙鐩存帴鎸夊洖杞︼級Using default value 1Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610)://瀹氫箟璇ュ垎鍖虹殑澶у皬錛屽傛灉鎸夐粯璁わ紙鐩存帴鍥炶濺錛夛紝灝辨槸浣跨敤鍏ㄩ儴鍙鐢ㄥ瓨鍌ㄧ┖闂達紱濡傛灉瑕佸垎鎴愪竴涓 1G 鐨勭┖闂達紝杈撳叆 +1024m 鍗沖彲,1G=1024m綆楁硶浠ユょ被鎺║sing default value 2610Command (m for help):w //鍐欏叆鍒嗗尯淇℃伅錛屽叾瀹炲氨鏄淇濆瓨鍒嗗尯淇℃伅The partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.
瀹屾垚浠ヤ笂鎿嶄綔鍚庢垜浠鍙浠ョ湅鍒版柊娣誨姞鐨勭‖鐩樺凡緇忓瓨鍦ㄥ垎鍖轟簡
涓嬮潰瀵瑰垎鍖鴻繘琛屾牸寮忓寲鎿嶄綔錛 [root@Linux ~]#mkfs -t ext3 -c/dev/sdb1 //瀵瑰垎鍖轟嬌鐢 ext3 鏍煎紡鍖栵紝濡傛灉寤虹珛浜嗗氫釜鍒嗗尯錛屾樉紺 /dev/sdb2銆/dev/sdb3 絳夛紝浠ユょ被鎺錛岄噸澶嶈緭鍏ヨ繖鏉″懡浠わ紝灝卞彲浠ヨ繘琛屽叾瀹冨垎鍖虹殑鏍煎紡鍖栨搷浣滀簡銆傚洜涓烘柊紜鐩樺姞浜-c鍙傛暟錛岃佸厛媯嫻嬬佺洏鍧忛亾錛屽洜姝わ紝榪欎釜榪囩▼鍏ㄦ湁浜涢暱錛岄渶瑕佽愬績絳夊緟鈥︹︽敞鎰忚繖閲岀殑鏃墮棿闀跨煭鏃舵牴鎹浣犵殑紜鐩樺ぇ灝忔潵瀹炵幇鐨勶紝濡傛灉紜鐩樺ぇ鏃墮棿灝變細涔呬竴浜涳紝鍚﹀垯灝變細灝忕煭涓浜沵ke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=4096 (log=2)Fragment size=4096 (log=2)1310720 inodes, 5241198 blocks131029blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=0160 block groups32768 blocks per group, 32768 fragments per group16384 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632Checking for bad blocks (read-only test): done Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 32 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.
寮濮嬪瑰垎鍖鴻繘琛屾寕杞戒嬌鐢錛岄栧厛鍒涘緩涓涓鐢ㄤ簬鎸傝澆鐨勭洰褰
灝嗗垎鍖烘寕杞藉埌www鐩褰曚笅
杈撳叆vim /etc/fstab榪涜岀紪杈戱紝騫跺湪璇ユ枃浠跺唴杈撳叆浠ヤ笅鍐呭癸紝鐒跺悗鍦錛歸q淇濆瓨騫墮鍑猴紝閲嶅惎楠岃瘉鍗沖彲
④ Linux文件怎麼掛載
第一步,為這個新創建的文件系統(/dev/sdb1)創建掛載點目錄,一般是在根文件系統的mnt目錄(即:/mnt)下建立掛載目錄,也可以在其他位置建立掛載目錄,這里我們在根目錄下建立新的掛載目錄(如:/extdsk),使用命令 # mkdir /extdsk (目錄名稱可自定)。
第二步,確定掛載目錄後,需要為新文件系統/dev/sdb1增加磁碟標志,這個標志很重要,當需要自動掛載此文件系統時,默認的/etc/fstab文件會使用磁碟標志,而分區命令fdisk以及格式化命令mkfs都不增加此標志,這個標志應該是掛載目錄的完整路徑名,此處應該用命令 #e2label /dev/sdb1 /extdsk 完成此操作,命令中的/extdsk就是磁碟標志名稱。
第三步,使用mount命令這個新文件系統/dev/sdb1掛載到掛載目錄/extdsk,
命令格式為:#mount–t ext3 /dev/sdb1 /extdsk在此步驟中應該說明:如果在/etc/filesystems文件中包含了ext3文件系統格式,命令中的「-t ext3」參數可以省略不寫,命令會自動找出與/dev/sdb1分區相應的格式。
第四步,將這個新創建文件系統/dev/sdb1加入到/etc/fstab文件中,設置成開機自動載入,可以免去每次重啟系統都手動載入該文件系統的麻煩。