美文网首页
【Linux-运维】redhat挂载新磁盘

【Linux-运维】redhat挂载新磁盘

作者: blue_smile | 来源:发表于2018-06-14 10:35 被阅读0次

1、查看现有已挂载硬盘情况

[root@WSC-129-95 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        20G  3.6G   15G  20% /
devtmpfs         32G     0   32G   0% /dev
tmpfs            32G     0   32G   0% /dev/shm
tmpfs            32G  1.2G   30G   4% /run
tmpfs            32G     0   32G   0% /sys/fs/cgroup
/dev/sda4       1.8T  671M  1.7T   1% /data
/dev/sda3        20G 1006M   18G   6% /usr/local

2、查看机器所有硬盘情况
通过和对比已挂载磁盘,多出的一部分就是未挂载盘

[root@WSC-129-95 ~]# fdisk -l | grep -P "Disk /dev/[a-z]{0,3}:"
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdk: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdf: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sde: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdl: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdi: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdg: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdj: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sdh: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors

3、分区

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 0x8b821ab0.
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): n  #回车
Command action
   e   extended
   p   primary partition (1-4)
p #回车
Partition number (1-4): 1 #回车
First cylinder (1-13054, default 1): #回车
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054): #回车
Using default value 13054
Command (m for help): w #回车
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# 到这里分区工作已完成,执行fdisk -l可以看到多了一个分区
# 我是按照顺序挂载磁盘,所以第一个磁盘是sdb,对应增加的分区就是sdb1

4、格式化
格式化可以按照指定格式进行格式化,相关命令输入mkfs后按TAB键可以查看
这里我的系统是ext4文件系统,如下所示

[root@WSC-129-95 ~]# mkfs.ext4 /dev/sdb1 
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122101760 inodes, 488378385 blocks
24418919 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2636120064
14905 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    102400000, 214990848

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

5、挂载
已经完成分区和系统格式化后,只需将其挂载在操作系统上即可

[root@WSC-129-95 ~]# mount /dev/sdb1 /data1
# 挂载成功后,可以通过df -h查看是否挂载成功
[root@WSC-129-95 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        20G  3.6G   15G  20% /
devtmpfs         32G     0   32G   0% /dev
tmpfs            32G     0   32G   0% /dev/shm
tmpfs            32G  1.2G   30G   4% /run
tmpfs            32G     0   32G   0% /sys/fs/cgroup
/dev/sda4       1.8T  671M  1.7T   1% /data
/dev/sda3        20G 1007M   18G   6% /usr/local
/dev/sdb1       1.8T   77M  1.7T   1% /data1

6、设置开机自动挂载
Linux中,没有写入配置文件中的信息,重启后都会失效。
所以想要实现自动挂载,需要配置文件信息。

vi /etc/fstab
# 增加一行内容
/dev/sdb1       /data1   ext4    defaults        1       2
# 保存后退出,这里应该是可以自动挂载了。如需验证,重启下机器即可

相关文章

网友评论

      本文标题:【Linux-运维】redhat挂载新磁盘

      本文链接:https://www.haomeiwen.com/subject/pfyeeftx.html