I've setup a Fedora Live USB on a 16GB pendrive with a 4GB Persistent Overlay allocated following guide https://fedoraproject.org/wiki/How_t...d_use_Live_USB
I can merge changes in the overlay into a new image and reset the overlay storage using the scrip mentioned here https://fedoraproject.org/wiki/LiveO...into_new_image
But now the LiveOS rootfs partition "/dev/mapper/live-rw" mounted from ext3fs.img inside the squashfs.img is nearing its 3.9G limit,
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/live-rw 3.9G 3.4G 429M 89% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 84K 3.9G 1% /dev/shm
tmpfs 3.9G 928K 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sdb1 16G 7.0G 8.4G 46% /run/initramfs/live
tmpfs 3.9G 20K 3.9G 1% /tmp
/dev/loop3 2.0G 43M 1.8G 3% /home
varcacheyum 3.9G 0 3.9G 0% /var/cache/yum
vartmp 3.9G 0 3.9G 0% /var/tmp
Is there any practical way to increase the livecd rootfs partition (ext3fs.img inside the squashfs.img) and what are the exact steps?
Thanks for your help.
I can merge changes in the overlay into a new image and reset the overlay storage using the scrip mentioned here https://fedoraproject.org/wiki/LiveO...into_new_image
Code:
#!/bin/bash -xv
#
# Merge a LiveOS snapshot overlay into a new root filesystem, recompress it
# into a SquashFS image (if the source was so packaged), replace the source
# with the refresh, and reset the overlay.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
oldLC=$LC_NUMERIC
LC_NUMERIC="en_US.UTF-8"
export PATH=/usr/sbin:$PATH
export \
PS4='+(${SHLVL}:${LINENO}:${BASH_SOURCE}:${EUID}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -o errexit
set -o pipefail
t0=$(date +%s)
cleanup () {
umount -l $SRCMNT
rmdir $SRCMNT
dt=$(($(date +%s)-t0))
h=$((dt/3600))
m=$((dt%3600/60))
s=$((dt%60))
printf '\nTotal time elapsed: %02d:%02d:%02d hh:mm:ss\n' $h $m $s
[[ $1 == 0 ]] && exit 0 || exit 1
}
if [[ ! -f /usr/sbin/mksquashfs ]]; then
echo "Please install squashfs-tools (yum install squashfs-tools)";
exit
fi
TMPDIR=$1
[[ ! -d $TMPDIR/LiveOS ]] && mkdir $TMPDIR/LiveOS 2>/dev/null
# Mount the source device and SquashFS.
mkdir -p /run/media #Doesn't exist in fedora 20 livecd
SRCMNT=$(mktemp -d /run/media/XXXXXX)
mount $2 $SRCMNT
if [[ -e $SRCMNT/LiveOS/squashfs.img ]]; then
SQUASHMNT=$(mktemp -d /run/media/XXXXXX)
mount $SRCMNT/LiveOS/squashfs.img $SQUASHMNT --read-only
ORIGFS=$SQUASHMNT/LiveOS/ext3fs.img
[[ ! -f $ORIGFS ]] && ORIGFS=$SQUASHMNT/LiveOS/rootfs.img
else
ORIGFS=$SRCMNT/LiveOS/ext3fs.img
[[ ! -f $ORIGFS ]] && ORIGFS=$SRCMNT/LiveOS/rootfs.img
fi
OVERLAY=/LiveOS/$(basename $SRCMNT/LiveOS/overlay-*)
if [[ -f $SRCMNT$OVERLAY ]]; then
OVDEV=$(losetup -f --show $SRCMNT$OVERLAY --read-only)
else
printf '\n No persistent overlay for the filesystem was found.
Exiting...\n'
cleanup 1
fi
# >= Fedora 17
LiveOSMNT=/run/initramfs/live
# < Fedora 17
[[ -d /mnt/live/LiveOS ]] && LiveOSMNT=/mnt/live
# If we are processing a booted LiveOS device's root filesystem, then
if [[ $(mountpoint -x $2) == $(mountpoint -dq $LiveOSMNT) ]]; then
# Remove live-osimg-min; free its loop devices.
if [[ -e $SRCMNT/LiveOS/osmin.img ]]; then
dmsetup remove live-osimg-min || :
losetup -d /dev/loop1 || :
losetup -d /dev/loop0 || :
fi
else
LiveOSMNT=''
fi
# Remove expiring osmin.img
rm $SRCMNT/LiveOS/osmin.img || :
# Prepare temporary devices for the Device-mapper mirror target.
FSTYPE=$(blkid -s TYPE -o value $ORIGFS || :)
FSLABEL=$(blkid -s LABEL -o value $ORIGFS || :)
stinfo=($(stat -c '%B %s %o' $ORIGFS || :))
BLOCKSZ=${stinfo[0]}
BLOCKS=$((${stinfo[1]}/$BLOCKSZ))
IOBLKSZ=${stinfo[2]}
NEWFS=$TMPDIR/LiveOS/rootfs.img
dd if=/dev/null of=$NEWFS count=1 bs=$BLOCKSZ seek=$BLOCKS
mkfs.$FSTYPE -F -L $FSLABEL -m 1 -b $IOBLKSZ $NEWFS
tune2fs -c0 -i0 -Odir_index -ouser_xattr,acl $NEWFS
NEWFSDEV=$(losetup -f --show $NEWFS)
roORIGFSDEV=$(losetup -f --show $ORIGFS --read-only)
table="0 $BLOCKS snapshot $roORIGFSDEV $OVDEV P 8"
dmsetup create ori --readonly --table "$table"
# Invoke mirror target device.
table="0 $BLOCKS mirror core 2 32 sync 2 /dev/mapper/ori 0 $NEWFSDEV 0"
dmsetup create mir --table "$table"
set +xv
# Wait for mirror completion.
while state=$(dmsetup status mir)
state=${state#*mirror 2 * * }
alloc=${state%/*}
size=${state#*/}
size=${size%% *}
[[ $alloc != $size ]]; do
percent=$(dc <<< "8k 10 0.05 100 $alloc $size /*+*p")
percent=$(dc <<< "1k $percent 10 /p")
printf '\r Mirroring %5.1f %% complete. ' $percent
printf '\b|'
sleep 0.5
printf '\b/'
sleep 0.5
printf '\b-'
sleep 0.5
printf '\b\'
sleep 0.5
done
printf '\r Mirroring 100 %% complete. \n'
set -xv
# Check the new filesystem.
e2fsck -f -y $NEWFS || e2fsck -f -y $NEWFS
# Clean up.
dmsetup remove mir ori
sync
dt=$(($(date +%s)-t0))
h=$((dt/3600))
m=$((dt%3600/60))
s=$((dt%60))
printf '\nTime elapsed: %02d:%02d:%02d hh:mm:ss\n' $h $m $s
# Replace SquashFS or uncompressed root filesystem image.
if [[ -e $SRCMNT/LiveOS/squashfs.img ]]; then
umount -l $SQUASHMNT
rm $SRCMNT/LiveOS/squashfs.img
mksquashfs $TMPDIR/LiveOS $SRCMNT/LiveOS/squashfs.img -comp xz -keep-as-directory
else
if [[ -x /usr/bin/rsync ]]; then
rsync --inplace --progress $NEWFS $SRCMNT/LiveOS
else
cp $NEWFS $SRCMNT/LiveOS
fi
fi
# Clean up.
losetup -d $OVDEV $NEWFSDEV $roORIGFSDEV
OVDEV=$(losetup -f --show $SRCMNT$OVERLAY)
# Reset overlay.
dd if=/dev/zero of=$OVDEV bs=64k count=1 conv=notrunc,fsync
# If we are processing a booted LiveOS device's root filesystem, then
if [[ -n $LiveOSMNT ]]; then
# Try to unmount the TMPDIR.
mountpoint $TMPDIR && umount -l $TMPDIR || :
shutdown -r +1 'The system will reboot in 1 minute.'
else
sleep 1
losetup -d $OVDEV
fi
cleanup 0
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/live-rw 3.9G 3.4G 429M 89% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 84K 3.9G 1% /dev/shm
tmpfs 3.9G 928K 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sdb1 16G 7.0G 8.4G 46% /run/initramfs/live
tmpfs 3.9G 20K 3.9G 1% /tmp
/dev/loop3 2.0G 43M 1.8G 3% /home
varcacheyum 3.9G 0 3.9G 0% /var/cache/yum
vartmp 3.9G 0 3.9G 0% /var/tmp
Is there any practical way to increase the livecd rootfs partition (ext3fs.img inside the squashfs.img) and what are the exact steps?
Thanks for your help.