背景:根目录磁盘空间太小,如果存放数据,很容易满,导致系统文件无法安装
Filesystem Size Used Avail Use% Mounted on
udev 94G 0 94G 0% /dev
tmpfs 19G 2.7M 19G 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 98G 36G 58G 39% /
tmpfs 94G 8.0K 94G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 94G 0 94G 0% /sys/fs/cgroup
/dev/sda2 1.5G 210M 1.2G 16% /boot
/dev/loop0 62M 62M 0 100% /snap/core20/1328
/dev/sda1 1.1G 6.1M 1.1G 1% /boot/efi
/dev/loop1 92M 92M 0 100% /snap/lxd/24061
/dev/loop3 68M 68M 0 100% /snap/lxd/21835
/dev/loop2 41M 41M 0 100% /snap/snapd/20092
tmpfs 19G 0 19G 0% /run/user/1001
/dev/loop4 64M 64M 0 100% /snap/core20/2015
tmpfs 19G 0 19G 0% /run/user/0
1、使用 lsblk 查看物理盘情况
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 61.9M 1 loop /snap/core20/1328
loop1 7:1 0 91.9M 1 loop /snap/lxd/24061
loop2 7:2 0 40.9M 1 loop /snap/snapd/20092
loop3 7:3 0 67.2M 1 loop /snap/lxd/21835
loop4 7:4 0 63.5M 1 loop /snap/core20/2015
sda 8:0 0 223.1G 0 disk
├─sda1 8:1 0 1.1G 0 part /boot/efi
├─sda2 8:2 0 1.5G 0 part /boot
└─sda3 8:3 0 220.5G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 100G 0 lvm /
sdb 8:16 0 1.8T 0 disk
├─sdb1 8:17 0 1.9G 0 part
├─sdb2 8:18 0 1K 0 part
├─sdb5 8:21 0 190.8G 0 part
└─sdb6 8:22 0 1.6T 0 part
sdc 8:32 0 1.8T 0 disk
2、选择没有挂载点的磁盘,进行初始化
mkfs.ext4 /dev/sdc
3、创建目录,将磁盘挂载到该目录下
mkdir /data/ssd0
mount /dev/sdc /data/ssd0
4、查看磁盘uuid
ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 Sep 27 17:43 34c99dcc-b970-48f5-bca6-6b20c7a83232 -> ../../sda2
lrwxrwxrwx 1 root root 10 Sep 27 17:43 40E4-D3BE -> ../../sda1 vim /etc/fstab
lrwxrwxrwx 1 root root 10 Sep 27 17:43 807bf2c1-21d7-4d0b-bed4-7e2e2ed79a81 -> ../../dm-0
lrwxrwxrwx 1 root root 9 Oct 8 10:50 c2e21175-4028-4ed7-8625-af058202aeb1 -> ../../sdc
lrwxrwxrwx 1 root root 10 Sep 27 17:43 d2502ee5-50fb-4448-8c47-af415d35098f -> ../../sdb1
5、配置该挂载永久生效,不受重启影响
vim /etc/fstab
/dev/disk/by-id/dm-uuid-LVM-NK23j4PvVweDXf8F55LNkeLK88yg9JJ84VqzymlsCAgzCcR8xRpNK4t7XrcFRHr3 / ext4 defaults 0 1
# /boot was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/34c99dcc-b970-48f5-bca6-6b20c7a83232 /boot ext4 defaults 0 1
# /boot/efi was on /dev/sda1 during curtin installation
/dev/disk/by-uuid/40E4-D3BE /boot/efi vfat defaults 0 1
/swap.img none swap sw 0 0
/dev/disk/by-uuid/c2e21175-4028-4ed7-8625-af058202aeb1 /data/ssd0 ext4 defaults 0 1
6、查看挂载结果
df -h
挂载成功,可在该目录下存放大量数据
Filesystem Size Used Avail Use% Mounted on
udev 94G 0 94G 0% /dev
tmpfs 19G 2.7M 19G 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 98G 36G 58G 39% /
tmpfs 94G 8.0K 94G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 94G 0 94G 0% /sys/fs/cgroup
/dev/sda2 1.5G 210M 1.2G 16% /boot
/dev/loop0 62M 62M 0 100% /snap/core20/1328
/dev/sda1 1.1G 6.1M 1.1G 1% /boot/efi
/dev/loop1 68M 68M 0 100% /snap/lxd/21835
/dev/loop2 44M 44M 0 100% /snap/snapd/14978
tmpfs 19G 0 19G 0% /run/user/1001
tmpfs 19G 0 19G 0% /run/user/0
/dev/sdc 1.8T 28K 1.7T 1% /data/ssd0