Linux新增磁盤分區

磁盤的分區

       主分區與擴展分區最多可以有4個(分區表64字節,每分區占16字節);

       擴展分區最多只能有一個;

       邏輯分區是由擴展分區持續分出來的分區;

       能夠被格式化后作為數據訪問的分區為主要分區與邏輯分區,擴展分區無法格式化;

       邏輯分區的數量以操作系統而不同,在Linux系統中,IDE硬盤最多有59個邏輯分區(5-63),SATA硬盤則有11個邏輯分區(5-15);

各接口的磁盤在Linux中的文件名分別為

       /dev/sd[a-p][1-15]:為SCSI,SATA,USB,Flash等接口的磁盤文件名;

      /dev/hd[a-d][1-63]:為IDE接口的磁盤文件名;

文件系統分類

       Windows :NTFS、FAT32

       Linux:ext2、ext3、ext4xfs、reiserfs、nfs、iso9660jfs、brtfs


 小結:通過以上內容,我們簡單了解了磁盤的組成、分區、接口的磁盤命名及文件系統的分類。下面我們來具體看下磁盤分區、格式化及磁盤掛載所使用到的命令。


[root@ti0203a400-1401 /]# fdisk -l              //查看磁盤


Disk /dev/sda: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 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: 0x000152be


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26        5125    40960000   83  Linux

/dev/sda3            5125        5380     2048000   82  Linux swap / Solaris


[root@ti0203a400-1401 /]# fdisk /dev/sda                    //開始創建磁盤分區


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): p                   //顯示分區表


Disk /dev/sda: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 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: 0x000152be


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26        5125    40960000   83  Linux

/dev/sda3            5125        5380     2048000   82  Linux swap / Solaris


Command (m for help): n                        //新建一個分區

Command action

   e   extended

   p   primary partition (1-4)

p                                                        //創建主分區

Selected partition 4                         //分區號

First cylinder (5380-6527, default 5380):                //(開始柱面-可默認)                 

Using default value 5380

Last cylinder, +cylinders or +size{K,M,G} (5380-6527, default 6527): +5G                   //磁盤大小


Command (m for help): p                       //顯示分區表


Disk /dev/sda: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 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: 0x000152be


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26        5125    40960000   83  Linux

/dev/sda3            5125        5380     2048000   82  Linux swap / Solaris

/dev/sda4            5380        6033     5246248+  83  Linux


Command (m for help): w                       //保存退出

The partition table has been altered!


Calling ioctl() to re-read partition table.


WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

[root@ti0203a400-1401 /]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda2        39G  3.3G   34G   9% /

tmpfs           491M   92K  491M   1% /dev/shm

/dev/sda1       190M   55M  126M  31% /boot

[root@ti0203a400-1401 /]# cat /proc/partitions            //查看分區表是否加載

major minor  #blocks  name


   8        0   52428800 sda

   8        1     204800 sda1

   8        2   40960000 sda2

   8        3    2048000 sda3

   8        4    5246248 sda4                                             //如果沒有加載就執行下面指令重新讀取加載

[root@ti0203a400-1401 /]# partx -a /dev/sda          // RHEL6讓內核重新讀取硬盤分區表:

BLKPG: Device or resource busy

error adding partition 1

BLKPG: Device or resource busy

error adding partition 2

BLKPG: Device or resource busy

error adding partition 3

BLKPG: Device or resource busy

error adding partition 4

[root@ti0203a400-1401 /]# mkfs -t ext4 /dev/sda4              //格式化新建磁盤

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

328000 inodes, 1311562 blocks

65578 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1346371584

41 block groups

32768 blocks per group, 32768 fragments per group

8000 inodes per group

Superblock backups stored on blocks: 

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


Writing inode tables: done                            

Creating journal (32768 blocks): 

done

Writing superblocks and filesystem accounting information: 

done


This filesystem will be automatically checked every 20 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@ti0203a400-1401 /]# 

[root@ti0203a400-1401 /]# mkdir -p /testdir                                             //創建磁盤掛載目錄

[root@ti0203a400-1401 /]# mount -t ext4  /dev/sda4 /testdir/                 //掛載磁盤

[root@ti0203a400-1401 /]# df -h                                                               //查看磁盤是否識別并掛載

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda2        39G  3.3G   34G   9% /

tmpfs           491M   92K  491M   1% /dev/shm

/dev/sda1       190M   55M  126M  31% /boot

/dev/sda4       4.8G   11M  4.6G   1% /testdir

[root@ti0203a400-1401 /]# ls /testdir/

lost+found

[root@ti0203a400-1401 /]# 






轉載:

http://miclesvic.blog.51cto.com/2152735/1344202











原創文章,作者:jxmsn,如若轉載,請注明出處:http://www.www58058.com/16100

(0)
jxmsnjxmsn
上一篇 2016-05-29
下一篇 2016-05-30

相關推薦

  • 文本處理三兄弟(grep,sed,awk)

    linux文本處理三劍客: grep:文本過濾工具 grep  egrep=grep -e  fgrep sed:流編輯器  處理多個行  awk:文本編輯工具,格式化工具 grep [OPTIONS] PATTERN [FILE…] : 文本處理搜索工具,根據用戶指定的“模式”對目標文本進行匹配檢查;打印匹…

    Linux干貨 2017-04-01
  • Linux終端類型介紹

    相關命令:tty 適合閱讀人群:所有   終端機 終端(Computer terminal),是一臺電子計算機或者計算機系統,用來讓用戶輸入數據,及顯示其計算結果的機器。又名終端機,它與一部獨立的電腦不同,其實就是一種輸入輸出設備,一臺電腦多人使用,每增加一個用戶只須增加一臺顯示器和一套鍵盤鼠標就可以成為一個獨立的終端,多用戶可同時使用互相獨立,跟…

    Linux干貨 2016-10-14
  • 倒排索引-搜索引擎的基石

    1.概述       在關系數據庫系統里,索引是檢索數據最有效率的方式,。但對于搜索引起,他它并不能滿足其特殊要求:       1)海量數據:搜索引擎面對的是海量數據,像Google,百度這樣大型的商業搜索引擎索引都是億級甚至幾千的網頁數量 ,面對…

    Linux干貨 2015-12-10
  • 第七周學習總結–系統啟動流程

    寫在前面 作為一個理工科的你,我相信你一定給自己或者給別人裝過windows操作系統,作為windows操作系統都圖形化了,因此我們可能很難去了解中間都發生了什么。比如使用U盤安裝的時候,網上一大堆某某某U盤制作系統工具,按照網上的教程,制作完成以后,就可以在要裝系統的電腦上點擊電源鍵狂按F12(不同的電腦可能不同)進入BIOS設置了,然后就等著使用了。作為…

    2018-01-14
  • rpm 詳解

     rpm 包詳解 程序包的命名格式:name-VERSION.tar.gz 拆包:主包和分包 主包:name-VERSION-release.arch.rpm 支包:name-function-VERSION-release.arch.rpm   注意:程序包之間有時會存在依賴關系,依靠前端工具解決依賴關系 yum Rhel系列系統上的r…

    Linux干貨 2017-08-17
欧美性久久久久