1、104391 83 Linux/dev/sda2 14 1305 10377990 8e Linux LVMid和System 表示的是一个意思,id看起来不太直观,我们要在fdisk一个分区时,通过指定id来确认分区类型;比如 7表示的就NTFS 分区;这个在fdisk中要通过t功能来指定。下面的部分会提到;Disk /dev/sdb: 21.4 GB,21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersDisk /dev/sdb doesnt contain a validpartition table说明:硬盘分区的表示
2、:在Linux 是通过hd*x 或sd*x 表示的:其中* 表示的是a、b、c . .另外x 表示的数字 1、2、3 . .hd大多是IDE硬盘;sd大多是SCSI或移动存储;引导(Boot):表示引导分区,在上面的例子中sda1 是引导分区;Start (开始):表示的一个分区从Xcylinder(磁柱)开始;End (结束):表示一个分区到Ycylinder(磁柱)结束;2、 学会使用fdisk帮助功能:rootjetsenLin# fdisk /dev/sdaThenumber of cylinders for this disk is set to 1305.There isnothi
3、ng wrong with that, but this is larger than 1024,andcouldin certain setups cause problems with:1) softwarethat 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)Command(m for help): m -输出帮助信息Commandactiona toggle a bootable f
4、lag -设置启动分区b edit bsddisklabel -编辑分区标签c toggle thedoscompatibility flagd 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 -创建一个新的空白DOS分区表p print the partition table -打印分区表q quit without saving c
5、hanges -退出不保存设置s createa new empty Sun disklabel -t changea partitions system id -改变分区的IDu changedisplay/entry units -改变显示的单位v verifythe partition table -检查验证分区表w write table to disk and exit -保存分区表x extra functionality (experts only)Command (m for help):3、 通过Fdisk对磁盘分区进行操作:Fdisk创建分区:rootjetsenLin #
6、fdisk /dev/sdbDevice contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes willremain in memory only,until you decide to write them. After that,of course, the previouscontent wont be recoverable.The number of cylinders for this disk isset to
7、2610.There is nothing wrong with that, but thisis larger than 1024,and could in certain setups cause problemswith:1) software that runs at boot time (e.g.,old versions of LILO)2) booting and partitioning software fromother OSsWarning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(ri
8、te) n -输入m会有帮助信息出来,输入n不打印帮助信息Command actione extendedprimary partition (1-4) -指定分区类型 e为扩展分区 p为主分区pPartition number (1-4): 1 -定义分区数量 -主分区最多只能有四个First cylinder (1-2610, default 1):-设定起始分区的位置Last cylinder or +size or +sizeM or +sizeK(1-2610, default 2610):Using default value 2610 -设定结束分区的位置 w -保存刚才的配置信
9、息。The partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.rootjetsenLin #Fdisk删除分区:rootjetsenLin # fdisk /dev/sdb d -d 是代表删除,并且会列出当前磁盘的分区数。Selected partition 1 p -p是代表删除后,显示磁盘还有几个剩余的分区。 21.4 GB, 21474836480 bytesSystem -已经没有分区了-保存刚才的操作并且生效WARNING: Re-reading the
10、 partition tablefailed with error 16: Device or resource busy. The kernel still uses the old table.The new table will be used at the nextreboot.这里报了一错误,分区表正在使用,删除再下次启动生效Syncing disks. -同步新的磁盘信息rootjetsenLin # fdisk -l /dev/sdb通过fdisk命令来创建一指定大小的分区并增加一个分区Fdisk n创建分区:rootjetsenLin # fdisk /dev/sdb-创建分区
11、-指定分区类型为主分区-指定其实分区号-指定起始柱面号 1024 -指定终止柱面号-保存分区配置信息 Device or resource busy.增加分区:-增加分区-分区类型-还是指定主分区-分区号,我指定1。Partition 1is already defined. Delete it beforere-adding it.提示分区号1已经存在,删除后操作-我们重新创建分区-指定分区类型 2 -因为分区1已经存在,所以我们指定分区2,可通过。First cylinder (1025-2610, default 1025):-指定起始礠柱号,默认是上一分区后一号。Using defau
12、lt value 1025Last cylinder or +size or +sizeM or +sizeK(1025-2610, default 2610): 2000 -指定终止礠柱号。-保存分区配置通过fdisk命令来来修改现有分区类型Fdisk通过t参数来指定查看分区类型rootjetsenLin # fdisk -l /dev/sdb 查看分区信息,类型是Linux,id是83/dev/sdb1 1024 8225248+ /dev/sdb2 1025 2000 7839720 修改分区类型 t -进入修改分区类型-指定需要修改的分区号Hex code (type L tolist
13、 codes): 6 -指定分区号为6,也就是FAT16注意:查看分区类型的代码,在这里可以输入L查看就可以了Changed system type of partition 1 to 6(FAT16)-保存 If you have created or modifiedany DOS 6.xpartitions, please see the fdiskmanualpage for additionalinformation.-我们看到已经FAT16,并且ID也改成6了。6 FAT164、 对分区进行格式化及加载:对分区进行格式化的命令如下等,mkfs后面所接的代表的是将要格式化成的文件系统类型:mkfs.bfs mkfs.ext2mkfs.ext3mkfs.jfsmkfs.msdosmkfs.vfatmkfs.cramfsmkfs.minixmkfs.reiserfsmkfs.xfs格式化分区:rootjetsenLin # mkfs.ext4 /dev/sdb1 -格式化分区类型为ext4mke4fs 1.41.5(23-Apr-2009)Filesystem label= -我们没有指定卷标,就没有OS type: Linux -操作系统类型Block size=4096 (log=2) -单个块的大小
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1