Skip to content

Instantly share code, notes, and snippets.

@ozero
Last active April 2, 2023 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozero/2f4612e1fbf1716fcfaa142717899c46 to your computer and use it in GitHub Desktop.
Save ozero/2f4612e1fbf1716fcfaa142717899c46 to your computer and use it in GitHub Desktop.

How to move root volume of this image

This image: Arch Linux Image for VisionFive 2

Author "cwt" briefly wrote below:

If you wish to mount NVMe as the root partition, please format it as btrfs and then create a subvolume with the desired name. Mount the path /mnt which already in the /etc/fstab (so just run mount /mnt as root), then use rsync to copy the contents of /mnt/arch-minimal to the new subvolume on the NVMe. Finally, edit the /boot/boot/extlinux/extlinux.conf and the /etc/fstab on the new subvolume.

But I'm totally noob to btrfs & Arch, so I'm going to write down detailed steps.

prerequisites

  • Buy usb serial cable & use TeraTerm etc to use serial console login
  • Buy NVMe M.2 SSD & Install
  • use 30w or over USB charger as power source

create volume on NVMe and rsync

# mount source subvolume on microSD
cd /mnt
mkdir /mnt/mmcblk1p3
mount /dev/mmcblk1p3 /mnt/mmcblk1p3
ls -la /mnt/mmcblk1p3/arch-minimal # make sure that you can see source subvolume

fdisk /dev/nvme0n1 # On NVMe, delete all partition, then Create new one partition, using fdisk
mkfs.btrfs /dev/nvme0n1p1 # format that partion as btrfs

# mount NVMe
mkdir /mnt/nvme0n1p1
mount /dev/nvme0n1p1 /mnt/nvme0n1p1
ls -la /mnt/nvme0n1p1 # make sure it's blank at this time

# copy from arch-minimal to NVMe
rsync -a /mnt/mmcblk1p3/arch-minimal/ /mnt/nvme0n1p1

# fix volume size
resize2fs /dev/nvme0n1p1

Edit extlinux.conf

# Add label to btrfs devices
btrfs filesystem label /mnt archroot # NVMe
btrfs filesystem label / archmicrosd # microSD
btrfs filesystem show --all-devices # make sure the volumes & labels

pacman -Si nano # install text editor

cd /boot/boot/extlinux
cp extlinux.conf extlinux-conf-bak # backup
nano extlinux.conf
  • content of extlinux.conf is here
## /boot/extlinux/extlinux.conf
##
## IMPORTANT WARNING
##
## The configuration of this file is generated automatically.
## Do not edit this file manually, use: u-boot-update

default Arch-cwt6-server
menu title U-Boot menu
prompt 0
timeout 50

label Arch-cwt6-server
        menu label Arch Linux 5.15.0-cwt6-server
        linux /boot/vmlinuz-5.15.0-cwt6-server
        initrd /boot/initrd.img-5.15.0-cwt6-server
        fdtdir /boot/dtbs/
        append root=LABEL=archroot rw console=tty0 console=ttyS0,115200 earlyconn rootwait stmmaceth=chain_mode:1

# rescue boot from microSD
label Arch-cwt6-server-single 
        menu label Arch Linux 5.15.0-cwt6-server (Single User Mode)
        linux /boot/vmlinuz-5.15.0-cwt6-server
        initrd /boot/initrd.img-5.15.0-cwt6-server
        fdtdir /boot/dtbs/
        append root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlyconn rootwait stmmaceth=chain_mode:1 rootflags=defaults,discard=async,compress=lzo,user_subvol_rm_allowed,subvol=arch-minimal single

label Arch-cwt6-desktop
        menu label Arch Linux 5.15.0-cwt6-desktop
        linux /boot/vmlinuz-5.15.0-cwt6-desktop
        initrd /boot/initrd.img-5.15.0-cwt6-desktop
        fdtdir /boot/dtbs/
        append root=LABEL=archroot rw console=tty0 console=ttyS0,115200 earlyconn rootwait stmmaceth=chain_mode:1

label Arch-cwt6-lowlatency
        menu label Arch Linux 5.15.0-cwt6-lowlatency
        linux /boot/vmlinuz-5.15.0-cwt6-lowlatency
        initrd /boot/initrd.img-5.15.0-cwt6-lowlatency
				fdtdir /boot/dtbs/
        append root=LABEL=archroot rw console=tty0 console=ttyS0,115200 earlyconn rootwait stmmaceth=chain_mode:1

Edit fstab (on NVMe)

cd /mnt/nvme0n1p1/etc
cp fstab fstab-bak # backup
nano fstab

content of /mnt/nvme0n1p1/etc/fstab is here

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <filesystem> <mount>  <type> <options>                                                                 <dump> <pass>
/dev/mmcblk1p2 /boot    vfat   defaults,discard                                                           0 2
/dev/nvme0n1p1  /        btrfs  defaults,discard=async,compress=lzo,user_subvol_rm_allowed,subvol=/       0 1
tmpfs          /tmp     tmpfs  defaults                                                                   0 0
tmpfs          /var/tmp tmpfs  defaults                                                                   0 0

Then reboot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment