一、前言
1. linux硬盘标识
sda - 表示第1块SCSI硬盘@b@ /dev/sda - 第一块sata 串口硬盘@b@ /dev/sdb - 第二块sata串口硬盘@b@ ...@b@hda - 表示第1块IDE硬盘@b@ /dev/hda - 第一块IDE接口硬盘@b@ /dev/hdb - 第二块IDE接口硬盘 @b@ ...@b@scd0 -- 表示第1个USB光驱
2. 磁盘最多4个主分区、一个扩展分区,如下图IDE硬盘所示,主分区hda1~hda4,扩展分区为hda5..
二、操作步骤
1. 装入新硬盘,重新后,查看新硬盘是否识别,如下图
或在命令行查看(如不清楚磁盘情况执行fdisk -l查看所有磁盘分区信息)
[root@s3 mnt]# fdisk -l /dev/sdb@b@WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.@b@Disk /dev/sdb: 4000.8 GB, 4000787030016 bytes@b@256 heads, 63 sectors/track, 484501 cylinders@b@Units = cylinders of 16128 * 512 = 8257536 bytes@b@Sector size (logical/physical): 512 bytes / 4096 bytes@b@I/O size (minimum/optimal): 4096 bytes / 4096 bytes@b@Disk identifier: 0x2e670a05@b@@b@ Device Boot Start End Blocks Id System@b@/dev/sdb1 1 266306 2147483647+ ee GPT@b@Partition 1 does not start on physical sector boundary.
2. 对新磁盘sdb进行分区前准备 - 如之前旧的分区信息(如有window分区格式化数据),先删除(在Command (m for help)行后输入 d)
[root@s3 mnt]# fdisk /dev/sdb@b@WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.@b@WARNING: The size of this disk is 4.0 TB (4000787030016 bytes).@b@DOS partition table format can not be used on drives for volumes@b@larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID @b@partition table format (GPT).@b@@b@The device presents a logical sector size that is smaller than@b@the physical sector size. Aligning to a physical sector (or optimal@b@I/O) size boundary is recommended, or performance may be impacted.@b@@b@WARNING: DOS-compatible mode is deprecated. It's strongly recommended to@b@ switch off the mode (command 'c') and change display units to@b@ sectors (command 'u').@b@@b@Command (m for help): d@b@Selected partition 1
3. 然后在创建新分区并格式化,如下输入n,回车1后,再选择分区类型(e - 扩展分区或 p - 主分区),输入p, 回车2后,提示选择分区数量(1-4),这边输入1 (分1个主分区),回车3后,后面直接回车选择默认(回车4、5),输入w - 写入分区表生效设置,再回车6,完成分区步骤
Command (m for help): n --回车1@b@Command action@b@ e extended@b@ p primary partition (1-4)@b@ p --回车2@b@Partition number (1-4): 1 --输入1,回车3@b@First cylinder (1-484501, default 1): --回车4@b@Using default value 1@b@Last cylinder, +cylinders or +size{K,M,G} (1-266305, default 266305): --回车5@b@Using default value 266305@b@Command (m for help): w --输入w,回车6@b@The partition table has been altered!@b@@b@Calling ioctl() to re-read partition table.@b@Syncing disks.
4. 格式化分区,首先查看磁盘挂载情况,当前磁盘情况&文件系统格式化版本ext4
[root@s3 vm]# df -lhT@b@Filesystem Type Size Used Avail Use% Mounted on@b@/dev/mapper/vg_s3-lv_root ext4 50G 5.5G 42G 12% /@b@tmpfs tmpfs 3.9G 80K 3.9G 1% /dev/shm@b@/dev/sda1 ext4 477M 42M 410M 10% /boot@b@/dev/mapper/vg_s3-lv_home ext4 860G 774G 42G 95% /home
执行分区命令mkfs,如下
[root@s3 mnt]# mkfs -t ext4 /dev/sdb1@b@mke2fs 1.41.12 (17-May-2010)@b@/dev/sdb1 alignment is offset by 512 bytes.@b@This may result in very poor performance, (re)-partitioning suggested.@b@文件系统标签=@b@操作系统:Linux@b@块大小=4096 (log=2)@b@分块大小=4096 (log=2)@b@Stride=1 blocks, Stripe width=0 blocks@b@134217728 inodes, 536870872 blocks@b@26843543 blocks (5.00%) reserved for the super user@b@第一个数据块=0@b@Maximum filesystem blocks=4294967296@b@16384 block groups@b@32768 blocks per group, 32768 fragments per group@b@8192 inodes per group@b@Superblock backups stored on blocks: @b@ 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, @b@ 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, @b@ 102400000, 214990848, 512000000@b@@b@正在写入inode表: 完成 @b@Creating journal (32768 blocks): 完成@b@Writing superblocks and filesystem accounting information: 完成@b@@b@This filesystem will be automatically checked every 34 mounts or@b@180 days, whichever comes first. Use tune2fs -c or -i to override.
5. 挂载新磁盘分区,创建挂载目录/ext/4T,再执行mount进行挂载,之后查看当前磁盘情况(解挂命令: umount /ext/4T)
[root@s3 /]# mkdir /ext/4T@b@[root@s3 /]# mount /dev/sdb1 /ext/4T@b@[root@s3 /]# df -l@b@Filesystem 1K-blocks Used Available Use% Mounted on@b@/dev/mapper/vg_s3-lv_root 51475068 5704148 43149480 12% /@b@tmpfs 4024640 228 4024412 1% /dev/shm@b@/dev/sda1 487652 42776 419276 10% /boot@b@/dev/mapper/vg_s3-lv_home 901254408 811524340 43942320 95% /home@b@/dev/sdb1 2113656592 71704 2006210716 1% /ext/4T
6. 配置开机自动挂着新磁盘到挂载点,不然每次重启都需手动挂载
[root@s3 /]# vi /etc/fstab@b@@b@# ...@b@# 在最后一行加入如下配置@b@/dev/sdb1 /ext/4T ext4 defaults 0 0@b@@b@############备注说明##############@b@@b@ # 1. /dev/sdb1 - 是您想要mount的储存装置的实体位置 @b@ # 2. /ext/4T - 就是您想要将其加入至哪个目录位置,如/home或/,这其实就是在安装时提示的挂入点。@b@ # 3. ext4 - 就是所谓的local filesystem,其包含了以下格式:如ext、ext2、msdos、iso9660、nfs、swap等,或如ext2,可以参见/prco/filesystems说明。@b@ # 4. defaults - 就是您mount时,所要设定的状态,如ro(只读)或defaults(包括了其它参数如rw、suid、exec、auto、nouser、async),可以参见「mount nfs」。@b@ # 5. 0 - 指明是否要备份,(0为不备份,1为要备份,一般根分区要备份)@b@ # 6. 0 - 指明自检顺序。 (0为不自检,1或者2为要自检,如果是根分区要设为1,其他分区只能是2)
��