Linux怎么使用添加的新硬盘
一.磁盘分区
装过系统后第一块磁盘的设备号是/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怎么使用添加的新硬盘的更多相关文章
- linux服务器添加一块新硬盘不用重新启动机器的操作
Linux系统添加一块新硬盘不用关闭系统即可加载硬盘信息的操作 因之前换过硬盘重装系统,硬盘上的数据没有拷贝出来,开发人员问我要备份,炸了.我只好联系机房让他把之前换掉的硬盘插回服务器.但是插好之后f ...
- linux系统,CentOs7加新硬盘
1,打开Vmware软件,添加一块新的硬盘,然后一直下一步. 2.通过CRT等终端软件,连接到机器 [root@Mysql ~]# lsblk //检查一下硬盘分区信息 [root@Mysql ...
- linux 给用户添加进新的组
给用户user1添加一个新的组group1 usermod -G group1 #给当前登录用户所在组设置为 group1 注意:上面的命令有个问题需要知道,这个操作是重置用户所在组,也就是会让当前用 ...
- 为linux添加一块新硬盘并分区
一---如何增加一块硬盘1:虚拟机添加硬盘2:分区3:格式化4:挂载5:设置可以自动挂载 1---设置里面 2---分区命令 fdisk /dev/sdb开始分区m显示命令列表p显示磁盘分区 同fdi ...
- CentOS系统在不重启的情况下为虚拟机添加新硬盘
一.概述 用过虚拟机的都知道,如果在系统运行的时候去给虚拟机添加一块新设备,比如说硬盘,系统是读取不到这个新硬盘的,因为系统在启动的时候会去检测硬件设备.但是我们也可能会遇到这样的情况,比如正在运行比 ...
- 添加新硬盘,扩展Centos7根分区
##背景介绍,系统安装时,分配的硬盘容量太小,根分区空间不够用,现添加一个新硬盘,通过以下步骤来扩展centos7根分区 [root@t201 ~]# df -h 文件系统 容量 已用 可用 已用% ...
- linux硬盘挂载-新硬盘挂载和扩容硬盘挂载
这里对当前我实际操作后的两种硬盘挂载进行整理: 第1种是直接添加一块新硬盘,然后进行挂载. 第2种是对硬盘进行扩容后,对扩容后的空间进行分区再进行挂载. [内容为参考网上资料,再加自已实际操作情况进行 ...
- centos7添加新硬盘并挂载
一.查看现有磁盘设备 fdisk -l 发现/dev/sdb 为新加的硬盘: 二.开始分区 fdisk /dev/sdb fdisk -l #再次查看分区情况,已经有了/dev/sdb1 三.创建文件 ...
- RHEL7虚拟机中不重启的情况下加新硬盘及扩展根分区容量
在VMware中添加一块新的5G硬盘 显示当前分区 # fdisk -l 通常在你在虚拟机中添加一块新硬盘时,你可能会看到新硬盘没有自动加载.这是因为连接到硬盘的SCSI总线需要重新扫描来使得新硬盘可 ...
随机推荐
- iOS开发UIScrollView的底层实现
起始 做开发也有一段时间了,经历了第一次完成项目的激动,也经历了天天调用系统的API的枯燥,于是就有了探索底层实现的想法. 关于scrollView的思考 在iOS开发中我们会大量用到scrollVi ...
- Xcode8 及iOS10适配问题汇总
上点干货,目前得知的一些bug解决汇总:iOS10相册相机闪退bughttp://www.jianshu.com/p/5085430b029fiOS 10 因苹果健康导致闪退 crashhttp:// ...
- Java 之 I/O 系列 02 ——序列化(二)
Java 之 I/O 系列 目录 Java 之 I/O 系列 01 ——基础 Java 之 I/O 系列 02 ——序列化(一) Java 之 I/O 系列 02 ——序列化(二) 继续上篇的第二个问 ...
- select option居中显示
<style> .ch-select{ padding:0px;} .ch-select input[type=text]{ width:100%; position:relative; ...
- http 报文
HTTP报文详解 HTTP有两种报文:请求报文和响应报文,具体介绍如下 一.HTTP请求报文 先上个图,细细分析 HTTP请求报文主要包括请求行.请求头部以及请求的数据(实体)三部分 请求行(HTTP ...
- mysql 无法远程访问(授权也没办法,确切的说是因为只绑定了127IP)
默认状况下,出于安全考虑,mysql数据库屏蔽了远程访问功能. 然而在许多状况下,你需要在家或者从web程序去访问远端数据库服务器,这就相当麻烦了. 第一步: 激活网络设置你需要编辑mysql配置文件 ...
- C# 检测网络链接
;//Local system uses a modem to connect to the Internet. ; //Local system uses a local area network ...
- Unity3d之MonoBehaviour的可重写函数整理
最近在学习Unity3d的知识.虽然有很多资料都有记录了,可是我为了以后自己复习的时候方便就记录下来吧!下面的这些函数在Unity3d程序开发中具有很重要的作用. Update 当MonoBehavi ...
- POJ 1062 昂贵的聘礼 最短路 难度:0
http://poj.org/problem?id=1062 #include <iostream> #include <cstring> #include <queue ...
- Catalan数
先看2个问题: 问题一: n个元素进栈(栈无穷大),进栈顺序为1,2,3,....n,那么有多少种出栈顺序? 先从简单的入手:n=1,当然只有1种:n=2,可以是1,2 也可以是2,1:那么有2种: ...