环境:
在正常运行CentOS 7.1的机器上添加一块80G的新硬盘.
系统:
2 | CentOS Linux release 7.1.1503 (Core) |
5 | Linux localhost.localdomain 3.10.0-229.el7.x86_64 |
步骤:
1、关机、加硬盘、开机
2、查看硬盘是否识别到
03 | Disk /dev/sda : 500.1 GB, 500107862016 bytes, 976773168 sectors |
04 | Units = sectors of 1 * 512 = 512 bytes |
05 | Sector size (logical /physical ): 512 bytes / 512 bytes |
06 | I /O size (minimum /optimal ): 512 bytes / 512 bytes |
08 | Disk identifier: 0xf0b1ebb0 |
10 | Device Boot Start End Blocks Id System |
11 | /dev/sda1 * 4096 209723391 104859648 7 HPFS /NTFS/exFAT |
12 | /dev/sda2 209723392 210747391 512000 83 Linux |
13 | /dev/sda3 210747392 976773119 383012864 8e Linux LVM |
15 | Disk /dev/sdb : 80.0 GB, 80026361856 bytes, 156301488 sectors |
16 | Units = sectors of 1 * 512 = 512 bytes |
17 | Sector size (logical /physical ): 512 bytes / 512 bytes |
18 | I /O size (minimum /optimal ): 512 bytes / 512 bytes |
20 | Disk identifier: 0x947748e0 |
3、fdisk /dev/sdb 硬盘分区
02 | Welcome to fdisk (util-linux 2.23.2). |
04 | Changes will remain in memory only, until you decide to write them. |
05 | Be careful before using the write command . |
08 | Command (m for help): m |
10 | a toggle a bootable flag |
12 | c toggle the dos compatibility flag |
14 | g create a new empty GPT partition table |
15 | G create an IRIX (SGI) partition table |
16 | l list known partition types |
19 | o create a new empty DOS partition table |
20 | p print the partition table |
21 | q quit without saving changes |
22 | s create a new empty Sun disklabel |
23 | t change a partition's system id |
24 | u change display /entry units |
25 | v verify the partition table |
26 | w write table to disk and exit |
27 | x extra functionality (experts only) |
29 | Command (m for help): p |
31 | Disk /dev/sdb : 80.0 GB, 80026361856 bytes, 156301488 sectors |
32 | Units = sectors of 1 * 512 = 512 bytes |
33 | Sector size (logical /physical ): 512 bytes / 512 bytes |
34 | I /O size (minimum /optimal ): 512 bytes / 512 bytes |
36 | Disk identifier: 0x947748e0 |
38 | Device Boot Start End Blocks Id System |
40 | Command (m for help): n |
42 | p primary (0 primary, 0 extended, 4 free ) |
45 | Partition number (1-4, default 1): 1 |
46 | First sector (2048-156301487, default 2048): |
47 | Using default value 2048 |
48 | Last sector, +sectors or +size{K,M,G} (2048-156301487, default 156301487): |
49 | Using default value 156301487 |
50 | Partition 1 of type Linux and of size 74.5 GiB is set |
52 | Command (m for help): w |
53 | The partition table has been altered! |
55 | Calling ioctl() to re- read partition table. |
4、查看分区是否成功
2 | brw-rw----. 1 root disk 8, 16 Apr 15 22:11 /dev/sdb |
3 | brw-rw----. 1 root disk 8, 17 Apr 15 22:11 /dev/sdb1 |
5、格式化分区
2 | mkfs mkfs.btrfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.minix mkfs.xfs |
6、挂载新硬盘,并添加到 /etc/fstab自动挂载
02 | mount /dev/sdb1 /newdisk |
12 | /dev/sdb1 /newdisk xfs defaults 0 0 |
7、重启验证一下
02 | Filesystem Type Size Used Avail Use% Mounted on |
03 | /dev/mapper/centos-root xfs 50G 1.1G 49G 3% / |
04 | devtmpfs devtmpfs 927M 0 927M 0% /dev |
05 | tmpfs tmpfs 937M 0 937M 0% /dev/shm |
06 | tmpfs tmpfs 937M 8.5M 928M 1% /run |
07 | tmpfs tmpfs 937M 0 937M 0% /sys/fs/cgroup |
08 | /dev/sdb1 xfs 75G 33M 75G 1% /newdisk |
09 | /dev/mapper/centos-home xfs 312G 33M 312G 1% /home |
10 | /dev/sda2 xfs 497M 121M 377M 25% /boot |
参考文档:
http://www.linuxidc.com/Linux/2011-02/31868.htm