安装好后打开树莓派
执行fdisk -l

root@raspberrypi:~# fdisk -l
Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram1: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram2: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram3: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram4: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram5: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram6: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram7: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram8: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram9: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram10: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram11: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram12: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram13: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram14: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram15: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mmcblk0: 29.72 GiB, 31914983424 bytes, 62333952 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: 0x57f003b7

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1         8192  1056767  1048576  512M  b W95 FAT32
/dev/mmcblk0p2      1056768 62333951 61277184 29.2G 83 Linux


Disk /dev/sda: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: Generic SATA    
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

这里/dev/sda就是我的128g ssd了

开始格式化文件系统

sudo apt-get install e2fsprogs
root@raspberrypi:~# sudo mkfs.ext4 /dev/sda
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done                            
Creating filesystem with 31258710 4k blocks and 7815168 inodes
Filesystem UUID: 608e90cd-94ae-4fe1-a095-620641a5c923
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done

开始挂载目录/www,因为之前有数据,所以根据ai说的来先备份再挂载

如果您想要将新格式化的分区挂载到现有的/www目录,同时保留/www目录中的文件,您需要先将/www目录中的文件移动到安全的位置,然后挂载新分区,最后将文件移回挂载点。以下是详细步骤:

  1. 备份/www目录中的文件
    在挂载新分区之前,您需要将/www目录中的所有文件移动到一个临时位置,以防止它们在挂载过程中被覆盖。例如,您可以将文件移动到/tmp/www_backup

    sudo mkdir /tmp/www_backup
    sudo mv /www/* /tmp/www_backup/
  2. 挂载新分区
    假设您的新分区是/dev/sda1,并且已经格式化为ext4文件系统,您可以使用以下命令将其挂载到/www

    sudo mount /dev/sda /www
  3. 将文件移回/www
    挂载新分区后,您可以将之前备份的文件移回/www

    sudo mv /tmp/www_backup/* /www/
    sudo rmdir /tmp/www_backup
  4. 设置自动挂载(可选):
    如果您希望在系统启动时自动挂载这个分区,您需要编辑/etc/fstab文件。在编辑之前,请确保您了解每个字段的含义,并且正确地指定了设备和挂载点。以下是一个示例条目:

    /dev/sda1 /www ext4 defaults 0 0

    在编辑/etc/fstab之后,您可以使用mount -a命令来测试配置是否正确,而不会重启系统:

    sudo mount -a

    如果没有错误消息,说明配置正确。

请注意,这些操作需要root权限,因此请确保您使用sudo来执行这些命令。此外,在执行任何操作之前,请确保您已经备份了所有重要数据,以防止意外数据丢失。

通过finalshell观察到挂载已成功

image.png

Last modification:May 15, 2024
如果觉得我的文章对你有用,请随意赞赏