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)這個大師寫的也很詳細了。可以一起參考

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