您的位置:首页 > 其它

管理系统中的简单分区和文件系统

2017-04-26 17:21 525 查看
管理系统中的简单分区和文件系统

=========一.查看系统设备信息==========

#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 ##退出不保
4000


   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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: