Linux 磁盘分区 Fdisk
linux磁盤分區(qū):fdisk(小于2T的分區(qū)工具)
[root@zyl ~]# fdisk -l ? ? ? ? ? ?#####查看磁盤空間?
Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 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: 0x00061f64
? ?Device Boot ? ? ?Start ? ? ? ? End ? ? ?Blocks ? Id ?System
/dev/sda1 ? * ? ? ? ? ? 1 ? ? ? ? ?26 ? ? ?204800 ? 83 ?Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 ? ? ? ? ? ? ?26 ? ? ? ? 307 ? ? 2252800 ? 82 ?Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 ? ? ? ? ? ? 307 ? ? ? ?1959 ? ?13270016 ? 83 ?Linux
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 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: 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 bytes
255 heads, 63 sectors/track, 130 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: 0x00000000
[root@zyl ~]# fdisk /dev/sdb #####查看/dev/sdb磁盤空間
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building 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 ? ? ? ? ? ? ? ? ? ?#####刪除一個(gè)分區(qū)
? ?l ? list known partition types ? ? ? ? ? ?#####查看分區(qū)類型對(duì)應(yīng)的編號(hào)列表
? ?m ? print this menu ? ? ? ? ? ? ? ? ? ? ? #####打印此幫助菜單
? ?n ? add a new partition ? ? ? ? ? ? ? ? ? #####新建一個(gè)分區(qū)
? ?o ? create a new empty DOS partition table
? ?p ? print the partition table ? ? ? ? ? ? #####打印分區(qū)列表
? ?q ? quit without saving changes ? ? ? ? ? #####退出程序,不保存
? ?s ? create a new empty Sun disklabel ?
? ?t ? change a partition's system id ? ? ? ?#####更改分區(qū)類型
? ?u ? change display/entry units
? ?v ? verify the partition table
? ?w ? write table to disk and exit ? ? ? ? ?#####將分區(qū)寫入分區(qū)表并退出程序
? ?x ? extra functionality (experts only)
Command (m for help): n ? ? ? ? ? ? ? ? ? ? ?#####新建一個(gè)分區(qū)
Command action
? ?e ? extended ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#####分區(qū)類型 ?擴(kuò)展分區(qū)
? ?p ? primary partition (1-4) ? ? ? ? ? ? ? #####主分區(qū)
p ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#####新建主分區(qū)
Partition number (1-4): 1
First cylinder (1-130, default 1): ? ? ? ? ? #####默認(rèn)為1
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +100M
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 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: 0x4f8513b3
? ?Device Boot ? ? ?Start ? ? ? ? End ? ? ?Blocks ? Id ?System
/dev/sdb1 ? ? ? ? ? ? ? 1 ? ? ? ? ?14 ? ? ?112423+ ?83 ?Linux
Command (m for help): 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)
e
Partition number (1-4): 1
Partition 1 is already defined. ?Delete it before re-adding it.#分區(qū)1已經(jīng)定義。刪除它之前重新添加它
Command (m for help): n
Command action
? ?e ? extended
? ?p ? primary partition (1-4)
e ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#####新建擴(kuò)展分區(qū)
Partition number (1-4): 2
First cylinder (15-130, default 15): 15
Last 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 bytes
255 heads, 63 sectors/track, 130 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: 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): n
Command action
? ?l ? logical (5 or over) ? ? ? ? ? ? ? ? ? ? ? ?#####分區(qū)類型 ?邏輯分區(qū)?
? ?p ? primary partition (1-4)
p
Partition number (1-4): 2 ? ? ? ? ? ? ? ? ? ? ? ? #####此僅為測(cè)試
Partition 2 is already defined. ?Delete it before re-adding it.
Command (m for help): n
Command action
? ?l ? logical (5 or over)
? ?p ? primary partition (1-4)
p
Partition number (1-4): 4 ? ? ? ? ? ? ? ? ? ? ? ?#####此僅為測(cè)試
No free sectors available ? ? ? ? ? ? ? ? ? ? ? ?#####發(fā)現(xiàn)沒有空間。即創(chuàng)建邏輯分區(qū)
Command action
? ?l ? logical (5 or over)
? ?p ? primary partition (1-4)
l
First cylinder (15-130, default 15):?
Using default value 15
Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130): +400M
Unsupported 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 bytes
255 heads, 63 sectors/track, 130 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: 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): n
Command action
? ?l ? logical (5 or over)
? ?p ? primary partition (1-4)
l
First cylinder (67-130, default 67):?
Using default value 67
Last 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 bytes
255 heads, 63 sectors/track, 130 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: 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 bytes
255 heads, 63 sectors/track, 1958 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: 0x00061f64
? ?Device Boot ? ? ?Start ? ? ? ? End ? ? ?Blocks ? Id ?System
/dev/sda1 ? * ? ? ? ? ? 1 ? ? ? ? ?26 ? ? ?204800 ? 83 ?Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 ? ? ? ? ? ? ?26 ? ? ? ? 307 ? ? 2252800 ? 82 ?Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 ? ? ? ? ? ? 307 ? ? ? ?1959 ? ?13270016 ? 83 ?Linux
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 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: 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 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#####強(qiáng)制內(nèi)核重新查找一次分區(qū)表
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/sda
brw-rw----. 1 root disk 8, ?1 Jun 25 01:58 /dev/sda1
brw-rw----. 1 root disk 8, ?2 Jun 25 ?2016 /dev/sda2
brw-rw----. 1 root disk 8, ?3 Jun 25 ?2016 /dev/sda3
brw-rw----. 1 root disk 8, 16 Jun 25 02:16 /dev/sdb
brw-rw----. 1 root disk 8, 17 Jun 25 02:16 /dev/sdb1
brw-rw----. 1 root disk 8, 18 Jun 25 02:16 /dev/sdb2
brw-rw----. 1 root disk 8, 21 Jun 25 02:16 /dev/sdb5
brw-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: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
28112 inodes, 112420 blocks
5621 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
14 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:?
? ? ? ? 8193, 24577, 40961, 57345, 73729
Writing inode tables: done ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. ?Use tune2fs -c or -i to override.
[root@zyl /]#?
[root@zyl /]# tune2fs -c -1 /dev/sdb1 ? ? ? ? ?#####調(diào)整和查看/dev/sdb1文件系統(tǒng)的參數(shù)
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to -1
[root@zyl /]# df -h
Filesystem ? ? ?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/sda
brw-rw----. 1 root disk 8, ?1 Jun 25 01:58 /dev/sda1
brw-rw----. 1 root disk 8, ?2 Jun 25 ?2016 /dev/sda2
brw-rw----. 1 root disk 8, ?3 Jun 25 ?2016 /dev/sda3
brw-rw----. 1 root disk 8, 16 Jun 25 02:24 /dev/sdb
brw-rw----. 1 root disk 8, 17 Jun 25 02:28 /dev/sdb1
brw-rw----. 1 root disk 8, 18 Jun 25 02:16 /dev/sdb2
brw-rw----. 1 root disk 8, 21 Jun 25 02:16 /dev/sdb5
brw-rw----. 1 root disk 8, 22 Jun 25 02:16 /dev/sdb6
[root@zyl /]# mount /dev/sd
sda ? sda1 ?sda2 ?sda3 ?sdb ? sdb1 ?sdb2 ?sdb5 ?sdb6 ?
[root@zyl /]# mount /dev/sdb1 /mnt
[root@zyl /]# touch /mnt/dddd
[root@zyl /]# df -h
Filesystem ? ? ?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/sdb
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
轉(zhuǎn)載于:https://blog.51cto.com/zhagyilig/1793063
總結(jié)
以上是生活随笔為你收集整理的Linux 磁盘分区 Fdisk的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: shell脚本实现动态时钟
- 下一篇: linux内核模块开发