I tried this yesterday evening on Ubuntu 22.04:
# 1. Install using customized image & packages
cd ~/tmp
wget https://downloads.openwrt.org/releases/23.05.0-rc2/targets/apm821xx/sata/openwrt-imagebuilder-23.05.0-rc2-apm821xx-sata.Linux-x86_64.tar.xz
tar xJf openwrt-imagebuilder-23.05.0-rc2-apm821xx-sata.Linux-x86_64.tar.xz
cd openwrt-imagebuilder-23.05.0-rc2-apm821xx-sata.Linux-x86_64
# 2. Set rootfs image size to 990MB
sed -i -e '/CONFIG_TARGET_ROOTFS_PARTSIZE=/s/=.*$/=990/;' .config
# 3. Create install image
PACKAGES=" ... " # my custom packages list including samba4, rsyncd etc.
make image PROFILE="wd_mybooklive" PACKAGES="$PACKAGES" FILES="../files/" CONFIG_IPV6="n"
# 3. Write it to the harddisk temporarily connected to PC (sdc)
IMG=bin/targets/apm821xx/sata/openwrt-*-apm821xx-sata-mybooklive-squashfs-factory.img
DISK=/dev/sdc
sudo sgdisk -Z $DISK # destroy existing partition tables, just in case
gunzip $IMG.gz
sudo dd if="$IMG" of=$DISK bs=10M
sgdisk --mbrtogpt $DISK
sudo sgdisk --new 3::+512M --typecode 3:8200 --new 4:: --typecode 4:8300 $DISK
sudo sgdisk --change-name=3:Swap --change-name=4:Data $DISK
mkswap ${DISK}3
mkfs.ext4 -O bigalloc -C 65535 -m 0 -L Data -E lazy_itable_init=0,lazy_journal_init=0 -v /dev/sda4
# 4. Remove HDD from PC, attach to MBL board, power on
ssh root@openwrt
This worked fine and the HDD partition layout is now in GPT format (the install image was in MBR format).
Then I used LuCI to upload the sysupgrade image (same version) and performed a sysupgrade. The sysupgrade image was also in MBR format.
But after rebooting, the HDD partitioning was still in GPT format. And sda3
and sda4
also still existed and were detected and mounted.
So the harddisk cannot have been completely wiped.
My question is only, if I can rely on this behaviour in the future?