一、linux系统硬盘怎么格式化
LVM将一个或多个硬盘的分区在逻辑上集合,相当于一个大硬盘来使用,当硬盘的空间不够使用的时候,可以继续将其它的硬盘的分区加入其中,这样可以实现磁盘空间的动态管理,相对于普通的磁盘分区有很大的灵活性。那么你知道linux系统硬盘怎么格式化吗?我带来了linux系统硬盘格式化的具体操作过程,下面大家跟着我一起来学习一下吧。

先用fdisk分区,分区完成后再用mkfs格式化并创建文件系统,挂载,磁盘就能使用啦。
主分区表:64bytes,最多只能分四个主分区,每个主分区的记录(相关信息,比如分区大小,位置)在主分区表里占14bytes。
如果要建多于四个的分区,就要拿出一个主分区做为扩展分区,再在扩展分区里面进行其它的分区操作。在建扩展分区的时候会建立一张对应的扩展分区表,它记录了在这个扩展分区里的分区的相关信息;理论上它没有分区数量的限制,在扩展分区内部的分区叫做逻辑分区,如上图中的/dev/hda5,/dev/hda6/,/dev/hda7
在分好区后,分区里面是空的,没有任何东西。为了能让OS识别,就必须要向分区里写入相应格式的数据。比如windows的FAT32,NTFS;Linux的ext2,ext3,ext4(目前ext3格式的用的比较多,ext4还在实验之中,在新的Fedora上使用的就是ext4的文件系统)。
Windows/dos常用的分区工具:fdisk/partition magic/diskpart
fdisk/sfdisk:命令行工具,各种版本和环境都能使用,包含在软件包util-linux中
diskdruid:图形化分区工具,只能在安装REDHAT系统时使用。
环境/工具:Fedora 14/256M内存卡;fdisk
[root@novice~]# fdisk-l/dev/sdb
Disk/dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units= sectors of 1* 512= 512 bytes
Sector size(logical/physical): 512 bytes/ 512 bytes
I/O size(minimum/optimal): 512 bytes/ 512 bytes
Device Boot Start End Blocks Id System
[root@novice~]# fdisk/dev/sdb
Command(m for help):#在输入上面的命令后会出现左边的提示,输入m就会得到一个帮助菜单,如下:
c toggle the dos compatibility flag
o create a new empty DOS partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
w write table to disk and exit
x extra functionality(experts only)
#help虽然是英文的,可都很简单,在这里不再解释。
#现在,我们正式开始分区的操作:
Command(m for help): n#新建分区
#e/p分别对应扩展分区/主分区;我们先分四个主分区,每个50M;然后再来增加主分区或扩展分区,看会出现怎样的状况,嘿嘿。
Partition number(1-4, default 1): 1#分区号,在这里我们依次选择1、2、3、4
First sector(2048-496127, default 2048):#指定分区的起始扇区,一般默认,按enter键即可。
Last sector,+sectors or+size{K,M,G}(2048-496127, default 496127):+50M#指定分区的终止扇区,根据前面的提示我们可以做出相应的选择+sectors或+size{K,M,G}
Command(m for help): p#用p打印出已建好的分区列表
Disk/dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units= sectors of 1* 512= 512 bytes
Sector size(logical/physical): 512 bytes/ 512 bytes
I/O size(minimum/optimal): 512 bytes/ 512 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
Disk/dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units= sectors of 1* 512= 512 bytes
Sector size(logical/physical): 512 bytes/ 512 bytes
I/O size(minimum/optimal): 512 bytes/ 512 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 309298 25+ 83 Linux
#已经建好四个主分区啦,现在我们来看看如果再建主分区或是扩展分区的话会出现怎样的情况:
You must delete some partition and add an extended partition first
#看到了吧,不能再建分区啦!要再建分区的话必须删除some分区,再新建一个扩展分区才行。
#现在,我们删掉一个主分区,来新建扩展分区
Command(m for help): d#删除分区
Partition number(1-4): 4#选择要删除分区的分区号,我们选第四个
Command(m for help): p#打印,如下,四个分区变成了三个!
Disk/dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units= sectors of 1* 512= 512 bytes
Sector size(logical/physical): 512 bytes/ 512 bytes
I/O size(minimum/optimal): 512 bytes/ 512 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
#如果在没有建满三个主分的区的情况下建立扩展分区,相关选项会有些不同。
First sector(309248-496127, default 309248):#enter,默认
Last sector,+sectors or+size{K,M,G}(309248-496127, default 496127):#enter,默认,使用剩余空间
Disk/dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units= sectors of 1* 512= 512 bytes
Sector size(logical/physical): 512 bytes/ 512 bytes
I/O size(minimum/optimal): 512 bytes/ 512 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
#接下来,我们在新建的扩展分区里再新建两个逻辑分区,因为已经有了三个主分区,这里不会再显示是建立逻辑分区还是主分区的提示!
First sector(311296-496127, default 311296):#enter
Last sector,+sectors or+size{K,M,G}(311296-496127, default 496127):+50M
First sector(415744-496127, default 415744):#enter
Last sector,+sectors or+size{K,M,G}(415744-496127, default 496127):#enter
Disk/dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units= sectors of 1* 512= 512 bytes
Sector size(logical/physical): 512 bytes/ 512 bytes
I/O size(minimum/optimal): 512 bytes/ 512 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
/dev/sdb5 311296 413695 51200 83 Linux
/dev/sdb6 415744 496127 40192 83 Linux
#上面的列表,就是我们今天分区的成果啦!接下来保存退出,重启计算机,就可以进行下一步的mkfs操作啦!如果忘记了相关的操作命令,记得按m!!!
The partition table has been altered!
Calling ioctl() to re-read partition table.
另:在建好分区后,我们还可以更改相关分区的文件系统类型
#如,我们要把第二个主分区改成Linux下的交换分区,操作如下
Command(m for help): t#更改文件系统类型
Partition number(1-6): 2#选择第二个分区
Hex code(type L to list codes): L#选择要更改的文件系统编码,可以按L来查看相关编码信息。
0 Empty 24 NEC DOS 81 Minix/ old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap/ So c1 DRDOS/sec(FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec(FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec(FAT-
16 Hidden FAT16 64 Novell Netware af HFS/ HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST smartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
Hex code(type L to list codes): 82#查找到linux swap的编码为82
Changed system type of partition 2 to 82(Linux swap/ Solaris)
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 82 Linux swap/ Solaris
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
/dev/sdb5 311296 413695 51200 83 Linux
/dev/sdb6 415744 496127 40192 83 Linux
#最后别忘了保存!如果你须要的话!
#扩展分区不能直接使用,逻辑分区只能建立在扩展分区上!
第二步:mkfs(mkfs时分区的格式最好与fdisk设定的分区格式一致,不然.......)
mkfs支持ext2 ext3 vfa msdos jfs reiserfs等文件系统。
#更多更具体的用法请参照相关命令的man手册
[root@novice~]# mkfs-t ext3/dev/sdb1
Stride=0 blocks, Stripe width=0 blocks
2560 blocks(5.00%) reserved for the super user
Maximum filesystem blocks=52428800
8192 blocks per group, 8192 fragments per group
Superblock backups stored on blocks:
Creating journal(4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs-c or-i to override.
[root@novice~]# fdisk/dev/sdb
Hex code(type L to list codes): L
0 Empty 24 NEC DOS 81 Minix/ old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap/ So c1 DRDOS/sec(FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec(FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec(FAT-
4 FAT16<32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FS data
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M/ CTOS/.
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
Hex code(type L to list codes): 7
Changed system type of partition 6 to 7(HPFS/NTFS)
Disk/dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units= sectors of 1* 512= 512 bytes
Sector size(logical/physical): 512 bytes/ 512 bytes
I/O size(minimum/optimal): 512 bytes/ 512 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 82 Linux swap/ Solaris
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
/dev/sdb5 311296 413695 51200 83 Linux
/dev/sdb6 415744 496127 40192 7 HPFS/NTFS
The partition table has been altered!
Calling ioctl() to re-read partition table.
[root@novice~]# mkfs.ntfs/dev/sdb6
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes: 100%- Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
二、linux系统上如何格式化硬盘
1、点击电脑左下角的箭头位置标志,然后选择启动终端。不同的桌面环境方法进入终端不太一样,这个根据自己使用的桌面而定。
2、在终端上面输入命令:sudo fdisk-l回车。
3、然后找到/dev/sda/dev/sdb这样子的英文。这里电脑上面的硬盘,其中sda则是第一个硬盘,sdb是第二个硬盘。
4、在终端输入命令:图片里面的命令回车。
5、其中sudo mkfs-t理解为固定格式即可,ntfs则是格式化的类型U盘可以改成fat32后面的/dev/sdb1格式化的分区。如果直接写入sdb则会出错,无法格式化整个硬盘,只能够格式化分区。
6、上面的命令回车后,会看到图一的百分比,等到百分百就可以。最后成功后会显示completed successfully,证明成功格式化。
7、挂载分区:格式化后的分区需要查看写入文件的话还需要进行挂载。在终端输入命令:图片里面的命令
8、回车没有报错则为挂载成功,其中sdb1就是你所需挂载的分区。
9、输入命令:df-h可以看到分区的容量大小等信息。
10、写入文件到硬盘:挂载成功后点击左下角的符号,然后点击文件管理器,在图二看到已经多了一个5g的硬盘,就是上面挂载的硬盘,要存入文件数据的话直接复制到里面即可。而红圈则代表它挂载的正是mnt目录,进入这个目录等于访问这个硬盘。
三、linux 强制硬盘格式化
1.找到“我的电脑”然后右键打开,或者双击打开也可以,
2.在硬盘格式化之前先把里边的资料进行备份,然后找到需要格式化的硬盘。
3.在磁盘符号位置右键弹出格式化命令,
4.格式化操作可以查看可用来格式化的空间,设置磁盘格式,
5.然后设置分配单元大小。详细的介绍可看书籍《Linux就该这么学》。
关于本次linux格式化硬盘和linux格式化硬盘命令mkfs的问题分享到这里就结束了,如果解决了您的问题,我们非常高兴。









