Linux添加新硬盤,fdisk新建分區

fdisk新建分區:

[root@localhost ~]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x000e7df7
 
  Device Boot      Start         End      Blocks  Id  System
/dev/sda1  *           1         511    4096000   83  Linux
Partition 1 does not end on cylinderboundary.
/dev/sda2             511        1020    4096000   83  Linux
Partition 2 does not end on cylinderboundary.
/dev/sda3            1020        1275    2048000   82  Linux swap / Solaris
/dev/sda4            1275        2611   10730496    5  Extended
/dev/sda5            1276        2611   10729472   83  Linux
 
Disk /dev/sdb: 21.5GB, 21474836480 bytes
255 heads, 63sectors/track, 2610 cylinders
Units = cylinders of16065 * 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 ~]# fdisk /dev/sdb 開始分區
Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with diskidentifier 0x6811b6b9.
Changes will remain in memory only, untilyou decide to write them.
After that, of course, the previous contentwon't be recoverable.
 
Warning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(rite)
 
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
  a   toggle a bootable flag
  b   edit bsd disklabel
  c   toggle the dos compatibilityflag
  d   delete a partition
  l   list known partition types
  m   print this menu
   n   add a new partition #添加一個新分區
  o   create a new empty DOSpartition table
   p   print the partition table #查看當前分區情況
  q   quit without saving changes
  s   create a new empty Sundisklabel
  t   change a partition's system id
  u   change display/entry units
  v   verify the partition table
  w   write table to disk and exit
  x   extra functionality (expertsonly)
 
Command (m for help): n #添加一個新分區
Command action
  e   extended
  p   primary partition (1-4)
p #主分區
Partition number (1-4): 1 #分區號
First cylinder (1-2610, default 1): 1 #柱面
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +4G #分配大小(不以柱面方式)
 
Command (m for help): p #查看一下
 
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x6811b6b9
 
  Device Boot      Start         End      Blocks  Id  System
/dev/sdb1               1         523    4200966   83  Linux成功!
 
Command (m for help): n #繼續添加分區
Command action
  e   extended
  p   primary partition (1-4)
e #擴展分區
Partition number (1-4): 2 #分區號
First cylinder (524-2610, default 524): #默認起始柱面-回車
Using default value 524
Last cylinder, +cylinders or +size{K,M,G}(524-2610, default 2610): #默認結束柱面-回車
Using default value 2610
 
Command (m for help): p #查看一下
 
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x6811b6b9
 
  Device Boot      Start         End      Blocks  Id  System
/dev/sdb1               1         523    4200966   83  Linux
/dev/sdb2             524        2610   16763827+   5  Extended #擴展分區成功!
 
Command (m for help): n #繼續分邏輯分區
Command action
  l   logical (5 or over)
  p   primary partition (1-4)
l #選邏輯分區
First cylinder (524-2610, default 524): #默認起始柱面-回車
Using default value 524
Last cylinder, +cylinders or +size{K,M,G}(524-2610, default 2610): #默認結束柱面-回車
Using default value 2610
 
Command (m for help): p #查看一下
 
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x6811b6b9
 
  Device Boot      Start         End      Blocks  Id  System
/dev/sdb1               1         523    4200966   83  Linux
/dev/sdb2             524        2610   16763827+   5  Extended
/dev/sdb5             524        2610   16763796   83  Linux #成功!
 
Command (m for help): w #保存
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe #重新讀取分區表信息
[root@localhost ~]# mkfs -t ext4 /dev/sdb1 #格式化
[root@localhost ~]# mkdir /disk1 /disk5 #創建兩個掛載點
[root@localhost ~]# mount /dev/sdb1 /disk1 #掛載
[root@localhost ~]# mount /dev/sdb5 /disk5 #掛載


開機自動掛載:

[root@localhost ~]# dumpe2fs /dev/sdb1 #查看分區UUID
dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          968fc705-506d-4977-a469-32be93467a97
[root@localhost ~]# dumpe2fs /dev/sdb5 |more
dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          987dd564-5d12-4d0b-9706-c5bdf860e927
#
# /etc/fstab
# Created by anaconda on Wed Jan  6 23:44:24 2016
#
# Accessible filesystems, by reference, aremaintained under '/dev/disk'
# See man pages fstab(5), findfs(8),mount(8) and/or blkid(8) for more info
[root@localhost ~]# vim /etc/fstab
#
UUID=b943e84c-2d74-4098-85ed-096353ff1815/             ext4   defaults        1 1
UUID=4f4b30ad-e3e4-45c3-bb60-6f6c0dd8cd62/boot         ext4    defaults        1 2
UUID=41c2e8a6-10f0-4a10-b1a8-fe8db32ce708/home         ext4   defaults        1 2
UUID=289dd6bc-687b-48e9-9d10-e34aa360228fswap         swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID=968fc705-506d-4977-a469-32be93467a97/disk1        ext4    defaults        12
/dev/sdb5               /disk5                        ext4    defaults        1 2
[root@localhost ~]# mount –a #測試一下,所有分區按照配置文件/etc/fstab 重新掛載一次
/etc/fstab

文件錯誤時修復:

[root@localhost ~]# mount -o remount,rw / #重新將/掛載成讀寫權限,只用於
/etc/fstab
文件錯誤修復時。





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