linux下挂载新硬盘和分区的步骤 (50天)
今天和大家分享一下在linux下挂载新硬盘的步骤。
演示的环境基于centos
[root@localhost etc]# uname -a
Linux localhost.localdomain 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost etc]# cat system-release
CentOS release 6.2 (Final)
[root@localhost etc]#
先挂载了一个3G的硬盘查看磁盘空间的情况
[root@localhost etc]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x0004daae
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 4998 39832576 83 Linux
/dev/sda3 4998 5222 1802240 82 Linux swap / Solaris
Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 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: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
划分磁盘分区,分为4个主分区,最后写入磁盘。
[root@localhost etc]# fdisk /dev/sdb
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').
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)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 4
First cylinder (1-391, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-391, default 391): 100
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (101-391, default 101): 101
Last cylinder, +cylinders or +size{K,M,G} (101-391, default 391): 200
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (201-391, default 201): 201
Last cylinder, +cylinders or +size{K,M,G} (201-391, default 391): 300
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Selected partition 1
First cylinder (301-391, default 301): 301
Last cylinder, +cylinders or +size{K,M,G} (301-391, default 391): 391
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost etc]# fdisk -l
再次查看分区情况,
Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 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: 0xe5f51a7b
Device Boot Start End Blocks Id System
/dev/sdb1 301 391 730957+ 83 Linux
/dev/sdb2 101 200 803250 83 Linux
/dev/sdb3 201 300 803250 83 Linux
/dev/sdb4 1 100 803218+ 83 Linux
Partition table entries are not in disk order
我就格式化第一个分区,采用文件系统ext3.
[root@localhost etc]# mkfs -t ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
45696 inodes, 182739 blocks
9136 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=188743680
6 block groups
32768 blocks per group, 32768 fragments per group
7616 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
创建一个临时目录,然后把分区挂载到这个目录下。
[root@localhost /]# mkdir test
[root@localhost /]# mount /dev/sdb1 /test
挂载后查看磁盘情况,就可以看到分区就在那了。
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 38G 32G 4.3G 89% /
tmpfs 980M 288K 980M 1% /dev/shm
/dev/sda1 291M 32M 244M 12% /boot
/dev/sdb1 703M 17M 651M 3% /test
配置开机启动项
vi /etc/fstab
LABEL=SWAP-sda2 swap swap defaults 0 0
加入如下
/dev/sdb1 /test ext3 defaults 1 1
~
5. 第5列为dump选项,设置是否让备份程序dump备份文件系统,0为忽略,1为备份。
6. 第6列为fsck选项,告诉fsck程序以什么顺序检查文件系统,0为忽略。
- SQL Sever索引
- 使用SQL Server Management Studio 2008 将数据库里的数据导成脚本
- jquery mobile 移动web(5)
- [C#6] 1-using static
- WordPress 中的 Debug 模式(调试模式)
- Windows Server 2008 R2 Server Core 的 Microsoft .NET Framework 4安装程序
- [C#6] 4-string 插值
- 使用API Key验证WCF Data Service
- WordPress By Example:一个WordPress 主题搜索引擎
- jquery mobile 移动web(4)
- [C#6] 3-null 条件运算符
- ServiceStack.Redis 使用教程
- WordPress 标签页面只有一篇文章时自动跳转到该文章
- OS X 上使用.NET开发应用程序
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- LeetCode41|数组中数组出现的次数
- Django后台管理界面修改(源文件修改)
- 前端工程师不可不知的Nginx知识
- Django1.11 简单登录注册
- 基因表达聚类分析之初探SOM - 自组织特征图
- JMH - Java 代码性能测试的终极利器、必须掌握
- 从零搭建Spring Boot脚手架(6):整合Redis作为缓存
- 换一种姿势挖掘CORS漏洞
- 新的Spring OAuth2.0 授权服务器项目正式发布
- spring boot整合apollo
- 枚举和List的几个共有方法
- AtomicInteger源码解析
- AtomicIntegerArray源码解析
- AtomicIntegerFieldUpdater源码解析
- “终于懂了” 系列:Android屏幕刷新机制—VSync、Choreographer 全面理解!