linux下磁盘格式化操作

zhangchunyan@zhangchunyan-desktop:~$ ls /dev/sd
sda    sda1  sda2  sda5  sda6  sdb   
zhangchunyan@zhangchunyan-desktop:~$ fdisk -l
zhangchunyan@zhangchunyan-desktop:~$ sudo fdisk -l
[sudo] password for zhangchunyan:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0x00079de5

    Device Boot          Start                End          Blocks    Id  System
/dev/sda1                                  6079      48829536    83  Linux
/dev/sda2                      6080            30880    199214032+    Extended
/dev/sda5                      6080            30394    195310206    83  Linux
/dev/sda6                    30395            30880        3903763+  82  Linux swap / Solaris

Disk /dev/sdb: 3904 MB, 3904897024 bytes
121 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 7502 * 512 = 3841024 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006bcd8

   Device Boot      Start         End      Blocks   Id  System

注释:fdisk是linux磁盘分区管理命令
使用方法:

      一、在 console 上输入 fdisk -l /dev/sda ,观察硬盘之实体使用情形。

      二、在 console 上输入 fdisk /dev/sda,可进入分割硬盘模式。

        1. 输入 m 显示所有命令列示。

        2. 输入 p 显示硬盘分割情形。

        3. 输入 a 设定硬盘启动区。

        4. 输入 n 设定新的硬盘分割区。

         4.1. 输入 e 硬盘为[延伸]分割区(extend)。

         4.2. 输入 p 硬盘为[主要]分割区(primary)。

        5. 输入 t 改变硬盘分割区属性。

        6. 输入 d 删除硬盘分割区属性。

        7. 输入 q 结束不存入硬盘分割区属性。

        8. 输入 w 结束并写入硬盘分割区属性


zhangchunyan@zhangchunyan-desktop:~$ sudo fdisk /dev/sdb

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
Command action
      toggle a bootable flag
      edit bsd disklabel
      toggle the dos compatibility flag
      delete a partition
      list known partition types
      print this menu
      add a new partition
      create a new empty DOS partition table
      print the partition table
      quit without saving changes
      create a new empty Sun disklabel
      change a partition's system id
      change display/entry units
      verify the partition table
      write table to disk and exit
      extra functionality (experts only)

Command (m for help): n
Command action
      extended
      primary partition (1-4)
1
Invalid partition number for type `1'
Command action
      extended
      primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1016, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1016, default 1016):
Using default value 1016

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
注释:mkfs,linux格式化文件系统命令(make file system)
使用方式 : mkfs [-V] [-t fstype] [fs-options] filesys [blocks] [-L Lable]
  说明 : 建立 linux 档案系统在特定的 partition 上
  参数 :
  device : 预备检查的硬盘 partition,例如:/dev/sda1
  -V : 详细显示模式
  -t : 给定档案系统的型式,Linux 的预设值为ext2
  -c : 在制做档案系统前,检查该partition 是否有坏轨
  -l bad_blocks_file : 将有坏轨的block资料加到 bad_blocks_file 里面
  block : 给定 block 的大小
  -L:建立lable
 
        补充说明:
        mkfs本身并不执行建立文件系统的工作,而是去调用相关的程序来执行。例如,若在"-t" 参数中指定ext2,则mkfs会调用mke2fs来建立文件系统.使用时如省略指定【块数】参数,mkfs会自动设置     适当的块数.

mkfs的使用示例
[root@localhost beinan]# mkfs -t 文件系统   存储设备
文件系统: ext3 ;reiserfs ;ext2 ;fat32 ;msdos 等... ...



zhangchunyan@zhangchunyan-desktop:~$ sudo mkfs
mkfs                  mkfs.ext2        mkfs.ext4dev  mkfs.ntfs       
mkfs.bfs          mkfs.ext3        mkfs.minix      mkfs.vfat       
mkfs.cramfs    mkfs.ext4        mkfs.msdos     
zhangchunyan@zhangchunyan-desktop:~$ sudo mkfs.ntfs /dev/sdb1
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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值