一、查看磁盘挂载情况
df -TH
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 126G 0 126G 0% /dev
tmpfs tmpfs 126G 0 126G 0% /dev/shm
tmpfs tmpfs 126G 896K 126G 1% /run
tmpfs tmpfs 126G 0 126G 0% /sys/fs/cgroup
/dev/vda1 ext4 99G 3.0G 91G 4% /
tmpfs tmpfs 26G 0 26G 0% /run/user/0
/dev/vdb1 ext4 148G 2.1G 138G 2% /opt
二、查看所有磁盘
fdisk -l
//查看所有磁盘,包括未格式化分区的磁盘
Disk /dev/vda: 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: 0x000b4cb4
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 209713151 209711104 100G 83 Linux
Disk /dev/vdb: 150 GiB, 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
Disklabel type: dos
Disk identifier: 0xa55bb94f
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 314572799 314570752 150G 83 Linux
三、创建磁盘分区
fdisk /dev/vdb1
Welcome to fdisk (util-linux 2.28).
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 0x7cd397be.
Command (m for help): m
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
# n 新建分区
Command (m for help): n
# 这里输入e即分为逻辑分区,按p即分为主分区,我们要将这块盘分为主分区,输入p
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
# 到这里输入该主分区为第几个主分区,由于是新盘我们输入1来分第一个主分区
Partition number (1-4, default 1): 1
First sector (2048-1610612735, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-1610612735, default 1610612735):
Created a new partition 1 of type 'Linux' and of size 768 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
四、格式化分区磁盘
//将分区格式化
mkfs -t ext4 /dev/vdb1
mke2fs 1.42.11 (09-Jul-2014)
Creating filesystem with 201326336 4k blocks and 50331648 inodes
Filesystem UUID: 437a2c79-1d95-4702-9e0f-3a6ed8511782
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
五、挂载
//挂载 mount 分区 挂载目录
mount /dev/vdb1 /opt
或者
mount 10.50.1.118:/vol/dongvol108 /seastest
//如果想每次系统重启都能自动挂载该分区可修改/etc/fstab文件,在最后加入:/dev/vdb1 /opt ext3 defaults 1 2 (格式说明:/dev/vdb1 代表哪个分区, /opt是挂载目录, ext3是该分区的格式,defaults 是挂载时所要设定的参数(只读,读写,启用quota等),输入defaults包括的参数有(rw、dev、exec、auto、nouser、async) ,1是使用dump是否要记录,0是不要。 2是开机时检查的顺序,是boot系统文件就为1,其他文件系统都为2,如不要检查就为0)
六、卸载
//卸载 unmount 设备文件名或挂载点
umount 10.50.1.118:/vol/dongvol108
七、查看挂载权限
//查看挂载点的读写权限
mount
/dev/vdb1 on /opt type ext4 (rw,relatime,data=ordered)
网友评论