Skip to content

Commit

Permalink
rpi: Add resize-rootfs=r0 (expand rootfs)
Browse files Browse the repository at this point in the history
:Release Notes:
A service to expand the rootfs

:Detailed Notes:
Expand the rootfs as whole SD card.
This service will be executed on the first boot only.
(Creates /var/luna/preferences/rootfs-resized)

:Testing Performed:
See PLAT-80165

:QA Notes:
N/A

:Issues Addressed:
[PLAT-76087] [FOTA] Expand rootfs size and mount partitions for libostree
[PLAT-80165] [OSE] CCC: rpi: add resize-rootfs=r0 (expand rootfs)

Change-Id: I06b830f58f04cfe35ebd8c9794d8c96b1d10d387
  • Loading branch information
jb-seo authored and Minjae Kim committed Jul 29, 2019
1 parent dd35430 commit fa11466
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# @@@LICENSE
#
# Copyright (c) 2019 LG Electronics, Inc.
#
# LICENSE@@@

[Unit]
Description=webos - "%n"
DefaultDependencies=no
Conflicts=shutdown.target
Before=sysinit.target
After=systemd-remount-fs.service local-fs.target
Requires=local-fs.target
ConditionPathExists=!/var/luna/preferences/rootfs_resized

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/systemd/system/scripts/resize-rootfs.sh
StandardOutput=tty
StandardError=tty

[Install]
WantedBy=local-fs.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh
# Copyright (c) 2019 LG Electronics, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

if [ "$(id -u)" -ne "0" ]; then
echo "This script requires root."
exit 1
fi

PREF_DIR="/var/luna/preferences"
DEVICE="/dev/mmcblk0"
PART="2"

updatePartitionTable() {
start=$(fdisk -l ${DEVICE}|grep ${DEVICE}p${PART}|awk '{print $2}')

fdisk ${DEVICE} <<EOF
p
d
2
n
p
2
$start
No
w
EOF
echo "Partition table updated!"
}

if [ -f ${PREF_DIR}/rootfs_resized ]; then
echo "Resize rootfs done already!"
else
updatePartitionTable
partprobe
resize2fs ${DEVICE}p${PART}
touch ${PREF_DIR}/rootfs_resized
echo "Resize rootfs done!"
fi
27 changes: 27 additions & 0 deletions meta-webos-raspberrypi/recipes-bsp/resize-rootfs/resize-rootfs.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2019 LG Electronics, Inc.

SUMMARY = "A service to expand rootfs to whole media"
AUTHOR = "JeongBong Seo <jb.seo@lge.com>"
SECTION = "webos/base"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"

RDEPENDS_${PN} = "e2fsprogs-resize2fs parted"

PR = "r0"

inherit systemd

SRC_URI = " \
file://resize-rootfs.service \
file://resize-rootfs.sh \
"

do_install() {
install -d ${D}${systemd_system_unitdir}
install -v -m 0644 ${WORKDIR}/resize-rootfs.service ${D}${systemd_system_unitdir}
install -d ${D}${sysconfdir}/systemd/system/scripts
install -v -m 0755 ${WORKDIR}/resize-rootfs.sh ${D}${sysconfdir}/systemd/system/scripts
}

SYSTEMD_SERVICE_${PN} = " resize-rootfs.service"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2019 LG Electronics, Inc.

EXTENDPRAUTO_append_rpi = "webosrpi1"

# resize-rootfs will expand rootfs, so we don't need extra space a lot
IMAGE_ROOTFS_EXTRA_SPACE = "16384"
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CAMERASERVICE_raspberrypi3-64 = ""

RDEPENDS_${PN}_append_rpi = " \
com.webos.service.audiooutput \
resize-rootfs \
${AISERVICE} \
${CAMERASERVICE} \
${TTSSERVICE} \
Expand Down

0 comments on commit fa11466

Please sign in to comment.