ubuntu22.04磁盘挂载(多磁盘和单磁盘挂载)
多磁盘挂载到同一个目录
# 如果没有安装逻辑卷管理系统工具
sudo apt install lvm2
# 查看磁盘分区
sudo fdisk -l
# 新建物理卷
sudo pvcreate /dev/nvme0n1 /dev/nvme1n1
# 查看现有物理卷信息
sudo pvdisplay
# 新建物理卷
sudo vgcreate dnyjy_vg /dev/nvme0n1 /dev/nvme1n1
# 新建逻辑卷
sudo lvcreate -n dnyjy_lv -l 100%FREE dnyjy_vg
user@user:~$ sudo lvcreate -n dnyjy_lv -l 100%FREE dnyjy_vg
Logical volume "dnyjy_lv" created.
user@user:~$ sudo fdisk -l
Disk /dev/loop0: 59.75 MiB, 62652416 bytes, 122368 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
Disk /dev/loop1: 59.77 MiB, 62676992 bytes, 122416 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
Disk /dev/loop2: 77.38 MiB, 81137664 bytes, 158472 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
Disk /dev/loop3: 33.71 MiB, 35344384 bytes, 69032 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
Disk /dev/nvme0n1: 1.75 TiB, 1920383410176 bytes, 3750748848 sectors
Disk model: RP2A21T9RK004LX
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/nvme1n1: 1.75 TiB, 1920383410176 bytes, 3750748848 sectors
Disk model: RP2A21T9RK004LX
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 893.75 GiB, 959656755200 bytes, 1874329600 sectors
Disk model: MR9560-8i
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: gpt
Disk identifier: 510C23CC-F528-412B-940F-9E9C4553B9DA
Device Start End Sectors Size Type
/dev/sda1 2048 2203647 2201600 1G EFI System
/dev/sda2 2203648 4300799 2097152 1G Linux filesystem
/dev/sda3 4300800 1874327551 1870026752 891.7G Linux filesystem
Disk /dev/mapper/dnyjy_vg-dnyjy_lv: 3.49 TiB, 3840757727232 bytes, 7501479936 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
# 格式化分区 ext4
sudo mkfs.ext4 /dev/mapper/dnyjy_vg-dnyjy_lv
user@user:~$ sudo mkfs.ext4 /dev/mapper/dnyjy_vg-dnyjy_lv
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done
Creating filesystem with 937684992 4k blocks and 234422272 inodes
Filesystem UUID: dbbfcfd7-7162-4ed6-9dab-13cdac888a27
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
# 挂载到目录
sudo mount /dev/mapper/dnyjy_vg-dnyjy_lv /home/
# 查看
df -h
# 在/etc/fstab末尾添加挂载信息,实现自动挂载:
sudo vi /etc/fstab
/dev/mapper/dnyjy_vg-dnyjy_lv ext4 defaults 0 0
单磁盘挂载
sudo fdisk -l
sudo mkfs -t ext4 /dev/nvme0n1
sudo mount -t ext4 /dev/nvme0n1 /home
sudo vim /etc/fstab 文本最后增加“/dev/nvme0n1 /home ext4 defaults 0 0”
备注:如果重复以上步骤挂载第二块磁盘,那第一个挂载的磁盘会被覆盖,通过df -h可查看到