加入收藏 | 设为首页 | 会员中心 | 我要投稿 应用网_镇江站长网 (https://www.0511zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Linux系统磁盘的分区、格式化、检验与挂载 - Linux系统

发布时间:2014-06-01 23:38:12 所属栏目:Linux 来源:站长网
导读:磁盘分区 - fdisk fdisk的命令不需要记,因为输入m后,就会看到详细的帮助信息,如下所示: [root@lx15 /data ]# fdisk /dev/sda The number of cylinders for
磁盘分区 - fdisk

fdisk的命令不需要记,因为输入m后,就会看到详细的帮助信息,如下所示:

[root@lx15 /data ]# fdisk /dev/sda  
      
The number of cylinders for this disk is set to 36404.  
There is nothing wrong with that, but this is larger than 1024,  
and could in certain setups cause problems with:  
1) software that runs at boot time (e.g., old versions of LILO)  
2) booting and partitioning software from other OSs  
   (e.g., DOS FDISK, OS/2 FDISK)  
      
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  
   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  
   u   change display/entry units  
   v   verify the partition table  
   w   write table to disk and exit  
   x   extra functionality (experts only)

分区格式化 - mkfs

通过fdisk进行分区后,需要进行格式化后才能使用,分区格式化的命令很简单 :

mkfs [-t 文件系统格式] 设备文件名

下面是一个例子:

mkfs -t ext3 /dev/sda2

上诉例子表示以ext3格式化分区/dev/sda2

磁盘检验 - fsck

fsck [-t 文件系统格式] 设备文件名

ext2/ext3文件系统的最顶层会存在一个lost+found目录,该目录就是当你使用fsck检查后,若出现问 题,有问题的数据会被放置到该目录下,所以理想状态下该目录应该是空的。

磁盘的挂载 - mount

mount的命令很复杂,参数极多,但一般指需要使用默认就可以了,挂载命令 如下:

用默认方式将/dev/sda2挂载到目录/home上面

mkdir /home

mount /dev/sda2 /home

重新挂载命令如下:

将/home重新挂载,并加入参数rw与auto

mount -o remount,rw,auto /home

卸载命令是unmount,后面可以跟挂载点,也可以跟分区:

unmount /home

unmount /dev/sda2

设置开机挂载 - /etc/fstab

# cat /etc/fstab  
LABEL=/                 /                       ext3    defaults        1 1  
LABEL=/data             /data                   ext3    defaults        1 2  
LABEL=/var              /var                    ext3    defaults        1 2  
LABEL=/boot             /boot                   ext3    defaults        1 2  
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  
LABEL=SWAP-sda5         swap                    swap    defaults        0 0

当我们执行mount命令时,会将配置写入/etc/fstab中,下面是该文件每一列的意义:

第一列:磁 盘设备文件名或其LABEL

第二列:挂载点

第三列:文件系统类型

第四列:文件系统参数

第五 列:能否被dump(0表示不要,1表示每天要dump)

第六列:设置是否开机fsck(0表示不要,1表示最 早检验,2表示比1迟检验)

查看本栏目更多精彩内容:http://www.bianceng.cn/OS/Linux/

(编辑:应用网_镇江站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!