mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-25 07:31:01 +02:00
Allow RO rootfs and writeable stateful.
BUG=9423 TEST=mount an image --safe, rootfs OK Change-Id: I4bc48e742e2438a1d2cae17c752743e02bd124fd Review URL: http://codereview.chromium.org/4974006
This commit is contained in:
parent
d4993a7311
commit
867fde26b7
@ -20,6 +20,8 @@ DEFINE_string board "$DEFAULT_BOARD" \
|
|||||||
"The board for which the image was built." b
|
"The board for which the image was built." b
|
||||||
DEFINE_boolean read_only $FLAGS_FALSE \
|
DEFINE_boolean read_only $FLAGS_FALSE \
|
||||||
"Mount in read only mode -- skips stateful items."
|
"Mount in read only mode -- skips stateful items."
|
||||||
|
DEFINE_boolean safe $FLAGS_FALSE \
|
||||||
|
"Mount rootfs in read only mode."
|
||||||
DEFINE_boolean unmount $FLAGS_FALSE \
|
DEFINE_boolean unmount $FLAGS_FALSE \
|
||||||
"Unmount previously mounted dir." u
|
"Unmount previously mounted dir." u
|
||||||
DEFINE_string from "/dev/sdc" \
|
DEFINE_string from "/dev/sdc" \
|
||||||
@ -64,9 +66,12 @@ function unmount_image() {
|
|||||||
|
|
||||||
function get_usb_partitions() {
|
function get_usb_partitions() {
|
||||||
local ro_flag=""
|
local ro_flag=""
|
||||||
|
local safe_flag=""
|
||||||
[ ${FLAGS_read_only} -eq ${FLAGS_TRUE} ] && ro_flag="-o ro"
|
[ ${FLAGS_read_only} -eq ${FLAGS_TRUE} ] && ro_flag="-o ro"
|
||||||
|
[ ${FLAGS_read_only} -eq ${FLAGS_TRUE} -o \
|
||||||
|
${FLAGS_safe} -eq ${FLAGS_TRUE} ] && safe_flag="-o ro -t ext2"
|
||||||
|
|
||||||
sudo mount ${ro_flag} "${FLAGS_from}3" "${FLAGS_rootfs_mountpt}"
|
sudo mount ${safe_flag} "${FLAGS_from}3" "${FLAGS_rootfs_mountpt}"
|
||||||
sudo mount ${ro_flag} "${FLAGS_from}1" "${FLAGS_stateful_mountpt}"
|
sudo mount ${ro_flag} "${FLAGS_from}1" "${FLAGS_stateful_mountpt}"
|
||||||
if [[ -n "${FLAGS_esp_mountpt}" ]]; then
|
if [[ -n "${FLAGS_esp_mountpt}" ]]; then
|
||||||
sudo mount ${ro_flag} "${FLAGS_from}12" "${FLAGS_esp_mountpt}"
|
sudo mount ${ro_flag} "${FLAGS_from}12" "${FLAGS_esp_mountpt}"
|
||||||
@ -79,8 +84,15 @@ function get_gpt_partitions() {
|
|||||||
# Mount the rootfs partition using a loopback device.
|
# Mount the rootfs partition using a loopback device.
|
||||||
local offset=$(partoffset "${FLAGS_from}/${filename}" 3)
|
local offset=$(partoffset "${FLAGS_from}/${filename}" 3)
|
||||||
local ro_flag=""
|
local ro_flag=""
|
||||||
|
local safe_flag=""
|
||||||
|
|
||||||
if [ ${FLAGS_read_only} -eq ${FLAGS_TRUE} ]; then
|
if [ ${FLAGS_read_only} -eq ${FLAGS_TRUE} ]; then
|
||||||
ro_flag="-o ro"
|
ro_flag="-o ro"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${FLAGS_read_only} -eq ${FLAGS_TRUE} -o \
|
||||||
|
${FLAGS_safe} -eq ${FLAGS_TRUE} ]; then
|
||||||
|
safe_flag="-o ro -t ext2"
|
||||||
else
|
else
|
||||||
# Make sure any callers can actually mount and modify the fs
|
# Make sure any callers can actually mount and modify the fs
|
||||||
# if desired.
|
# if desired.
|
||||||
@ -88,7 +100,7 @@ function get_gpt_partitions() {
|
|||||||
enable_rw_mount "${FLAGS_from}/${filename}" "$(( offset * 512 ))"
|
enable_rw_mount "${FLAGS_from}/${filename}" "$(( offset * 512 ))"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo mount ${ro_flag} -o loop,offset=$(( offset * 512 )) \
|
sudo mount ${safe_flag} -o loop,offset=$(( offset * 512 )) \
|
||||||
"${FLAGS_from}/${filename}" "${FLAGS_rootfs_mountpt}"
|
"${FLAGS_from}/${filename}" "${FLAGS_rootfs_mountpt}"
|
||||||
|
|
||||||
# Mount the stateful partition using a loopback device.
|
# Mount the stateful partition using a loopback device.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user