在Linux系统中,查看新增硬盘或硬盘使用情况可以通过多种命令实现。以下是一些常用的方法:
/dev
目录下,每个硬盘通常对应一个设备文件,如/dev/sda
。lsblk
命令lsblk
(List Block Devices)命令可以列出所有块设备及其相关信息,包括新增的硬盘。
lsblk
输出示例:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part /
sdb 8:16 0 100G 0 disk
在这个例子中,sdb
是新增的硬盘。
fdisk -l
命令fdisk
是一个磁盘分区工具,通过-l
选项可以列出所有磁盘及其分区表。
sudo fdisk -l
输出示例:
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0x0009f3e0
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 2099199 2097152 1 fat32
/dev/sda2 2099200 41943039 39843840 83 linux
Disk /dev/sdb: 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: 0x00000000
在这个例子中,/dev/sdb
是新增的硬盘。
dmesg | grep sd
命令查看内核日志可以发现新硬件添加的信息。
dmesg | grep sd
输出示例:
[ 123.456789] sd 1:0:0:0: [sdb] 209715200 512-byte logical blocks: (100 GB/93 GiB)
[ 123.456789] sd 1:0:0:0: [sdb] Write Protect is off
[ 123.456789] sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
[ 123.456789] sd 1:0:0:0: [sdb] No Caching mode page present
[ 123.456789] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[ 123.456789] sdb: sdb1
[ 123.456789] sd 1:0:0:0: [sdb] Attached SCSI disk
原因:
解决方法:
fsck
工具检查和修复文件系统:fsck
工具检查和修复文件系统:原因:
解决方法:
fdisk
或gparted
对新硬盘进行分区:fdisk
或gparted
对新硬盘进行分区:通过以上方法,您可以有效地查看和管理Linux系统中的新增硬盘。
领取专属 10元无门槛券
手把手带您无忧上云