Method steps for the Linux cloud server to mount a new disk

  • 2021-01-19 22:42:21
  • OfStack

background

1 new server in the company, mount a 2T hard disk, ssh login found not mounted, processing 1.

(don't want to go to baidu every time how to mount, or finishing 1)

Check the status


#  View disk status ,  Found to have 1 Block a new disk  /dev/vdb
fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006b766

  Device Boot   Start     End   Blocks  Id System
/dev/vda1  *      1    5222  41942016  83 Linux

Disk /dev/vdb: 2147.5 GB, 2147483648000 bytes
16 heads, 63 sectors/track, 4161015 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: 0xb9876eee

#  use  lsblk  To view 
[root@ecs-9054 tmp]# lsblk
NAME  MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda  252:0  0 40G 0 disk
 └ ─ vda1 252:1  0 40G 0 part /
vdb  252:16  0  2T 0 disk

#  Check the format 
[root@ecs-9054 tmp]# lsblk -f
NAME  FSTYPE LABEL UUID                 MOUNTPOINT
vda
 └ ─ vda1 ext4     e10f3c70-e806-4633-a7cb-3d5aa3d9df5e /
vdb

Partitioning and Formatting


#  Partitioning the data disk , According to the prompt ,  Please input : n, p, 1,  Press enter twice , wq
#  The input n Adding a new partition 
#  The input p New primary partition 
#  Specify the partition number and enter 1 Can be 
#  Specify the starting sector. Default is fine. Change is not recommended 
#  Specifies the end sector, which represents the partition size, and can be used K . M . G Specifies the partition size. Default allocates all 
fdisk /dev/vdb

#  Now we find that the new  /dev/vdb1
fdisk -l

#  Format Specified Partitions 
mkfs.ext4 /dev/vdb1

mount


#  Temporarily mount the partition ,  Failure after restart 
#  Mounted on the  /data  directory 
mount /dev/vdb1 /data

#  Cancel the mount 
# unmount /data

#  Permanent mount :  Writes new partition information 
#  The first 1 A partition that needs to be mounted, such as /dev/sdb1
#  The first 2 Partition mount points, such as mount to /root/RepositoryDisk Under the 
#  The first 3 The partition format, and the format specified when formatting the partition yourself 1 to 
#  The first 4 A direct defaults Can, and the system maintained 1 to 
#  The first 5 And the system is maintained 1 , the input 0 Can be 
#  The first 6 And the system is maintained 1 , the input 0 Can be 
#
#  to  /etc/fstab  The file appends the following text 
echo /dev/vdb1 /data ext4 defaults,noatime 0 0 >> /etc/fstab


Related articles: