Linux硬盘管理

Linux硬盘管理常用命令

  • Linux硬盘管理
    • 硬盘分区管理
      • 删除分区
    • 硬盘格式化
        • 格式化磁盘报错
    • 挂载硬盘
      • 自动挂载
    • 后续

Linux硬盘管理

Linux 硬盘使用情况查看

df -h
Disk /dev/vda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00028912

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1        2611    20970496   83  Linux
/dev/vda2            2611       13054    83884735   83  Linux

这里显示硬盘总容量
107G
两块分区:
cda1和vda2

硬盘分区管理

[root@ecs-docker-test ~]# 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 table
Building a new DOS disklabel with disk identifier 0xc248b687.

Command (m for help): n          
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-209715199, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): 
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

注意:分区之后需要执行命令 partprobe
或者 重启服务器

删除分区

略...

硬盘格式化

命令:mkfs -t ext4 -c /dev/vda2

[root@crawlerdev deploy]# mkfs -t ext4 -c /dev/vda2
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
5242880 inodes, 20971183 blocks
1048559 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
640 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, 20480000

Checking for bad blocks (read-only test): done                                
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

格式化磁盘报错

mkfs.ext3:inode_size (128) * inodes_count (0) too big for a

filesystemwith 0 blocks, specify higher inode_ratio (-i)

orlower inode count (-N).

网路上接思路都是扩展分区和主分区的思路

有时候也可能是硬盘分区之后,机器没有识别
需要重启之后才能继续格式化新分区

挂载硬盘

[root@crawlerdev deploy]# mount /dev/vda2 /deploy/
[root@crawlerdev deploy]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        20G   20G     0 100% /
tmpfs           1.9G     0  1.9G   0% /dev/shm
/dev/vda2        79G  184M   75G   1% /deploy


自动挂载

https://www.cnblogs.com/zishengY/p/7137671.html

后续

一般生产环境会由运维操作
开发环境如果不熟悉Linux系统 不建议自己操作1


  1. 参考资料:(https://blog.csdn.net/qq_35036995/article/details/80532351)
    参考资料:https://blog.csdn.net/Field_Yang/article/details/65633317
    https://blog.csdn.net/openn/article/details/9856451 ↩︎

你可能感兴趣的:(linux)