荆轲刺秦王
远程SSH登录上CentOS服务器后,进行如下操作
提醒:挂载操作会清空数据,请确认挂载盘无数据或未使用
第一步:列出所有磁盘 命令: ll /dev/disk/by-path
[root@admin ~]# ll /dev/disk/by-path
total 0
lrwxrwxrwx 1 root root 9 Dec 19 15:15 pci-0000:00:07.1-scsi-1:0:0:0 -> ../../sr 0
lrwxrwxrwx 1 root root 9 Dec 19 15:15 pci-0000:00:10.0-scsi-0:0:0:0 -> ../../sd a
lrwxrwxrwx 1 root root 10 Dec 19 15:15 pci-0000:00:10.0-scsi-0:0:0:0-part1 -> .. /../sda1
lrwxrwxrwx 1 root root 10 Dec 19 15:15 pci-0000:00:10.0-scsi-0:0:0:0-part2 -> .. /../sda2
lrwxrwxrwx 1 root root 9 Dec 19 15:15 pci-0000:00:10.0-scsi-0:0:1:0 -> ../../sd b
提示:如果无法确认数据盘设备名称,请使用df命令来确认系统盘的名称,从而排除挂错盘的情况。
[root@admin ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_admin-lv_root
36580952 6037568 28678476 18% /
tmpfs 960872 0 960872 0% /dev/shm
/dev/sda1 487652 40341 421711 9% /boot
第二步:格式化硬盘 命令:fdisk /dev/sdb
[root@admin ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklab el
Building a new DOS disklabel with disk identifier 0x96e9db40.
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-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
Using default value 2610
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: 0x96e9db40
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.
注意:加粗部分需要手动输入
第三步:创建分区 命令:mkfs.ext4 /dev/sdb1
[root@admin ~]# mkfs.ext4 /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
1310720 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
First data block=0 (第一个数据块=0)
Maximum filesystem blocks=4294967296
160 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
Writing inode tables: done (正在写入inode表:完成)
Creating journal (32768 blocks): done (完成)
Writing superblocks and filesystem accounting information: done (完成)
This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
第四步:挂载分区 命令:mkdir /data
mount /dev/sdb1 /data #将sdb这个硬盘挂载成为/data
[root@admin ~]# mount /dev/sdb1 /data
[root@admin ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_admin-lv_root
35G 5.8G 28G 18% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/sda1 477M 40M 412M 9% /boot
/dev/sdb1 20G 44M 19G 1% /data
第五步:将信息写入fstab,让系统开启自动挂载。
命令: echo "/dev/sdb1 /data ext4 defaults 0 0" >> /etc/fstab
[root@admin ~]# echo "/dev/sdb1 /data ext4 defaults 0 0" >> /etc/fstab
[root@admin ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Dec 16 19:44:14 2017
#
# 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
#
/dev/mapper/vg_admin-lv_root / ext4 defaults 1 1
UUID=d6a341bc-6e77-4da3-adb0-872e5ae06ca9 /boot ext4 defaults 1 2
/dev/mapper/vg_admin-lv_swap 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
/dev/sdb1 /data /ext4 defaults 0 0
/dev/sdb1 /data ext4 defaults 0 0
/dev/sdb1 /data ext4 defaults 0 0
CentOS 6.5开机自动挂载硬盘 http://www.linuxidc.com/linux/2014-10/108446.htm
CentOS添加一个新的硬盘分区到挂载的过程 http://www.linuxidc.com/Linux/2013-06/85694.htm
CentOS挂载移动硬盘 http://www.linuxidc.com/Linux/2011-05/35694.htm
更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14
本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-04/115841.htm