Win 7系统 Win10系统 XP系统 系统故障 系统安装
您的位置: 首页 > 故障 > linux

Linux系统添加新硬盘分区及设置启动自动挂载教程

日期: 2015-04-14   浏览: 459

  在不同的操作系统下添加新硬盘及分区方法也有些不同,Linux与windows系统对比会有些复杂,那么在Linux系统如何添加新硬盘和硬盘分区及硬盘设置驱动自动挂载呢?如果你想要在Linux系统下新添加硬盘的话,本文教程不可错过哦。

  Linux系统添加新硬盘分区及设置启动自动挂载方法/步骤

  1、检查发现系统上目前并没有挂载新的硬盘,如下图所示:

  

Linux系统添加新硬盘分区及设置启动自动挂载教程

 

  2、添加硬盘后我们启动电脑并再次检查,我们可以看到最下面多了一行“Disk /dev/sdb doesn't contain a valid partition table”,告诉我们有一块新的硬盘,但是还没有分区;如下图所示:

  

Linux系统添加新硬盘分区及设置启动自动挂载教程

 

  3、根据以上提示开始对新的硬盘进行分区操作,由于截图比较麻烦所以呢我把命里copy出来了,需要操作的部分我会标记出来

  [root@Linux ~]# fdisk /dev/sdb //根据提示,对新硬盘进行分区操作Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes will remain in memory only,until you decide to write them. After that, of course, the previouscontent won't be recoverable.The number of cylinders for this disk is set to 2610.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)Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

  Command (m for help): h //帮助信息h: unknown commandCommand 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)

  Command (m for help): n //输入 n,新建分区Command action e extended //新建逻辑分区 p primary partition (1-4) //新建主分区p //输入 p,建立主分区Partition number (1-4): 1 //一共可以分4个主分区,输入 1,建立第一个主分区First cylinder (1-2610, default 1): //选择该分区的起始磁盘数,如无特殊需求强烈建议选择默认,也就是默认用1 来分区(直接按回车)Using default value 1Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): //定义该分区的大小,如果按默认(直接回车),就是使用全部可用存储空间;如果要分成一个 1G 的空间,输入 +1024m 即可,1G=1024m算法以此类推Using default value 2610Command (m for help): w //写入分区信息,其实就是保存分区信息The partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.

  4、完成以上操作后我们可以看到新添加的硬盘已经存在分区了

  

Linux系统添加新硬盘分区及设置启动自动挂载教程

 

  5、下面对分区进行格式化操作:

  [root@Linux ~]# mkfs -t ext3 -c /dev/sdb1 //对分区使用 ext3 格式化,如果建立了多个分区,显示 /dev/sdb2、/dev/sdb3 等,以此类推,重复输入这条命令,就可以进行其它分区的格式化操作了。因为新硬盘加了-c参数,要先检测磁盘坏道,因此,这个过程全有些长,需要耐心等待……注意这里的时间长短时根据你的硬盘大小来实现的,如果硬盘大时间就会久一些,否则就会小短一些mke2fs 1.39 (29-May-2006)

  Filesystem label=

  OS type: Linux

  Block size=4096 (log=2)Fragment size=4096 (log=2)1310720 inodes, 5241198 blocks131029 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=0160 block groups32768 blocks per group, 32768 fragments per group16384 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632Checking for bad blocks (read-only test): done Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 32 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.

  6、开始对分区进行挂载使用,首先创建一个用于挂载的目录

  

Linux下添加新硬盘,分区并设置启动自动挂载

 

  7、将分区挂载到www目录下

  

Linux下添加新硬盘,分区并设置启动自动挂载

 

  8、输入vim /etc/fstab进行编辑,并在该文件内输入以下内容,然后在:wq保存并退出,重启验证即可

  

Linux系统添加新硬盘分区及设置启动自动挂载教程

 

  虽然在Linux系统下新添加硬盘和硬盘分区设置启动自动挂载会比较繁琐,但不是很复杂,也是极其简单的,用户可以按照教程的方法来操作。

相关资讯:
精彩专题:
最新应用:
最新系统下载: