[root@localhost ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000c591bDevice Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM /dev/sda3 41943040 52428799 5242880 8e Linux LVMDisk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /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/sda,按下图步骤操作。
[root@localhost ~]# fdisk /dev/sda Welcome to fdisk(util-linux 2.23.2).Changes will remain in memory only, until you decide to write them. Be careful before using the write command.Command (m for help): p ## p :显示磁盘当前的分区表 Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000c591bDevice Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM /dev/sda3 41943040 52428799 5242880 8e Linux LVMCommand (m for help): n ##输入n创建分区 Partition type:p primary (3 primary, 0 extended, 1 free)e extended Select (default e): p ## 询问我们是要创建主分区还是扩展分区,主分区最多只能创建4个,如果创建了扩展分区那么扩展分区需要占用一个主分区。这里我们创建分区,输入p Selected partition 4 First sector (52428800-62914559, default 52428800): 4 Value out of range. First sector (52428800-62914559, default 52428800): 52428800 Last sector, +sectors or +size{K,M,G}(52428800-62914559, default 62914559): 62914559 Partition 4 of type Linux and of size 5 GiB is setCommand (m for help): t Partition number (1-4, default 4): 4 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' ## 分区选择默认4 Command (m for help): w The partition table has been altered! ## w 保存 Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
在此执行fdisk -l查看,此时 /dev/sda4 硬盘已经存在
[root@localhost ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000c591bDevice Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM /dev/sda3 41943040 52428799 5242880 8e Linux LVM /dev/sda4 52428800 62914559 5242880 8e Linux LVMDisk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /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
执行mkfs -t ext3 /dev/sda4格式化逻辑分区
[root@localhost ~]# mkfs -t ext3 /dev/sda4 mke2fs 1.42.9 (28-Dec-2013) Could not stat /dev/sda4 --- No such file or directoryThe device apparently does not exist; did you specify it correctly?
[root@localhost ~]# partprobe [root@localhost ~]# mkfs -t ext3 /dev/sda4 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 327680 inodes, 1310720 blocks 65536 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1342177280 40 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, 884736Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done[root@localhost ~]#