详解linux添加硬盘分区挂载教程

作者:渣渣辉 时间:2023-11-02 19:06:50 

基本步骤:分区——格式化——挂载——写入文件

1、首先用fdisk -l命令查看添加的硬盘名称,可以看到sdb为新增的硬盘


[root@oracle ~]# fdisk -l

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x0006b59c

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    2358  18631680  83 Linux

/dev/sda3      2358    2611   2031616  82 Linux swap / Solaris

2、进行分区,输入m查看提示


[root@oracle ~]# 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 0x09f38795.

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').

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)

分析:主要参数的解析

1. 输入 m 显示所有命令列示。

2. 输入 p 显示硬盘分割情形,打印分区表。

3. 输入 a 设定硬盘启动区。

4. 输入 n 创建新的硬盘分割区。

  4.1. 输入 e 硬盘为[延伸]分割区(extend)。

  4.2. 输入 p 硬盘为[主要]分割区(primary)。

5. 输入 t 改变硬盘分割区属性。

  1. t:分区系统id号

  2. L:82:linux swap

  3. 83:linux

  4. 86:NTFS window分区

6. 输入 d 删除硬盘分割区属性。

7. 输入 q 结束不存入硬盘分割区属性。

8. 输入 w 结束并写入硬盘分割区属性

3、输入n创建新的硬盘分区——输入p创建主分区——输入1设置一个分区——回车——回车(默认全部空间)


Command (m for help): n

Command action

e  extended                                  ···扩展分区

p  primary partition (1-4)                          ···主分区

p

Partition number (1-4): 1

First cylinder (1-2610, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):

Using default value 2610

4、输入p查看分区情况——输入w保存退出(一定要w保存不然无效)


Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x09f38795

Device Boot   Start     End   Blocks  Id System

/dev/sdb1        1    2610  20964793+ 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

5、mkfs命令格式化磁盘


[root@oracle ~]# mkfs.ext4 /dev/sdb

mkfs.ext4: invalid fragment size - /dev/sdb

6、mount命令挂载分区


[root@oracle ~]# mount /dev/sdb /oracle/

You have new mail in /var/spool/mail/root

[root@oracle ~]# df -TH

Filesystem   Type  Size Used Avail Use% Mounted on

/dev/sda2   ext4  19G  11G 7.3G 60% /

tmpfs     tmpfs 2.1G  74k 2.1G  1% /dev/shm

/dev/sda1   ext4  297M  29M 253M 11% /boot

/dev/sdb    ext4  22G  47M  20G  1% /oracle

7、添加到/etc/fstab文件下保存退出否则重启后硬盘消失


/dev/sdb    /oracle     ext4  defaults,noatime    0 0

来源:http://www.cnblogs.com/Dev0ps/p/8807939.html

标签:linux,硬盘,分区,挂载
0
投稿

猜你喜欢

  • 老谢:软文入门注意点

    2009-04-07 16:17:00
  • 李彦宏:成功是因为自己得高人指点

    2008-07-29 13:14:00
  • PHPWind v7.3.2收藏夹分页链接错误问题

    2009-05-31 17:34:00
  • IIS7下让你的wordpress完美的驱动wp-super-cache

    2011-10-14 20:35:33
  • FTP服务器架设的三方面安全因素

    2009-02-10 16:01:00
  • 草根站长 趴在玻璃上的苍蝇

    2007-10-24 17:48:00
  • SEO入手统筹优化步骤

    2009-08-23 09:55:00
  • 做反向链接的10点策略

    2008-06-15 07:07:00
  • 六种Web浏览器与IE大比拼

    2008-04-23 16:36:00
  • Chrome OS欲破微软垄断 相互渗透核心业务

    2009-11-22 10:25:00
  • WEB服务器家族的瑞士军刀(一)

    2007-12-29 09:41:00
  • 如何在Discuz!论坛调用UCenter Home的数据

    2009-07-02 22:23:00
  • 做GG广告1年来的总结与分析

    2008-08-12 13:07:00
  • 细说 AdSense 政策:什么是鼓励点击

    2007-10-21 12:05:00
  • 内容之外 进行博客优化要注意的16个方面

    2009-01-08 13:59:00
  • Yahoo!网站性能最佳体验的34条黄金守则——服务器

    2008-05-29 13:22:00
  • 浅析Apache服务器中SSI和CGI设定方法

    2010-05-08 17:59:00
  • 详解CentOS7下PostgreSQL 11的安装和配置教程

    2022-11-12 00:57:03
  • 让谷歌搜索引擎快速地收录网站的十个要点

    2008-12-14 07:17:00
  • 去除网页文字干扰码的两种方法

    2008-01-23 17:15:00
  • asp之家 网站运营 m.aspxhome.com