1. 查看磁盘大小,此时如果是更新操作而非初始化操作,查看磁盘大小可能未改变,需执行第二步 # fdisk -l 2. 配置系统重新扫描存储设备的scsi总线,找到scsi磁盘编号,进行rescan # ls /sys/class/scsi_disk/ 0:0:0:0 # echo 1 >/sys/class/scsi_disk/0\:0\:0\:0/device/rescan #此处用\转意 3. 再次查看磁盘大小 # fdisk -l Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x0009ef1a
Device Boot Start End Blocks Id System /dev/sda1 * 2048 83886079 41942016 83 Linux 4. 划分磁盘空间 # 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 forhelp): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (2-4, default 2): 2 First sector (83886080-209715199, default 83886080): Using default value 83886080 Last sector, +sectors or +size{K,M,G} (83886080-209715199, default 209715199): Using default value 209715199 Partition 2 of type Linux and of size 60 GiB is set
Command (m forhelp): w The partition table has been altered!
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. 5. 挂载虚拟文件系统 # kpartx -a /dev/sda device-mapper: reload ioctl on sda1 failed: Device or resource busy create/reload failed on sda1 device-mapper: reload ioctl on sda2 failed: Device or resource busy create/reload failed on sda2 # partprobe # mkfs -t ext3 /dev/sda2 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 3932160 inodes, 15728640 blocks 786432 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 480 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, 884736, 1605632, 2654208, 4096000, 7962624, 11239424