Skip to content

Commit

Permalink
expand working
Browse files Browse the repository at this point in the history
  • Loading branch information
pvizeli committed Apr 17, 2018
1 parent 281f262 commit 77293f5
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
3 changes: 1 addition & 2 deletions buildroot-external/board/ova/post-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ cp ${BOARD_DIR}/barebox-state.dtb ${BOOT_DATA}/EFI/barebox/state.dtb
hassio_boot_image ${BINARIES_DIR}
hassio_overlay_image ${BINARIES_DIR}

hassio_hdd_image ${BINARIES_DIR} ${BINARIES_DIR}/harddisk.img
hassio_hdd_image ${BINARIES_DIR} ${BINARIES_DIR}/harddisk.img 6

qemu-img resize ${BINARIES_DIR}/harddisk.img +6G
qemu-img convert -O vmdk ${BINARIES_DIR}/harddisk.img ${BINARIES_DIR}/hassio-os.vmdk
2 changes: 1 addition & 1 deletion buildroot-external/busybox.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Busybox version: 1.27.2
# Tue Apr 17 09:24:56 2018
# Tue Apr 17 18:57:21 2018
#
CONFIG_HAVE_DOT_CONFIG=y

Expand Down
2 changes: 2 additions & 0 deletions buildroot-external/configs/ova_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ BR2_PACKAGE_E2FSPROGS=y
BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y
BR2_PACKAGE_DT_UTILS=y
BR2_PACKAGE_GPTFDISK=y
BR2_PACKAGE_GPTFDISK_SGDISK=y
BR2_PACKAGE_CA_CERTIFICATES=y
BR2_PACKAGE_LIBCGROUP=y
BR2_PACKAGE_LIBCGROUP_TOOLS=y
Expand All @@ -49,6 +50,7 @@ BR2_PACKAGE_RAUC_NETWORK=y
# BR2_PACKAGE_SYSTEMD_NETWORKD is not set
BR2_PACKAGE_SYSTEMD_RANDOMSEED=y
# BR2_PACKAGE_SYSTEMD_RESOLVED is not set
BR2_PACKAGE_UTIL_LINUX_PARTX=y
BR2_PACKAGE_UTIL_LINUX_ZRAMCTL=y
BR2_TARGET_ROOTFS_SQUASHFS=y
BR2_TARGET_ROOTFS_SQUASHFS4_LZ4=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
RequiresMountsFor=/etc/docker /var/lib/docker

[Service]
ExecStart=--storage-driver=overlay2 --log-driver=journald
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// --storage-driver=overlay2 --log-driver=journald
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ExecStart=-/sbin/hassio-expand
RemainAfterExit=true

[Install]
WantedBy=local-fs-pre.target
WantedBy=local-fs.target
7 changes: 3 additions & 4 deletions buildroot-external/rootfs-overlay/usr/sbin/hassio-expand
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ set -e

DEVICE_CHILD=$(findfs LABEL="hassio-data")
DEVICE_ROOT="/dev/$(lsblk -no pkname ${DEVICE_CHILD})"
LAST_FREE_SECTOR=$(sgdisk -E ${DEVICE_ROOT})

# Need resize
if [ $LAST_FREE_SECTOR -le 2048 ]; then
if [ $(sgdisk -E ${DEVICE_ROOT}) -le 2048 ]; then
echo "[INFO] No resize of data partition needed"
exit
fi

# Resize & Reload partition
echo "[INFO] Update hassio-data partition"
sgdisk -d 6 -n 6:0:0 -c 6:"hassio-data" -t 6:"0FC63DAF-8483-4772-8E79-3D69D8477DE4" ${DEVICE_ROOT}
sgdisk -v
blockdev --rereadpt ${DEVICE_ROOT}
sgdisk -v ${DEVICE_ROOT}
partx -u ${DEVICE_ROOT}

# Resize filesystem
echo "[INFO] Resize hassio-data filesystem"
Expand Down
6 changes: 3 additions & 3 deletions buildroot-external/scripts/hdd_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ BOOTSTATE_SIZE=8M
SYSTEM_SIZE=256M
OVERLAY_SIZE=64M
DATA_SIZE=1G
IMAGE_SIZE=2G

function hassio_boot_image() {
local boot_data="${1}/boot"
Expand All @@ -30,7 +29,8 @@ function hassio_hdd_image() {
local rootfs_img="${1}/rootfs.squashfs"
local overlay_img="${1}/overlay.ext4"
local data_img="${1}/data.ext4"
local hdd_img="${2}"
local hdd_img=${2}
local hdd_count=${3:-2}

local loop_dev="/dev/mapper/$(losetup -f | cut -d'/' -f3)"
local boot_offset=0
Expand All @@ -39,7 +39,7 @@ function hassio_hdd_image() {
local data_offset=0

# Write new image & GPT
dd if=/dev/zero of=${hdd_img} bs=${IMAGE_SIZE} count=1
dd if=/dev/zero of=${hdd_img} bs=1G count=${hdd_count}
sgdisk -o ${hdd_img}

# Partition layout
Expand Down

0 comments on commit 77293f5

Please sign in to comment.