linux学习命令总结⑩②
#fdisk命令:磁盘分区工具
fdisk –l:查看机器所挂硬盘个数及分区情况
[root@VM_168_102_centos ~]# fdisk -l Disk /dev/xvda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 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: 0x70068116 Device Boot Start End Blocks Id System /dev/xvda1 * 1 1044 8385898+ 83 Linux Disk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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 Disk /dev/xvdc: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 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@VM_168_102_centos ~]# fdisk -l /dev/xvda Disk /dev/xvda: 8589 MB, 8589934592 bytes #该设备空间80G 255 heads, 63 sectors/track, 1044 cylinders #255个磁头;63个扇区;1044个柱面 Units = cylinders of 16065 * 512 = 8225280 bytes #每个柱面的大小约为8.225280M Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x70068116 Device#分区序列 Boot#引导 Start#开始柱面 End#结束柱面 Blocks#容量 Id#分区类型ID System#分区类型 /dev/xvda1 * 1 1044 8385898+ 83 Linux
通过fdisk分区工具,对指定挂载设备进行操作:
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xcc40c7dc. 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或者help进入帮助界面
进入到此界面我们可以输入m或者help来获取使用帮助
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 #输入d删除分区 l list known partition types #输入l列出内核支持的分区类型ID m print this menu n add a new partition #输入n新建分区 o create a new empty DOS partition table p print the partition table #输入p列出当前分区信息 q quit without saving changes #输入q不保存退出 s create a new empty Sun disklabel t change a partition‘s system id #输入t调整分区类型ID u change display/entry units v verify the partition table w write table to disk and exit #输入w保存退出 x extra functionality (experts only)
创建一个主分区
Command (m for help): p #列出当前分区信息 Disk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0xd0807ba8 Device Boot Start End Blocks Id System #当前无分区 Command (m for help): n #新建分区 Command action e extended #扩展分区(无法格式化) p primary partition (1-4) #主分区(最多四个) p #选择创建主分区 Partition number (1-4): 1 #创建第一个主分区 First cylinder (1-1305, default 1): #起始柱面(始终由1开始) Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 200 #结束柱面(每个柱面大小约8.22M,再乘以起始柱面到结束柱面的个数就等于该分区的大小;也可以自定大小如输入+1000M/+1G) Command (m for help): p #列出当前分区信息 Disk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0xd0807ba8 Device Boot Start End Blocks Id System /dev/xvdb1 1 200 1606468+ 83 Linux
创建一个扩展分区
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。