Centos挂载新硬盘,格式化新硬盘,普通挂载及UUID方式挂载并设置开机启动
1.查看当前硬盘使用状况:
1 2 3 4 5 |
[root@localhost data]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 9.3G 6.7G 2.2G 76% / tmpfs 495M 0 495M 0% /dev/shm /dev/sda1 97M 49M 44M 54% /boot |
2.查看新硬盘
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
[root@localhost ~]# fdisk -l Disk /dev/sda: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0x000d1d5b Device Boot Start End Blocks Id System /dev/sda1 * 1 13 102400 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 13 79 524288 82 Linux swap / Solaris Partition 2 does not end on cylinder boundary. /dev/sda3 79 1306 9858048 83 Linux Disk /dev/sdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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 |
新添加的硬盘的编号为/dev/sdb
3.硬盘分区
1)进入fdisk模式
1 |
#/sbin/fdisk /dev/sdb |
2)输入n进行分区
1 |
Command (m for help): n |
3)选择分区类型
1 2 3 |
Command action e extended p primary partition (1-4) |
这里有两个选项:
p: 主分区 linux上主分区最多能有4个
e: 扩展分区 linux上扩展分区只能有1个,扩展分区创建后不能直接使用,还要在扩展分区上创建逻辑分区。
这里我选择的p。
4)选择分区个数
1 |
Partition number (1-4): 1 |
可以选择4个分区,这里我只分成1个分区
5)设置柱面,这里选择默认值就可以
1 2 3 4 |
First cylinder (1-1305, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): Using default value 1305 |
6)输入w,写入分区表,进行分区
1 2 3 4 5 |
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
4.格式化分区
将新分区格式化为ext3文件系统
1)如果创建的是主分区
1 |
#mkfs -t ext4 /dev/sdb1 |
5. 挂载硬盘
1) 创建挂载点
在根目录下创建storage目录
1 |
#mkdir /storage |
2) 将/dev/sdb1挂载到/storage下
1 |
#mount /dev/sdb1 /storage |
6. 设置开机启动自动挂载
新创建的分区不能开机自动挂载,每次重启机器都要手动挂载。
设置开机自动挂载需要修改/etc/fstab文件
1 |
#vi /etc/fstab |
在文件的最后增加一行
1 |
/dev/sdb5 /storage ext4 defaults 1 2 |
=====================================================================================
企业级应用系统的建设,通常将系统和数据分别存储,并建立raid。新装的CentOS6.5,需要挂载数据盘,并且能够系统启动自动挂载该数据盘。
1、手动挂载磁盘
查看磁盘分区信息,执行fdisk命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
[root@tsp-rls-webservice tsp]# fdisk -l Disk /dev/sdb: 1476.5 GB, 1476529225728 bytes 255 heads, 63 sectors/track, 179511 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: 0x0008a3a1 Device Boot Start End Blocks Id System /dev/sdb1 1 179512 1441922048 83 Linux Disk /dev/sda: 322.1 GB, 322122547200 bytes 255 heads, 63 sectors/track, 39162 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: 0x6a5b51c5 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 39163 314059776 8e Linux LVM Disk /dev/mapper/vg_tsprlswebserv-lv_root: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 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/mapper/vg_tsprlswebserv-lv_swap: 16.8 GB, 16814964736 bytes 255 heads, 63 sectors/track, 2044 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/mapper/vg_tsprlswebserv-lv_home: 251.1 GB, 251092008960 bytes 255 heads, 63 sectors/track, 30526 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 |
查看到/dev/sdb1没有挂载,接下来建立挂载点(创建挂载目录),执行mount命令,挂载数据盘。
1 2 |
[root@tsp-rls-webservice tsp]# mkdir /tsp [root@tsp-rls-webservice tsp]# mount /dev/sdb1 /tsp |
2、系统启动,自动挂载数据盘
查看磁盘UUID信息
1 2 3 4 5 6 7 |
[root@tsp-rls-webservice tsp]# blkid /dev/mapper/vg_tsprlswebserv-lv_root: UUID="3dedb8a7-69c5-44d7-b590-e70a0b1b3c9a" TYPE="ext4" /dev/sdb1: UUID="e85dd659-bb20-4d12-a8bc-16130efc04ea" TYPE="ext4" /dev/sda1: UUID="97f12da1-c972-4508-9028-9b98cde34a34" TYPE="ext4" /dev/sda2: UUID="cKJ1xc-8mci-0d89-DNaR-5IAG-2JOv-V1G1q9" TYPE="LVM2_member" /dev/mapper/vg_tsprlswebserv-lv_swap: UUID="aa4589df-1d47-4060-a419-9c4432c3bb9a" TYPE="swap" /dev/mapper/vg_tsprlswebserv-lv_home: UUID="17a62039-4676-45ce-8eb9-1914e2d4820c" TYPE="ext4" |
编辑系统分区表
1 |
[root@tsp-rls-webservice tsp]# vi /etc/fstab |
添加如下信息:
1 |
UUID=e85dd659-bb20-4d12-a8bc-16130efc04ea /tsp ext4 defaults 1 2 |
编辑后的信息如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# # /etc/fstab # Created by anaconda on Thu Aug 21 17:17:19 2014 # # 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_tsprlswebserv-lv_root / ext4 defaults 1 1 UUID=97f12da1-c972-4508-9028-9b98cde34a34 /boot ext4 defaults 1 2 UUID=e85dd659-bb20-4d12-a8bc-16130efc04ea /tsp ext4 defaults 1 2 /dev/mapper/vg_tsprlswebserv-lv_home /home ext4 defaults 1 2 /dev/mapper/vg_tsprlswebserv-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 |
保存退出;重启系统,确认自动挂载成功。
发表评论
要发表评论,您必须先登录。