当前位置:网站首页>Add a new cloud disk to Huawei virtual machine

Add a new cloud disk to Huawei virtual machine

2022-07-05 12:34:00 just4you

background

Have been borrowing a friend's Huawei virtual machine , System disk only 40G, Small as it is , But only run some simple test programs , That's enough. .
Log in to the virtual machine console today to adjust the configuration , I found another 100G My cloud disk has been empty ...... Still too young !!

Add hard disk

View disk information

Use command "fdisk -l" View disk information .
 Insert picture description here
You can see 100G Cloud disk , No partition yet .

Linux Partition format description : /dev/vda,/dev/vdb, /dev/vda1

  1. vd: Represents the type of hard disk . This shows vd( Virtual machine , I guess it is. VirtualDisk Abbreviation ). There are other sd(SCSI Hard disk )、hd( Ordinary hard disk ) And so on .
  2. a,b: vd In the heel a or b, Indicates the serial number of the hard disk , The first hard disk a, The second hard disk b. Here, cloud disk is the second hard disk , So show b. If there is a hard disk , Should be c 了 .
  3. Numbers 1: It's the partition number . According to the picture above :/dev/vda The system disk has only one partition ,/dev/vdb There are currently no partitions , So its partition list is empty .

Yes /dev/vdb partition

Carry out orders "fdisk /dev/vdb", Ready to start partitioning .
 Insert picture description here

Partition operation

 Insert picture description here
explain :

  1. Primary partition (primary) You can create 4 individual . Because it uses a new disk , There is no primary partition , So the number of the main partition here is from 1 Start .
  2. Sector of partition , Because it is the first partition , So you can directly use the system default .
  3. Partition size , If not set , If you enter directly , Then the whole new disk will be used .

View the newly created partition

 Insert picture description here

Partition formatting

Use command “mkfs.ext4 /dev/vdb1" Format the partition .

Use “mkfs -t ext4 -c /dev/vdb1” It's fine too .
-t: Specify the partition format . Just remember ext4 Than ext3 All right .

 Insert picture description here

Mount new partition

Create a new directory & mount

mkdir /data/morefiles

mount /dev/vdb1 /data/morefiles

Be careful : If /data/morefiles There are documents in , After mounting , The original document is not visible ( It is equivalent to that the original folder points to the new disk location . After uninstalling , The original document is visible )

Unload command :umount /dev/vdb1

View the mounting effect

 Insert picture description here

Set up auto mount after power on

perform mount After the command mounts the new disk , If the server restarts , The mount will fail , Need to mount again .

Edit the file :/etc/fstab
Add the following :

/dev/vdb1	/data/morefiles	ext4 defaults 1 1

Parameter description :

  1. /dev/vdb1: Partition device file name or UUID
  2. /data/morefiles: Mount point
  3. ext4: file system name
  4. defaults: Mount parameters
  5. Partition is for dump Backup .0( No backup );1( Back up every day );2( Backup from time to time ). When choosing daily backup , You will find one in the directory “lost and found” Catalog , For backup .
  6. Whether it is fsck testing .0( Don't test ), Other numbers represent detection priority ( The smaller the number is. , The higher the priority )

problem

Sometimes the following prompt appears when saving formatted information :

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.

here , Try the command “partprobe” Solve . Or restart the server :)

原网站

版权声明
本文为[just4you]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140528011923.html