管理系統中的簡單分區和文件系統

管理系統中的簡單分區和文件系統


=========一.查看系統設備信息==========
#fdisk -l ##顯示系統中所有可以使用的設備信息
#blkid ##顯示系統正在使用的設備id(顯示的是可用的)


=========二.創建新分區===========
1.
#fdisk /dev/vdb


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
   t   change a partition's system id ##修改分區功能id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit ##保存更改到分區表中
   x   extra functionality (experts only)


注意:出現這個情況怎麼辦(顯示磁盤沒有分區,但是不能對它進行分區)
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 
First sector (2048-20971519, default 2048): +1G
Last sector, +sectors or +size{K,M,G} (2097152-20971519, default 20971519): ^C
[root@localhost ~]# fdisk -l


Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 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: 0x00013f3e


   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    20970332    10484142+  83  Linux


Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 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


##用文件劃分磁盤的方法


2.
分區後要進行
#partprobe
#cat /proc/partitions可以查看分區情況
示例如下:
------------------------------------------------------------------
[root@station ~]# fdisk -l


Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 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: 0x00013f3e


   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    20970332    10484142+  83  Linux


Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 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: 0x2096d4d2


   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     2099199     1048576   83  Linux
/dev/vdb2         2099200     4196351     1048576   83  Linux
/dev/vdb3         4196352     6293503     1048576   83  Linux
/dev/vdb4         6293504     7317503      512000    5  Extended
/dev/vdb5         6295552     6500351      102400   83  Linux
/dev/vdb6         6502400     7317503      407552   83  Linux
[root@station ~]# cat /proc/partitions 
major minor  #blocks  name


 253        0   10485760 vda
 253        1   10484142 vda1
 253       16   10485760 vdb
 253       17    1048576 vdb1
 253       18    1048576 vdb2
 253       19    1048576 vdb3
 253       20          1 vdb4
 253       21     102400 vdb5
 253       22     407552 vdb6
--------------------------------------------------------------------


=========三.系統文件的創建===========
1.文件系統比較
Windows下:
ntfs;fat(可用於linux)
Linux下:
ext4;(分佈式讀取)是 Red Hat Enterprise Linux 6 的標準文件系統。它非常強大可靠 , 具有多項可以提高現代工作量處理性能的功能
ext2;(分佈式讀取)是常用於 Linux 中的較舊的文件系統。它簡單可靠 , 非常適合小型存儲設備 , 但是效率低於 ext
vfat;(鏈式讀取)支持包括一系列相關文件系統 ( VFAT/FAT16 和FAT32 ), 這些文件系統針對較舊版本的 Microsoft Windows開發 , 在大量的系統和設備上受支持
xfs;(讀取速度快)在 Red Hat Enterprise Linux 7 的標準文件系統其具備數據完全性 、性能穩定、擴展性強( 18eb )、傳輸速率高( 7G+/s )


2.文件系統創建示例:
[root@station ~]# history
    1  cat /proc/partitions 
    2  blkid    ##查看當前可用的設備
    3  mkfs.xfs /dev/vdb2 ##格式化文件系統
    4  blkid ##查看當前可用的設備(/dev/vdb2也可以使用了)
    5  mount /dev/vdb2 /mnt ##一次性的掛載,關機會失效
    6  df
    7  umount /mnt/ ##取消掛載
    8  df
    9  vim /etc/fstab ##開機自動掛載(上次做的那/etc/rc.d/rc.local是系統最後才掃描的)
   10  mount -a ##重新加載上面的文件,使新增內容生效

   11  df ##查看掛載情況



--------------------------------------------------------------------------
[root@station ~]# cat /proc/partitions 
major minor  #blocks  name


 253        0   10485760 vda
 253        1   10484142 vda1
 253       16   10485760 vdb
 253       17    1048576 vdb1
 253       18    1048576 vdb2
[root@station ~]# blkid
/dev/vda1: UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" TYPE="xfs" 
[root@station ~]# mkfs.xfs /dev/vdb2
meta-data=/dev/vdb2              isize=256    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@station ~]# blkid
/dev/vda1: UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" TYPE="xfs" 
/dev/vdb2: UUID="45f7eda1-3bfb-47f2-b73c-218db2d0de88" TYPE="xfs" 
[root@station ~]# mount /dev/vdb2 /mnt
[root@station ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       10473900 3207152   7266748  31% /
devtmpfs          927072       0    927072   0% /dev
tmpfs             942660      84    942576   1% /dev/shm
tmpfs             942660     676    941984   1% /run
tmpfs             942660       0    942660   0% /sys/fs/cgroup
/dev/vdb2        1038336   32928   1005408   4% /mnt
[root@station ~]# umount /mnt/
[root@station ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       10473900 3207152   7266748  31% /
devtmpfs          927072       0    927072   0% /dev
tmpfs             942660      84    942576   1% /dev/shm
tmpfs             942660     676    941984   1% /run
tmpfs             942660       0    942660   0% /sys/fs/cgroup
[root@station ~]# vim /etc/fstab
[root@station ~]# mount -a
[root@station ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       10473900 3207156   7266744  31% /
devtmpfs          927072       0    927072   0% /dev
tmpfs             942660      84    942576   1% /dev/shm
tmpfs             942660     676    941984   1% /run
tmpfs             942660       0    942660   0% /sys/fs/cgroup
/dev/vdb2        1038336   32928   1005408   4% /mnt
---------------------------------------------------------------------------

還原設置:
[root@localhost ~]# history
    2  df     ##查看設備掛載情況
    3  umount /mnt ##取消掛載
    4  vim /etc/fstab ##打開你編寫的那個文件,把自己寫的那行刪除
    5  fdisk /dev/vdb ##刪除分區
    6  partprobe
    7  df
    8  fdisk -l

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