查看磁盘现状(parted 命令):

ls /dev/sd*
sudo parted -l | grep Disk | grep sd
sudo parted -l | grep Disk | grep sd |wc -l
sudo parted -l
root@hx2:~# sudo parted -l | grep Disk | grep sd
Error: /dev/sda: unrecognised disk label
Disk /dev/sda: 1000GB
Disk /dev/sdb: 128GB


root@hx2:~# ls /dev/sd*
/dev/sda  /dev/sdb  /dev/sdb1  /dev/sdb2  /dev/sdb5


root@hx2:~# sudo parted -l | grep Disk | grep sd |wc -l
Error: /dev/sda: unrecognised disk label
2


root@hx2:~# sudo parted -l
Error: /dev/sda: unrecognised disk label
Model: ATA ST1000LM048-2E71 (scsi)                                        
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags: 

Model: ATA PLEXTOR PX-128M6 (scsi)
Disk /dev/sdb: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type      File system  Flags
 1      1049kB  512MB  511MB  primary   ext2         boot
 2      513MB   128GB  128GB  extended
 5      513MB   128GB  128GB  logical                lvm


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/hx2--vg-swap_1: 17.1GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system     Flags
 1      0.00B  17.1GB  17.1GB  linux-swap(v1)


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/hx2--vg-root: 110GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End    Size   File system  Flags
 1      0.00B  110GB  110GB  ext4

格式化磁盘

mkfs.ext4 -F /dev/sda

实操:

root@hx2:~# mkfs.ext4 -F /dev/sda
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 244190646 4k blocks and 61054976 inodes
Filesystem UUID: 71571e4b-b6b8-4be7-999e-af736bef922f
Superblock backups stored on blocks: 
     32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
     4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
     102400000, 214990848

Allocating group tables: 完成                            
正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成     

创建挂载目录,并挂载磁盘:

mkdir /opt/data

mount /dev/sda /opt/data

检查挂载情况:

root@hx2:~# df -h
Filesystem                Size  Used Avail Use% Mounted on
udev                      7.8G     0  7.8G   0% /dev
tmpfs                     1.6G   33M  1.6G   3% /run
/dev/mapper/hx2--vg-root  102G   31G   66G  32% /
tmpfs                     7.8G     0  7.8G   0% /dev/shm
tmpfs                     5.0M     0  5.0M   0% /run/lock
tmpfs                     7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/sdb1                 472M  211M  237M  48% /boot
tmpfs                     1.6G     0  1.6G   0% /run/user/1000
/dev/sda                  917G   72M  871G   1% /opt/data

搞定!

最后一步:添加挂载信息(服务器重启后自动挂载磁盘)

vim /etc/fstab

将以下内容加入fastab:

/dev/sda /opt/data ext4 defaults,noatime,nodiratime 0 0

2023-11-07T08:38:31.png

保存退出,搞定! 

标签: 磁盘挂载

添加新评论