显示磁盘空间使用情况
df -h
df -h 命令的输出显示了文件系统的磁盘空间使用情况。
这里 /dev/nvme0n1p1 设备(大小为 880GB)已经被挂载到 /media/nvidia/SSD 目录下,并且使用了 304GB,剩余 532GB,使用率为 37%。这意味着 /dev/nvme0n1 已经被格式化并且在使用中,挂载点是 /media/nvidia/SSD。
如果你想重新格式化 /dev/nvme0n1p1,首先需要卸载这个挂载点。可以使用以下命令卸载:
umount /media/nvidia/SSD
在卸载之后,你就可以安全地格式化这个设备了。再次运行 mkfs -t ext4 /dev/nvme0n1p1 来创建新的 ext4 文件系统。但请注意,这将删除该设备上的所有数据。
sudo mkfs -t ext4 /dev/nvme0n1
./copy_rootfs.sh /dev/xxx,xxx为外部存储设备
把nvme_config.sh文件copy到设备中
chmod +x给脚本文件添加可执行权限
执行sudo ./nvme_config.sh
重启设备
系统启动后后,执行df -h观察/目录是否在外部存储介质中
copy_rootfs.sh文件
#!/bin/bash
parted_dev=""
mount_dev=""
umount_dev=""
function Usag()
{
echo "usag: "
echo " copy_rootfs.sh /dev/sda"
echo " copy_rootfs.sh /dev/nvme0n1"
echo " copy_rootfs.sh /dev/mmcblk0"
}
if [ $# -ne 1 ];then
Usag
exit
fi
if [[ $1 =~ "/dev/sd" ]];then
parted_dev="$1"
mount_dev="$11"
elif [[ $1 =~ "/dev/nvme0n1" ]];then
parted_dev="$1"
mount_dev="$1p1"
elif [[ $1 =~ "/dev/mmcblk" ]];then
parted_dev="$1"
mount_dev="$1p1"
else
Usag
exit
fi
umount_dev=`ls $parted_dev*`
for var in $umount_dev
do
echo "nvidia" | sudo -S umount $var
done
echo "nvidia" | sudo -S parted -s $parted_dev mklabel gpt;
if [ $? -ne 0 ];then
echo "error: mklable gpt."
exit
fi
echo "nvidia" | sudo -S parted -s $parted_dev mkpart primary 2048s 100%;
if [ $? -ne 0 ];then
echo "error: mkpart primary."
exit
fi
echo "nvidia" | sudo -S mkfs.ext4 -F $mount_dev;
if [ $? -ne 0 ];then
echo "error: mkfs.ext4."
exit
fi
echo "nvidia" | sudo -S mount $mount_dev /mnt;
if [ $? -ne 0 ];then
echo "error: mount"
exit
fi
echo "nvidia" | sudo -S rsync -aAXv / --exclude={"/dev/","/proc/","/sys/","/tmp/","/run/user/","/mnt/","/media/*","/lost+found"} /mnt;
if [ $? -ne 0 ];then
echo "error: rsync error, pleas check file"
exit
fi
echo "nvidia" | sudo -S umount $mount_dev
if [ $? -ne 0 ];then
echo "error: umount"
exit
fi
exit
nvme_config.sh文件
#!/bin/bash
sudo mv /boot/extlinux/extlinux.conf /boot/extlinux/extlinux.conf.b
cat >> /boot/extlinux/extlinux.conf << HERE
TIMEOUT 30
DEFAULT primary
MENU TITLE L4T boot options
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
#FDT /boot/dtb/kernel_tegra234-p3701-0004-p3737-0000.dtb
INITRD /boot/initrd
APPEND ${cbootargs} root=/dev/nvme0n1p1 rw rootwait rootfstype=ext4 mminit_loglevel=8 console=ttyTCU0,115200 console=ttyAMA0,115200 console=tty0 firmware_class.path=/etc/firmware fbcon=map:0 net.ifnames=0
# When testing a custom kernel, it is recommended that you create a backup of
# the original kernel and add a new entry to this file so that the device can
# fallback to the original kernel. To do this:
#
# 1, Make a backup of the original kernel
# sudo cp /boot/Image /boot/Image.backup
#
# 2, Copy your custom kernel into /boot/Image
#
# 3, Uncomment below menu setting lines for the original kernel
#
# 4, Reboot
# LABEL backup
# MENU LABEL backup kernel
# LINUX /boot/Image.backup
# FDT /boot/dtb/kernel_tegra234-p3701-0004-p3737-0000.dtb
# INITRD /boot/initrd
# APPEND ${cbootargs}
HERE