歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> Linux 磁盤分區 Fdisk

Linux 磁盤分區 Fdisk

日期:2017/3/3 11:42:31   编辑:Linux技術

linux磁盤分區:fdisk(小於2T的分區工具)

[root@zyl ~]# fdisk -l #####查看磁盤空間

Disk /dev/sda: 16.1 GB, 16106127360 bytes255 heads, 63 sectors/track, 1958 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00061f64

Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 307 2252800 82 Linux swap / SolarisPartition 2 does not end on cylinder boundary./dev/sda3 307 1959 13270016 83 Linux

Disk /dev/sdb: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000

[root@zyl ~]# fdisk --help #####查看幫助 fdisk: invalid option -- '-'

Usage: fdisk [options] <disk> change partition table fdisk [options] -l <disk> list partition table(s) fdisk -s <partition> give partition size(s) in blocks

Options: -b <size> sector size (512, 1024, 2048 or 4096) -c switch off DOS-compatible mode -h print help -u <size> give sizes in sectors instead of cylinders -v print version -C <number> specify the number of cylinders -H <number> specify the number of heads -S <number> specify the number of sectors per track

[root@zyl ~]# fdisk -l /dev/sdb #####查看/dev/sdb磁盤空間

Disk /dev/sdb: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000

[root@zyl ~]# fdisk /dev/sdb #####查看/dev/sdb磁盤空間Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0x4f8513b3.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 to switch off the mode (command 'c') and change display units to sectors (command 'u').

Command (m for help): m ##### 輸入m 查看幫助Command 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 #####新建一個分區Command action e extended #####分區類型 擴展分區 p primary partition (1-4) #####主分區p #####新建主分區Partition number (1-4): 1First cylinder (1-130, default 1): #####默認為1Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +100M

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x4f8513b3

Device Boot Start End Blocks Id System/dev/sdb1 1 14 112423+ 83 Linux

Command (m for help): mCommand 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): nCommand action e extended p primary partition (1-4)ePartition number (1-4): 1Partition 1 is already defined. Delete it before re-adding it.#分區1已經定義。刪除它之前重新添加它

Command (m for help): nCommand action e extended p primary partition (1-4)e #####新建擴展分區Partition number (1-4): 2First cylinder (15-130, default 15): 15Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130): Using default value 130

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x4f8513b3

Device Boot Start End Blocks Id System/dev/sdb1 1 14 112423+ 83 Linux/dev/sdb2 15 130 931770 5 Extended

Command (m for help): nCommand action l logical (5 or over) #####分區類型 邏輯分區 p primary partition (1-4)pPartition number (1-4): 2 #####此僅為測試Partition 2 is already defined. Delete it before re-adding it.

Command (m for help): nCommand action l logical (5 or over) p primary partition (1-4)pPartition number (1-4): 4 #####此僅為測試No free sectors available #####發現沒有空間。即創建邏輯分區

Command action l logical (5 or over) p primary partition (1-4)lFirst cylinder (15-130, default 15): Using default value 15Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130): +400MUnsupported suffix+400M'.Supported: 10^N: KB (KiloByte), MB (MegaByte), GB (GigaByte) 2^N: K (KibiByte), M (MebiByte), G (GibiByte)Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130): +400M

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x4f8513b3

Device Boot Start End Blocks Id System/dev/sdb1 1 14 112423+ 83 Linux/dev/sdb2 15 130 931770 5 Extended/dev/sdb5 15 66 417658+ 83 Linux

Command (m for help): nCommand action l logical (5 or over) p primary partition (1-4)lFirst cylinder (67-130, default 67): Using default value 67Last cylinder, +cylinders or +size{K,M,G} (67-130, default 130): Using default value 130

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x4f8513b3

Device Boot Start End Blocks Id System/dev/sdb1 1 14 112423+ 83 Linux/dev/sdb2 15 130 931770 5 Extended/dev/sdb5 15 66 417658+ 83 Linux/dev/sdb6 67 130 514048+ 83 Linux

[root@zyl ~]# fdisk -l

Disk /dev/sda: 16.1 GB, 16106127360 bytes255 heads, 63 sectors/track, 1958 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00061f64

Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 307 2252800 82 Linux swap / SolarisPartition 2 does not end on cylinder boundary./dev/sda3 307 1959 13270016 83 Linux

Disk /dev/sdb: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x4f8513b3

Device Boot Start End Blocks Id System/dev/sdb1 1 14 112423+ 83 Linux/dev/sdb2 15 130 931770 5 Extended/dev/sdb5 15 66 417658+ 83 Linux/dev/sdb6 67 130 514048+ 83 Linux [root@zyl ~]# partprobe #####強制內核重新查找一次分區表Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.[root@zyl /]# ll /dev/sd*brw-rw----. 1 root disk 8, 0 Jun 25 2016 /dev/sdabrw-rw----. 1 root disk 8, 1 Jun 25 01:58 /dev/sda1brw-rw----. 1 root disk 8, 2 Jun 25 2016 /dev/sda2brw-rw----. 1 root disk 8, 3 Jun 25 2016 /dev/sda3brw-rw----. 1 root disk 8, 16 Jun 25 02:16 /dev/sdbbrw-rw----. 1 root disk 8, 17 Jun 25 02:16 /dev/sdb1brw-rw----. 1 root disk 8, 18 Jun 25 02:16 /dev/sdb2brw-rw----. 1 root disk 8, 21 Jun 25 02:16 /dev/sdb5brw-rw----. 1 root disk 8, 22 Jun 25 02:16 /dev/sdb6

[root@zyl /]# mkfs.ext4 /dev/sdb1 #####格式化/dev/sdb1 mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=1024 (log=0)Fragment size=1024 (log=0)Stride=0 blocks, Stripe width=0 blocks28112 inodes, 112420 blocks5621 blocks (5.00%) reserved for the super userFirst data block=1Maximum filesystem blocks=6737100814 block groups8192 blocks per group, 8192 fragments per group2008 inodes per groupSuperblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729

Writing inode tables: done Creating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@zyl /]# [root@zyl /]# tune2fs -c -1 /dev/sdb1 #####調整和查看/dev/sdb1文件系統的參數tune2fs 1.41.12 (17-May-2010)Setting maximal mount count to -1[root@zyl /]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 13G 1.6G 11G 14% /tmpfs 935M 0 935M 0% /dev/shm/dev/sda1 194M 34M 151M 19% /boot[root@zyl /]# [root@zyl /]# [root@zyl /]# ls /dev/sd*/dev/sda /dev/sda2 /dev/sdb /dev/sdb2 /dev/sdb6/dev/sda1 /dev/sda3 /dev/sdb1 /dev/sdb5[root@zyl /]# ll /dev/sd*brw-rw----. 1 root disk 8, 0 Jun 25 2016 /dev/sdabrw-rw----. 1 root disk 8, 1 Jun 25 01:58 /dev/sda1brw-rw----. 1 root disk 8, 2 Jun 25 2016 /dev/sda2brw-rw----. 1 root disk 8, 3 Jun 25 2016 /dev/sda3brw-rw----. 1 root disk 8, 16 Jun 25 02:24 /dev/sdbbrw-rw----. 1 root disk 8, 17 Jun 25 02:28 /dev/sdb1brw-rw----. 1 root disk 8, 18 Jun 25 02:16 /dev/sdb2brw-rw----. 1 root disk 8, 21 Jun 25 02:16 /dev/sdb5brw-rw----. 1 root disk 8, 22 Jun 25 02:16 /dev/sdb6[root@zyl /]# mount /dev/sdsda sda1 sda2 sda3 sdb sdb1 sdb2 sdb5 sdb6 [root@zyl /]# mount /dev/sdb1 /mnt[root@zyl /]# touch /mnt/dddd[root@zyl /]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 13G 1.6G 11G 14% /tmpfs 935M 0 935M 0% /dev/shm/dev/sda1 194M 34M 151M 19% /boot/dev/sdb1 107M 5.6M 96M 6% /mnt[root@zyl /]# parted /dev/sdbGNU Parted 2.1Using /dev/sdbWelcome to GNU Parted! Type 'help' to view a list of commands.

本文出自 “randolph” 博客,轉載請與作者聯系!

Copyright © Linux教程網 All Rights Reserved