一.磁盘分区

装过系统后第一块磁盘的设备号是/dev/sda,在你添加一个新的磁盘后一般情况下是/dev/sdb

*******进入fdisk界面*****

# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa64fcc39.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 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').
*****p参数显示磁盘分区信息*****
Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa64fcc39

Device Boot      Start         End      Blocks   Id  System
*****n参数创建分区******

创建主分区
Command (m for help): n
Command action
   e   extended                                     //扩展分区
   p   primary partition (1-4)                 //主分区
p
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): +1G

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa64fcc39

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         132     1060258+  83  Linux

*****创建扩展分区******

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 4
First cylinder (133-652, default 133):
Using default value 133
Last cylinder, +cylinders or +size{K,M,G} (133-652, default 652):
Using default value 652

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa64fcc39

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         132     1060258+  83  Linux
/dev/sdb4             133         652     4176900    5  Extended
*****创建逻辑分区*****
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (133-652, default 133):
Using default value 133
Last cylinder, +cylinders or +size{K,M,G} (133-652, default 652): +1G

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (265-652, default 265):
Using default value 265
Last cylinder, +cylinders or +size{K,M,G} (265-652, default 652):
Using default value 652

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa64fcc39

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         132     1060258+  83  Linux
/dev/sdb4             133         652     4176900    5  Extended
/dev/sdb5             133         264     1060258+  83  Linux
/dev/sdb6             265         652     3116578+  83  Linux
*****保存分区设置并退出fdisk*************
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

***********注意:初学者一般认为到这里就可以使用新磁盘了,但是却不是这样的,还要进行,创建文件系统,挂载文件系统后才可以使用*********

二.创建文件系统

mkfs命令创建文件系统

mkfs -t [文件系统类型]   [磁盘设备名]

-t :指定要创建哪一种文件系统

Linux系统内核可以支持几十种文件系统类型;1) ext2文件系统应该说是Linux正宗的文件系统,早期的Linux都是用ext2,但随着技术的发展,大多Linux的发行版本目前并不用这个文件系统了;比如Redhat和Fedora大多都建议用ext3 ,ext3文件系统是由ext2发展而来的。对于Linux新手,我们还是建议您不要用ext2文件系统;ext2支持undelete(反删除),如果您误删除文件,有时是可以恢复的,但操作上比较麻烦; ext2支持大文件; ext2文件系统的官方主页是: 2)ext3 文件系统:是由ext2文件系统发展而来; ext3 is a Journalizing file system for Linux(ext3是一个用于Linux的日志文件系统),ext3支持大文件;但不支持反删除(undelete)操作; Redhat和Fedora都力挺ext3;至于ext3文件系统的更多特性,请访问《Linux文件系统(filesystem)资源索引》 ; 3)reiserfs 文件系统; reiserfs文件系统是一款优秀的文件系统,支持大文件,支持反删除(undelete);在我的测试ext2、reiserfs反删除文件功能的过程中,我发现reiserfs文件系统表现的最为优秀,几乎能恢复90%以上的数据,有时能恢复到100%;操作反删除比较容易;reiserfs支持大文件; 4)、Linux 支持的文件系统; Linux目前几乎支持所有的Unix类的文件系统,除了我们在安装Linux操作系统时所要选择的ext3、reiserfs和ext2外,还支持苹果MACOS的HFS,也支持其它Unix操作系统的文件系统,比如XFS、JFS、Minix fs及UFS等,您可以在kernel的源码中查看;如果您想要让系统支持哪些的文件系统得需要把该文件系统编译成模块或置入内核; 当然Linux也支持Windows文件系统NTFST和fat,但不支持NTFS文件系统的写入;支持fat文件系统的读写 Linux也支持网络文件系统,比如NFS等;

# mkfs -t ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
66384 inodes, 265064 blocks
13253 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=272629760
9 block groups
32768 blocks per group, 32768 fragments per group
7376 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376

正在写入inode表: 完成                            
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@seven ~]# mkfs -t ext3 /dev/sdb4
mke2fs 1.41.12 (17-May-2010)
mkfs.ext3: inode_size (128) * inodes_count (0) too big for a
        filesystem with 0 blocks, specify higher inode_ratio (-i)
        or lower inode count (-N).

三.挂载和卸载文件系统

******使用mount和umount命令可以实现挂载和卸载功能,这样用户才可以使用相应的设备存储数据*******

设置需要放置文件系统的目录/mnt/kk;然后将/dev/sdb1挂载到该目录中

# mkdir /mnt/kk
# mount /dev/sdb1 /mnt/kk、

查看/mnt/kk ,其中没有任何文件
# ls /mnt/kk
lost+found
# mkdir /mnt/kk/test
# ls /mnt/kk
lost+found  test

使用df命令查看分区信息
# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda3       18244476 2727168  14583884  16% /
tmpfs             969900      76    969824   1% /dev/shm
/dev/sda1         194241   28677    155324  16% /boot
/dev/sr0         3116336 3116336         0 100% /media/RHEL-6.6 Server.i386
/dev/sdb1        1043548   34112    956424   4% /mnt/kk

卸载文件系统

# umount /dev/sdb1
# ls /mnt/kk
# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda3       18244476 2726532  14584520  16% /
tmpfs             969900      76    969824   1% /dev/shm
/dev/sda1         194241   28677    155324  16% /boot
/dev/sr0         3116336 3116336         0 100% /media/RHEL-6.6 Server.i386

****将某个分区或设备挂载了以后才能使用,但是当计算机重启以后,有需要重新挂载这个时候可以通过修改/etc/fstab文件实现开机自动挂载文件系统

[root@seven ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Nov 28 21:56:53 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=125de97e-b784-4948-bc00-7dbfdc11c8a5 /                       ext4    defaults        1 1
UUID=e69780c7-d8f5-4d34-a7a7-8abe01c2299c /boot                   ext4    defaults        1 2
UUID=2b532692-271a-4f6b-845f-b07a271c603f swap                    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

在/etc/fstab的最下面一行加上,使/dev/sdb1开机自动挂载

/dev/sdb1              /mnt/kk                 ext3     defaults        0 0

Linux怎么使用添加的新硬盘的更多相关文章

  1. linux服务器添加一块新硬盘不用重新启动机器的操作

    Linux系统添加一块新硬盘不用关闭系统即可加载硬盘信息的操作 因之前换过硬盘重装系统,硬盘上的数据没有拷贝出来,开发人员问我要备份,炸了.我只好联系机房让他把之前换掉的硬盘插回服务器.但是插好之后f ...

  2. linux系统,CentOs7加新硬盘

    1,打开Vmware软件,添加一块新的硬盘,然后一直下一步. 2.通过CRT等终端软件,连接到机器 [root@Mysql ~]# lsblk    //检查一下硬盘分区信息 [root@Mysql ...

  3. linux 给用户添加进新的组

    给用户user1添加一个新的组group1 usermod -G group1 #给当前登录用户所在组设置为 group1 注意:上面的命令有个问题需要知道,这个操作是重置用户所在组,也就是会让当前用 ...

  4. 为linux添加一块新硬盘并分区

    一---如何增加一块硬盘1:虚拟机添加硬盘2:分区3:格式化4:挂载5:设置可以自动挂载 1---设置里面 2---分区命令 fdisk /dev/sdb开始分区m显示命令列表p显示磁盘分区 同fdi ...

  5. CentOS系统在不重启的情况下为虚拟机添加新硬盘

    一.概述 用过虚拟机的都知道,如果在系统运行的时候去给虚拟机添加一块新设备,比如说硬盘,系统是读取不到这个新硬盘的,因为系统在启动的时候会去检测硬件设备.但是我们也可能会遇到这样的情况,比如正在运行比 ...

  6. 添加新硬盘,扩展Centos7根分区

    ##背景介绍,系统安装时,分配的硬盘容量太小,根分区空间不够用,现添加一个新硬盘,通过以下步骤来扩展centos7根分区 [root@t201 ~]# df -h 文件系统 容量 已用 可用 已用% ...

  7. linux硬盘挂载-新硬盘挂载和扩容硬盘挂载

    这里对当前我实际操作后的两种硬盘挂载进行整理: 第1种是直接添加一块新硬盘,然后进行挂载. 第2种是对硬盘进行扩容后,对扩容后的空间进行分区再进行挂载. [内容为参考网上资料,再加自已实际操作情况进行 ...

  8. centos7添加新硬盘并挂载

    一.查看现有磁盘设备 fdisk -l 发现/dev/sdb 为新加的硬盘: 二.开始分区 fdisk /dev/sdb fdisk -l #再次查看分区情况,已经有了/dev/sdb1 三.创建文件 ...

  9. RHEL7虚拟机中不重启的情况下加新硬盘及扩展根分区容量

    在VMware中添加一块新的5G硬盘 显示当前分区 # fdisk -l 通常在你在虚拟机中添加一块新硬盘时,你可能会看到新硬盘没有自动加载.这是因为连接到硬盘的SCSI总线需要重新扫描来使得新硬盘可 ...

随机推荐

  1. Java GC系列(3):垃圾回收器种类

    本文由 ImportNew - 好好先生 翻译自 javapapers. 目录 垃圾回收介绍 垃圾回收是如何工作的? 垃圾回收的类别 垃圾回收监视和分析 在这篇教程中我们将学习几种现有的垃圾回收器.在 ...

  2. VirtualBox – Error In supR3HardenedWinReSpawn 问题解决办法

    转:http://chenpeng.info/html/3510---------VirtualBox – Error In supR3HardenedWinReSpawn---------<h ...

  3. hdu5882 Balanced Game

    题目链接:hdu5882 Balanced Game 题解:每种手势的攻防数一样,不难想到n为奇数时游戏平衡. #include<cstdio> #include<cstring&g ...

  4. .NET GC机制学习笔记

    学习笔记内容来自网络资料摘录http://www.cnblogs.com/springyangwc/archive/2011/06/13/2080149.html 1.GC介绍 Garbage Col ...

  5. firefox hack

    @-moz-document url-prefix(){ css选择器 { css样式设置 } }

  6. [转]C#设置WinForm快捷键

    1.Alt+*(按钮快捷键)按钮快捷键也为最常用快捷键,其设置也故为简单.在大家给button.label.menuStrip等其他控件的Text属性指定名称时,在其后面加上‘&’然后在加上一 ...

  7. 关于call和apply的那点事儿

    在JavaScript中改变闭包中的this关键字中经常用到的就是call和apply了 首先:call和apply的作用的区别是什么? 答:call和apply 的作用是相同的.都是用来改变函数th ...

  8. Matrix-Tree定理

    感觉又学到了一个利器! 感谢Vfleaking神犇,传送门 http://vfleaking.blog.163.com/blog/static/1748076342013112523651955/   ...

  9. Resume InlineHookSSDT

    在InlineHook中修改了zwOpenProcess函数的中的指令 与Resume HookSSDT同理 找出一个正确的值覆盖上去就行. 突发奇想  有没有可能上去一个驱动或者程序  直接卸载掉I ...

  10. 可伸缩的textview。

    在一些应用中,比如腾讯的应用市场APP应用宝,关于某款应用的介绍文字,如果介绍文字过长,那么不是全部展现出来,而是显示三四行的开始部分(摘要),预知全部的内容,用户点击展开按钮即可查阅全部内容. 这样 ...