Linux磁盘自动挂载

Linux磁盘挂载是比较常见的对linux系统管理的操作之一,需要耐心才能正确实现自动挂载,便于日后提高工作效率,和方便查看。

首先,为了需要,新添加一块磁盘到linux主机中,目的是让这个新添加的磁盘分区格式化并可以随系统启动自动挂载。

1.首先查看系统中磁盘信息,并确定是否需要分区。

[root@localhost ~]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes                此处是sda的磁盘信息

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 14 1044 8281507+ 83 Linux       

注意此处1044,若显示小于1044,表示磁盘尚有分区未划分

Linux磁盘自动挂载

/dev/sda2 1 13 104391 82 Linux swap / Solaris

Partition table entries are not in disk order

Disk /dev/sdb: 6442 MB, 6442450944 bytes

255 heads, 63 sectors/track, 783 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table        此处显示磁盘dev/sdb尚未格式化。

如上所示,系统中有两块磁盘sda、sdb,并提示sdb未含有分区表,需要将其进行分区操作。

2.对磁盘进行分区操作

[root@localhost ~]# fdisk /dev/sdb

Command (m for help): p                               p:print the partintion table

Disk /dev/sdb: 6442 MB, 6442450944 bytes                显示磁盘基本信息

255 heads, 63 sectors/track, 783 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

此处可以看出,尚未对磁盘进行分区

Command (m for help): n                              n:add a new partition

Command action

e extended                                           选择主分区还是扩展分区,在此选择主分区

p primary partition (1-4)

p

Partition number (1-4): 3                               选择分区数。

First cylinder (1-783, default 1):                            设置分区大小。此处定义1000M。就是最接近1000M的柱面号码

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-783, default 783): +1000M

Command (m for help): w                                如无误输入w保存配置信息,如不保存输入q退出

Command (m for help): p                                如下查看分区之后的磁盘信息

Disk /dev/sdb: 6442 MB, 6442450944 bytes

255 heads, 63 sectors/track, 783 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device     Boot Start End Blocks Id System

/dev/sdb1 368 783 3341520 83 Linux

/dev/sdb2 124 367 1959930 83 linux

/dev/sdb3 1 123 987966 83 Linux

3.将分区好的磁盘进行格式化操作

[root@localhost ~]# mke2fs -j /dev/sdb1                将磁盘sdb1格式化为ext3文件系统。

[root@localhost ~]# fdisk –l                              使用fdisk查看磁盘分区情况

4.将分区格式化完毕的磁盘挂载,检查确认分区格式化完毕。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/21020.html