本文编写于 1777 天前,最后修改于 1775 天前,其中某些信息可能已经过时。
使用fdisk工具对硬盘进行操作
现有一块新硬盘vdb
| root@2018sh001-1213728:~# lsblk |
| NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT |
| vda 254:0 0 40G 0 disk |
| ├─vda1 254:1 0 3.7G 0 part [SWAP] |
| └─vda2 254:2 0 36.3G 0 part / |
| vdb 254:16 0 100G 0 disk |
进入硬盘,进行分区
| root@2018sh001-1213728:~# fdisk /dev/vdb |
| |
| Welcome to fdisk (util-linux 2.29.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 table. |
| Created a new DOS disklabel with disk identifier 0x7d58c695. |
| |
| Command (m for help): p |
| Disk /dev/vdb: 100 GiB, 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 |
| Disklabel type: dos |
| Disk identifier: 0x7d58c695 |
| #可该改硬盘,没有分区 |
| Command (m for help): n # n 新建分区 |
| Partition type |
| p primary (0 primary, 0 extended, 4 free) |
| e extended (container for logical partitions) |
| Select (default p): p #一路默认回车即可 |
| Partition number (1-4, default 1): 1 |
| First sector (2048-209715199, default 2048): |
| Last sector, +sectors or +size{K,M,G,T,P} (2048-209715199, default 209715199): |
| Created a new partition 1 of type 'Linux' and of size 100 GiB. # 创建分区成功 |
| w #保存退出 |
格式化分区,使用ext3格式
| root@2018sh001-1213728:~# mkfs.ext3 /vdb/vdb1 |
| mke2fs 1.43.4 (31-Jan-2017) |
| The file /vdb/vdb1 does not exist and no size was specified. |
| root@2018sh001-1213728:~# mkfs.ext3 /dev/vdb1 |
| mke2fs 1.43.4 (31-Jan-2017) |
| Creating filesystem with 26214144 4k blocks and 6553600 inodes |
| Filesystem UUID: 4e1ad9dd-1826-43d9-a7ba-a50b091a300a |
| Superblock backups stored on blocks: |
| 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, |
| 4096000, 7962624, 11239424, 20480000, 23887872 |
| |
| Allocating group tables: done |
| Writing inode tables: done |
| Creating journal (131072 blocks): done |
| Writing superblocks and filesystem accounting information: done |
将新硬盘挂载到/d2目录
| root@2018sh001-1213728:~# mount /dev/vdb1 /d2 |
| root@2018sh001-1213728:~# df -h |
| Filesystem Size Used Avail Use% Mounted on |
| udev 991M 0 991M 0% /dev |
| tmpfs 201M 25M 177M 13% /run |
| /dev/vdb1 36G 12G 23G 34% / |
| tmpfs 1002M 0 1002M 0% /dev/shm |
| tmpfs 5.0M 8.0K 5.0M 1% /run/lock |
| tmpfs 1002M 0 1002M 0% /sys/fs/cgroup |
| tmpfs 201M 0 201M 0% /run/user/0 |
| /dev/vdb1 98G 61M 93G 1% /d2 |
| #可见多了一个分区,挂载成功 |
卸载并删除分区(未经测试)
| umount /dev/sdc2 |
| |
| fdisk /dev/sdc |
| m |
| d |
| 1 |
| d |
| w |
the file /dev/vdb does not exist and no size was specified大佬,这个你怎么解决哈
小吴 2021-06-17 07:10
写的不错,可以转载你的文章吗 OωO
大鹏 2020-11-11 04:25
可以啊,注明出处哦
好好先生 2020-11-16 23:27