2018年11月24日 硬盘格式化

   [root@localhost ~]# ls -l /dev/sd* 查看/dev目录下的sd目录

brw-rw----. 1 root disk 8,  0 Nov 26  2018 /dev/sda

brw-rw----. 1 root disk 8,  1 Nov 26  2018 /dev/sda1

brw-rw----. 1 root disk 8,  2 Nov 26  2018 /dev/sda2

brw-rw----. 1 root disk 8, 16 Nov 26  2018 /dev/sdb 新增的sdb硬盘

[root@localhost ~]# fdisk /dev/sdb  sdb 硬盘分区

Welcome to fdisk (util-linux 2.23.2).

 

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

 

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x5520890d.

 

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 删除分区

   g   create a new empty GPT partition table

   G   create an IRIX (SGI) partition table

   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

Command (m for help): p         详细分区信息

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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

Disk label type: dos

Disk identifier: 0x5520890d

Device Boot Start End Blocks Id System

Command (m for help): n        创建新的分区方式

Partition type:

   p   primary (0 primary, 0 extended, 4 free)  主分区

   e   extended                       扩展分区

Select (default p): p                      选择主分区

Partition number (1-4, default 1): 1           选择主分区编号

First sector (2048-41943039, default 2048):     选择开始扇区字节,直接回车.

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +5G  选择结束字节 用+5G 来表示

Partition 1 of type Linux and of size 5 GiB is set

 

Command (m for help): p       查看分区情况

 

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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

Disk label type: dos

Disk identifier: 0x5520890d

Device Boot  Start End  Blocks  Id System

/dev/sdb1 2048 10487807 5242880 83  Linux   已创建的信息

 

Command (m for help): w            保存并推出

The partition table has been altered!

Calling ioctl() to re-read partition table.    提示成功

Syncing disks.

[root@localhost ~]# ls -l /dev/sd*        再用通配符查看一下设备列表

brw-rw----. 1 root disk 8,  0 Nov 26  2018 /dev/sda

brw-rw----. 1 root disk 8,  1 Nov 26  2018 /dev/sda1

brw-rw----. 1 root disk 8,  2 Nov 26  2018 /dev/sda2

brw-rw----. 1 root disk 8, 16 Nov 26 15:36 /dev/sdb

brw-rw----. 1 root disk 8, 17 Nov 26 15:36 /dev/sdb1

[root@localhost ~]# mkfs. +tab  查看一下格式化分类

mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.minix mkfs.vfat

mkfs.cramfs mkfs.ext3 mkfs.fat mkfs.msdos mkfs.xfs

[root@localhost ~]# mkfs.ext4 /dev/sdb1  将sdb1 分区格式化为ext4格式

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

327680 inodes, 1310720 blocks

65536 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1342177280

40 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

   32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                           

Writing inode tables: done                            

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

[root@localhost ~]# mkdir /xiaodou  在根目录创建挂载点

[root@localhost ~]# mount /dev/sdb1 /xiaodou 将sdb1分区挂载到 /xiaodou挂载点上

[root@localhost ~]# df –h   查看挂载详情

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/rhel-root 18G 2.9G 15G 17% /

devtmpfs  985M  0  985M  0% /dev

tmpfs  994M  140K  994M   1% /dev/shm

tmpfs  994M  8.9M  986M   1% /run

tmpfs  994M     0  994M   0% /sys/fs/cgroup

/dev/sda1  497M  119M  379M  24% /boot

/dev/sr0 3.5G  3.5G  0 100% /run/media/root/RHEL-7.0 Server.x86_64

/dev/sdb1  4.8G   20M  4.6G   1% /xiaodou

[root@localhost ~]# vim /etc/fstab  要想让挂载点永久生效要编辑/etc/fstab目录 ,编辑内容:/dev/sbd1 /xiaodou ext4 defaults 0 0

[root@localhost ~]# reboot   重启生效

 

posted @ 2018-11-30 15:29  leoxcj  阅读(136)  评论(0编辑  收藏  举报