linux机器分区及挂载mount点

对新机器分区,及挂载mount点:新机器分区中有很大空间未分配,可以用来做存储:

/dev/vda大小为161.1 GB,已有分区/dev/vda1大小是8G,剩余152G未分区,进行分区,且挂载到新建mount点/data上。

1、[root@host-10-20-16-27 /]# fdisk -l
Disk /dev/vda: 161.1 GB, 161061273600 bytes, 314572800 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: 0x000b2f10


   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    16777215     8387584   83  Linux


2、分区:/dev/vda盘是161G,/dev/vda1大小是8G,把剩余的空间分给一个新区的操作如下:
把/dev/vda剩下的盘进行分区,执行fdisk  /dev/vda,然后执行n是新增一个分区,点p,如果剩余存储都给该分区,则后面就enter即可,最后w写入;
[root@host-10-20-16-27 /]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.23.2).

Select (default p): 
Using default response p
Partition number (2-4, default 2): 
First sector (16777216-314572799, default 16777216): 
Using default value 16777216
Last sector, +sectors or +size{K,M,G} (16777216-314572799, default 314572799): 
Using default value 314572799
Partition 2 of type Linux and of size 142 GiB is set


Command (m for help): 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.




分区成功:
[root@host-10-20-16-27 /]# fdisk -l


Disk /dev/vda: 161.1 GB, 161061273600 bytes, 314572800 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: 0x000b2f10


   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    16777215     8387584   83  Linux
/dev/vda2        16777216   314572799   148897792   83  Linux







3、
遇到的问题:格式化新的分区时,有下面的报错:
Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    16777215     8387584   83  Linux
/dev/vda2        16777216   314572799   148897792   83  Linux

[root@host-10-20-16-28 /]# mkfs  -t  ext4  /dev/vda2
mke2fs 1.42.9 (28-Dec-2013)
Could not stat /dev/vda2 --- No such file or directory
The device apparently does not exist; did you specify it correctly?
其实该磁盘是有的,可是报错不存在:

解决方法:
执行下partprobe 命令
查看是否安装该命令:
[root@db1 dev]# rpm -q parted
parted-1.8.1-23.el5
然后直接执行:
partprobe,下面再执行下格式化就OK了:

 mkfs  -t ext4  /dev/vda2
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
9306112 inodes, 37224448 blocks
1861222 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2185232384
1136 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, 23887872


Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done     


 /etc/fstab文件中写入要挂载的信息:
mount点是/data
/dev/vda2    /data ext4   defaults   0  0
执行mount -a
然后查看下面就有该mount点了:
[root@host-10-20-16-28 /]# df -h  |grep data
/dev/vda2       140G   61M  133G   1% /data

其中问题解决方法的相关链接是https://blog.csdn.net/zhangdaiscott/article/details/50057155



猜你喜欢

转载自blog.csdn.net/xiaofang2015/article/details/80496584