这些步骤需要有管理员的权限。
步骤
使用fdisk -l开查看但钱状态下磁盘情况
$ fdisk -l Disk /dev/sda: 21.5 GB,21474836480 bytes,41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x00085a0c Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 41943039 20458496 8e Linux LVM # 注意看这里:这个就是新的硬盘 # 记下/dev/sdb这个名称 Disk /dev/sdb: 1073 MB,1073741824 bytes,2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/centos-root: 18.8 GB,18756927488 bytes,36634624 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/centos-swap: 2147 MB,2147483648 bytes,4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
使用过fdisk /dev/sdb来进行分区操作
$ fdisk /dev/sdb # Command (m for help): n //输入N表示新建一个分区 # Command (m for help): w //保存分区
再次fdisk -l查看信息
$ fdisk -l
用mkfs.ext3格式化新分区
$ mkfs.ext3 /dev/sdb
挂载使用
$ mkdir /mnt/hdb1 //新建一个挂载点。 $ mount /dev/hdb1 /mnt/hdb1 //挂载。 $ df -h
开机自动挂载
在vi /etc/fstab中添加新硬盘的挂载信息,添加下面一行:
/dev/hdb1 /mnt/hdb1 ext3 defaults 1 2(如果还有一个分区就是1 3,以此类推)
这样,每次开机后,系统会自动将/dev/hdb1挂载到/mnt/hdb1
# # /etc/fstab # Created by anaconda on Tue May 10 23:34:03 2016 # # 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/centos-root / xfs defaults 0 0 UUID=d54493d2-18fd-4e43-b425-45dd790bdeaf /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0