Skip to content

Hard Drive ​

The AI Pod comes with a solid-state drive in version 1T by default. However, the AI Pod has two pcie4 interfaces, allowing you to replace the hard drive according to your needs.

Replacing the Hard Drive ​

  1. Copy the data from the removed hard drive to the new one (the original drive contains some model data and the AI Pod client).
  2. Replace the new hard drive.

Warning

When replacing the hard drive, ensure that the mount path in /etc/fstab is correctly configured; otherwise, the system will not boot properly.

The following is an example, where the solid-state drive is mounted to the /ssd directory.

UUID=942a4d75-e509-4fa2-8d3a-23cb6925b68c /ssd ext4 defaults 0 2
/ssd/home /home none bind 0 0

Migrate the System to SSD ​

In the current AI Pod system, the system is running on a 64G emmc storage, while docker and home are on SSD storage. You can follow the commands below to migrate the system to SSD.

  1. /ssd Directory

This directory is the mounted path for the current 1T SSD drive. You can see directories such as docker, home, and lzc-ai-agent here.

  1. Copy the current system to the NVMe drive. Assume your NVMe drive is nvme0n1p1.
sudo mount /dev/nvme0n1p1 /mnt
sudo rsync -axHAWX --numeric-ids --info=progress2 --exclude={"/dev/","/proc/","/sys/","/tmp/","/run/","/mnt/","/media/*","/lost+found", "/ssd/", "/home/"} / /mnt

sudo mkdir -p /mnt/ssd # 迁移之前的 /ssd 到新的目录

sudo systemctl stop lzc-ai-agent
sudo systemctl stop docker
systemctl stop nvzramconfig
systemctl disable nvzramconfig

mkdir -p /mnt/ssd
mv /mnt/docker /mnt/ssd/
mv /mnt/lzc-ai-agent /mnt/ssd/lzc-ai-agent
  1. Modify /etc/fstab

Comment out the lines related to /ssd/, and the updated /etc/fstab will look similar to the following text:

# /etc/fstab: static file system information.
#
# These are the filesystems that are always mounted on boot, you can
# override any of these by copying the appropriate line from this file into
# /etc/fstab and tweaking it as you see fit.  See fstab(5).
#
# <file system> <mount point>             <type>          <options>                               <dump> <pass>
/dev/root            /                     ext4           defaults                                     0 1
UUID=A9EE-ABCF /boot/efi vfat defaults 0 1
  1. Write /etc/systemd/system/setssdroot.service
[Unit]
Description=Change rootfs to SSD in M.2 key M slot (nvme0n1p1)
DefaultDependencies=no
Conflicts=shutdown.target
After=dev-nvme0n1p1.device
Requires=dev-nvme0n1p1.device
Before=shutdown.target
ConditionPathExists=/dev/nvme0n1p1
ConditionPathExists=/etc/setssdroot.conf
ConditionVirtualization=!container
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/setssdroot.sh
[Install]
WantedBy=default.target
  1. Write /sbin/setssdroot.sh
#!/bin/sh
# Runs at startup, switches rootfs to the SSD on nvme0 (M.2 Key M slot)
NVME_DRIVE="/dev/nvme0n1p1"
CHROOT_PATH="/nvmeroot"

INITBIN=/lib/systemd/systemd
EXT4_OPT="-o defaults -o errors=remount-ro -o discard"

modprobe ext4

mkdir -p ${CHROOT_PATH}
mount -t ext4 ${EXT4_OPT} ${NVME_DRIVE} ${CHROOT_PATH}

cd ${CHROOT_PATH}
/bin/systemctl --no-block switch-root ${CHROOT_PATH}
  1. Execute command
sudo chmod 777 /sbin/setssdroot.sh
systemctl daemon-reload
sudo systemctl enable setssdroot.service

sudo cp /etc/systemd/system/setssdroot.service /mnt/etc/systemd/system/setssdroot.service
sudo cp /sbin/setssdroot.sh /mnt/sbin/setssdroot.sh
sudo cp /etc/fstab /mnt/etc/fstab

sudo touch /etc/setssdroot.conf

/etc/setssdroot.conf is a marker file; the system will use the rootfs on NVMe only if this file exists. Therefore, if you need to switch to the emmc system, you can:

  • Unplug the NVMe drive
  • Manually mount the eMMC drive, then delete the /etc/setssdroot.conf file and restart
  1. Restart to take effect

Configure Swapfile ​

After migrating the system, restart the system. Running lsblk will show that the system is now running on NVMe. Configure the swapfile.

fallocate -l 32G /swapfile
mkswap /swapfile

Create a /etc/systemd/system/swapfile.swap file with the following content:

[Swap]
What=/swapfile

[Install]
WantedBy=swap.target

Execute the following command to start it.

systemctl daemon-reload
systemctl status swapfile.swap

systemctl enable swapfile.swap
systemctl start swapfile.swap

Fix apt man database error ​

# 修复权限
sudo chown -R man:root /var/cache/man
sudo chmod -R 755 /var/cache/man

# 重建数据库
sudo mandb