查看
fdisk l
Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x000a18d3 Device Boot Start End Blocks Id System/dev/vda1 2048 8194047 4096000 82 Linux swap / Solaris/dev/vda2 * 8194048 83886079 37846016 83 LinuxDisk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes
分区
fdisk /dev/vdb
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.Device does not contain a recognized partition tableBuilding a new DOS disklabel with disk identifier 0x60f2f992.Command (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1): 1First sector (2048-419430399, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): Using default value 419430399Partition 1 of type Linux and of size 200 GiB is setCommand (m for help): wqThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.
格式化
mkfs.ext4 /dev/vdb1
mke2fs 1.42.9 (28-Dec-2013)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks13107200 inodes, 52428544 blocks2621427 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=21999124481600 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done
增加分区信息
echo '/dev/vdb1 /opt ext4 defaults 0 0' >> /etc/fstab
挂载
mount -a
查看挂载后果
df -h
Filesystem Size Used Avail Use% Mounted on/dev/vda2 36G 1.9G 32G 6% /devtmpfs 16G 0 16G 0% /devtmpfs 16G 0 16G 0% /dev/shmtmpfs 16G 8.4M 16G 1% /runtmpfs 16G 0 16G 0% /sys/fs/cgrouptmpfs 3.2G 0 3.2G 0% /run/user/0/dev/vdb1 197G 61M 187G 1% /opt