linux中增加硬盘,并格式化操作-(虚拟机Vmware中测试)

环境使用vmware的测试环境。

vmware工具下面增加应硬盘操作,简单操作,所需要的硬盘空间自己加,默认即可。

 

查看已经增加的新硬盘

fdisk /dev/sdb

(m进行操作)

输入n,p主分区,化到圆扇区到133,(4G总共522的扇区,每个1G都是133个扇区)

已经给磁盘划了主分区1,现在操作删除。(这里主要测试)

正常操作划分去(其实和windowns很像,主要是英文介绍。不懂就按M帮助操作即可)

Command (m for help): n     【选择分区】
Command action
   e   extended【扩展分区】
   p   primary partition (1-4)【主分区】
p【选择扇区类型】
Partition number (1-4): 1【选择分区号码】
First cylinder (1-522, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): 133【选择终止圆柱扇区】

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 1
Partition 1 is already defined.  Delete it before re-adding it.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (134-522, default 134):        
Using default value 134
Last cylinder, +cylinders or +size{K,M,G} (134-522, default 522): 266

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (134-266, default 134): 134
Last cylinder, +cylinders or +size{K,M,G} (134-266, default 266): 266

Command (m for help): n
Command action
   l   logical (5 or over)【选择逻辑分区】
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (267-522, default 267): 
Using default value 267
Last cylinder, +cylinders or +size{K,M,G} (267-522, default 522): 522

Command (m for help): w【写入分区】
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost dev]#

用mkfs.ext2指令格式化主分区;(或者mkfs.ext4也可以-通用,版本升级)

 

一共对序号1.5主分区格式化、扩展分区序号2,逻辑分区序号3进行格式化。

[root@localhost dev]# mkdir /tmp/sdb{1,2,3,5} (创建文档)

[root@localhost dev]# mount /dev/sdb1 /tmp/sdb1 (挂载主分区,以及其他分区)
[root@localhost dev]# mount /dev/sdb2 /tmp/sdb2
mount: you must specify the filesystem type (#这是为什么挂载不了,是因为挂载挂在扩展分区中逻辑分区,扩展分区符号不能加入,系统提示定义你的文件系统类型。)还去网上找点资料补充,说怎么老是挂载不了上。

[root@localhost dev]# mount /dev/sdb3 /tmp/sdb3/
[root@localhost dev]# mount /dev/sdb5 /tmp/sdb5/

[root@localhost dev]# fdisk -l (使用fdisk指令看分区划分情况。)

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x00039fd9

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        5222    41430016   8e  Linux LVM

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 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: 0x59949818

   Device Boot      Start         End      Blocks   Id  System (第二个硬盘分区情况)
/dev/sdb1               1         133     1068291   83  Linux
/dev/sdb2             134         266     1068322+   5  Extended
/dev/sdb3             267         522     2056320   83  Linux
/dev/sdb5             134         266     1068291   83  Linux

Disk /dev/mapper/VolGroup-LogVol01: 2000 MB, 2000683008 bytes
255 heads, 63 sectors/track, 243 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/mapper/VolGroup-LogVol00: 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/mapper/VolGroup-LogVol04: 8208 MB, 8208252928 bytes
255 heads, 63 sectors/track, 997 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/mapper/VolGroup-LogVol03: 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/mapper/VolGroup-LogVol02: 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

[root@localhost dev]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol00
                      9.8G  5.5G  3.8G  59% /
tmpfs                 495M   80K  495M   1% /dev/shm
/dev/sda1             477M   29M  424M   7% /boot
/dev/mapper/VolGroup-LogVol02
                      9.8G  713M  8.6G   8% /home
/dev/mapper/VolGroup-LogVol03
                      9.8G   23M  9.2G   1% /opt
/dev/mapper/VolGroup-LogVol04
                      7.4G   37M  7.0G   1% /tmp
/dev/sdb1             1.1G  1.3M  974M   1% /tmp/sdb1  (每个分区的磁盘空间大小,和使用情况。)
/dev/sdb3             1.9G  3.0M  1.8G   1% /tmp/sdb3
/dev/sdb5             995M  1.3M  942M   1% /tmp/sdb5
[root@localhost dev]# 

(参考帮助:https://blog.csdn.net/fanhuiren888/article/details/79291768)这个大师写的也很详细了。可以一起参考

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章