题目:
1.给linux系统添加一块新硬盘
2.对该硬盘进行分区
3.格式化 xfs
4. 在/mnt中创建目录nvme1
5.将新增的分区 挂在到该目录
1)创建新硬盘
把虚拟机关机了,进入编辑页面
点击“添加”按钮
无脑下一步
这里推荐选这个,利于文件管理
搞完后点击“确定”即可
搞完后打开虚拟机看看有没有添加成功:使用lslbk命令(加上-p参数可以看到其决定路劲)
2)分区
#注意:gdisk命令针对GPT分区格式,若在MBR分区格式下进行添加分区,则所有数据会全部丢失,切记:一块新增的硬盘中fdisk与gdisk不能混用#找不到新增硬盘可以使用liblk命令查看(使用-p参数可以看到绝对路径)[root@HeHe dev]# fdisk /dev/nvme0n2Welcome to fdisk (util-linux 2.37.4).
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 0x9d819ff1.Command (m for help): m #m打开帮助手册Help:DOS (MBR)a toggle a bootable flagb edit nested BSD disklabelc toggle the dos compatibility flagGenericd delete a partitionF list free unpartitioned spacel list known partition typesn add a new partitionp print the partition tablet change a partition typev verify the partition tablei print information about a partitionMiscm print this menuu change display/entry unitsx extra functionality (experts only)ScriptI load disk layout from sfdisk script fileO dump disk layout to sfdisk script fileSave & Exitw write table to disk and exitq quit without saving changesCreate a new labelg create a new empty GPT partition tableG create a new empty SGI (IRIX) partition tableo create a new empty DOS partition tables create a new empty Sun partition tableCommand (m for help): n#添加新分区
Partition typep primary (0 primary, 0 extended, 4 free)e extended (container for logical partitions)
Select (default p): #回车,使用默认主分区
Partition number (1-4, default 1):#回车,使用默认分区号1
First sector (2048-41943039, default 2048):#回车,设置分区起始位置2048
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039): +3G #设置分区大小为3GCreated a new partition 1 of type 'Linux' and of size 3 GiB.Command (m for help): w #保存退出
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.[root@HeHe dev]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 10.3G 0 rom
nvme0n1 259:0 0 20G 0 disk
├─nvme0n1p1 259:1 0 600M 0 part /boot/efi
├─nvme0n1p2 259:2 0 1G 0 part /boot
└─nvme0n1p3 259:3 0 18.4G 0 part├─rhel-root 253:0 0 16.4G 0 lvm /└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
nvme0n2 259:4 0 20G 0 disk
└─nvme0n2p1 259:6 0 3G 0 part
3) 格式化
#格式化新硬盘后才能挂载(做系统文件)
#mkfs再tab两下会列出所有文件系统
[root@HeHe dev]# mkfs.xfs /dev/nvme0n2p1
meta-data=/dev/nvme0n2p1 isize=512 agcount=4, agsize=196608 blks= sectsz=512 attr=2, projid32bit=1= crc=1 finobt=1, sparse=1, rmapbt=0= reflink=1 bigtime=1 inobtcount=1 nrext64=0
data = bsize=4096 blocks=786432, imaxpct=25= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=16384, version=2= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
4、5)挂载
[root@HeHe dev]# mkdir /mnt/nvme1
[root@HeHe dev]# ls /mnt
hgfs nvme1
[root@HeHe dev]# ls /
afs boot dir1 file1 lib media opt root sbin sys usr
bin dev etc home lib64 mnt proc run srv tmp var
[root@HeHe dev]# mount /dev/nvme0n2p1 /mnt/nvme1/#查看磁盘的使用情况
[root@HeHe dev]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 872M 0 872M 0% /dev/shm
tmpfs 349M 7.1M 342M 3% /run
/dev/mapper/rhel-root 17G 4.4G 12G 27% /
/dev/nvme0n1p2 960M 296M 665M 31% /boot
/dev/nvme0n1p1 599M 7.1M 592M 2% /boot/efi
tmpfs 175M 52K 175M 1% /run/user/42
tmpfs 175M 36K 175M 1% /run/user/0
/dev/nvme0n2p1 3.0G 54M 2.9G 2% /mnt/nvme1