Linux下磁盤掛載

1.查看是否已分配node

[root@localhost ~]# fdisk -lide

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..net

二、發現有磁盤,路徑爲/dev/vda。而後使用fdisk命令進行分區orm

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

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').ip

Command (m for help): pci

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.it

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表示分區號,因爲一、2號已經分區全部從3號分區開始

其中 n 新建分區 d刪除分區 p打印分區 w將表寫入磁盤保存並退出

三、而後使用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

相關文章
相關標籤/搜索