码迷,mamicode.com
首页 > 系统相关 > 详细

Linux下磁盘挂载

时间:2019-01-20 23:33:25      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:ready   pre   新建   localhost   设备   cte   start   imu   inf   

1.查看是否已分配

[root@localhost ~]# fdisk -l

Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062b97

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018       41611    20458496   8e  Linux LVM
Partition 2 does not end on cylinder boundary.

2、发现有磁盘,路径为/dev/vda。然后使用fdisk命令进行分区

[root@localhost ~]# fdisk /dev/vda

WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to
         switch off the mode (command ‘c‘) and change display units to
         sectors (command ‘u‘).

Command (m for help): p

Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062b97

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018       41611    20458496   8e  Linux LVM
Partition 2 does not end on cylinder boundary.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1-1040253, default 1): 41611
Last cylinder, +cylinders or +size{K,M,G} (41611-1040253, default 1040253): 665776

Command (m for help): p

Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062b97

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018       41611    20458496   8e  Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3           41611      665776   314579584   83  Linux

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (1-1040253, default 1): 4
Sector 3024 is already allocated
First cylinder (665777-1040253, default 665777): 665777
Last cylinder, +cylinders or +size{K,M,G} (665777-1040253, default 1040253):
Using default value 1040253

Command (m for help): p

Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062b97

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018       41611    20458496   8e  Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3           41611      665776   314579584   83  Linux
/dev/vda4          665777     1040253   188736408   83  Linux

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: 设备或资源忙.
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.

解释:

Partition number表示分区号,由于1、2号已经分区所有从3号分区开始

其中 n 新建分区 d删除分区 p打印分区 w将表写入磁盘保存并退出

3、然后使用fdisk -l 命令查看,已经新建的分区

[root@localhost ~]# fdisk -l

Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062b97

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018       41611    20458496   8e  Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3           41611      665776   314579584   83  Linux
/dev/vda4          665777     1040253   188736408   83  Linux

红色部分为刚刚新建的分区

6.建好分区后对分区进行格式化,建立文件系统 mkfs.ext3

[root@localhost ~]# mkfs.ext3 /dev/vda3
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
19668992 inodes, 78644896 blocks
3932244 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
2401 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, 71663616

正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost ~]# mkfs.ext3 /dev/vda4
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
11796480 inodes, 47184102 blocks
2359205 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
1440 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

正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

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


7.然后mount选择一个挂载点挂上

[root@localhost ~]# mount /dev/vda3 /var
[root@localhost ~]# mount /dev/vda4 /opt

8.使用 df -TH  查看文件大小


[root@localhost ~]# df -TH /opt
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/vda4      ext3  191G  197M  181G   1% /opt
[root@localhost ~]# df -TH /var
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/vda3      ext3  318G  201M  301G   1% /var

注意:

如果挂载错误可以使用umount取消挂载,如果找不到分区使用partprobe 刷新分区实在不行就reboot下

使用fdisk -l即可查看新的分区

 

来源:https://blog.csdn.net/scmrpu/article/details/86498961

Linux下磁盘挂载

标签:ready   pre   新建   localhost   设备   cte   start   imu   inf   

原文地址:https://www.cnblogs.com/thatme/p/10296563.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!