一.磁盘分区

装过系统后第一块磁盘的设备号是/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. [redis] Redis 常用命令

    redis命令文档:http://doc.redisfans.com/index.html 1. redis查看当前所有的key KEYS * 模糊匹配keykeys 模糊字符串*   2. 查看当前 ...

  2. 1029c语言文法

    <程序>→<外部声明>|<程序><外部声明> <外部声明>→<函数定义>|<声明> <函数定义>→< ...

  3. Qt之自定义控件(开关按钮)

    简述 接触过IOS系统的童鞋们应该对开关按钮很熟悉,在设置里面经常遇到,切换时候的滑动效果比较帅气. 通常说的开关按钮,有两个状态:on.off. 下面,我们利用自定义控件来实现一个开关按钮. 简述 ...

  4. ubuntu14.04LS中安装SSH

    我只能说: 蛋疼了 因为 1.曾经12.04和13.10的源已经不能使用了(PS毕竟支持的时间到了) 2网上有好多说是更新源的 , 打开etc/...文件 ,然后粘贴一下他们给的源的地址 或许有些是可 ...

  5. 集合框架,ArrayList和Vector的区别,让arrayList线程安全的几种方案

    boolean add(E e) 将指定的元素添加到此列表的尾部. void add(int index, E element) 将指定的元素插入此列表中的指定位置. boolean addAll(C ...

  6. SAP客户标准信用额度修改和创建

    好吧,前提要说一下,信贷是到客户的信贷范围级别的. FUNCTION zfm_credit. *"---------------------------------------------- ...

  7. Gliffy

    http://www.gliffy.com Gliffy 支持在线制作流程图,能够很好的支持中文,基础版本免费.在线制作的思维导图是公开的,高级版本有设置隐私权的权力.可以嵌入博客,办公室应用软件中, ...

  8. 【转载】JSP中文乱码问题

     原作者http://www.cnblogs.com/xing901022/p/4354529.html 阅读目录 之前总是碰到JSP页面乱码的问题,每次都是现在网上搜,然后胡乱改,改完也不明白原因. ...

  9. enum使用总结

    enum的一般使用方法是它会占用最大的成员长度 然后我忘记的是enum还可以这样使用 enum ExctState { START, SUCCEED, FAILURE=6, REJECT, }; 这样 ...

  10. c#获取系统时间的方法(转)

      1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 ...