|
@@ -38,6 +38,7 @@ echo "done"
|
|
|
|
|
|
printf "mounting filesystem... "
|
|
printf "mounting filesystem... "
|
|
mkdir -p mnt
|
|
mkdir -p mnt
|
|
|
|
+use_genext2fs=0
|
|
if [ "$(uname -s)" = "Darwin" ]; then
|
|
if [ "$(uname -s)" = "Darwin" ]; then
|
|
fuse-ext2 _disk_image mnt -o rw+,allow_other,uid=501,gid=20 || die "could not mount filesystem"
|
|
fuse-ext2 _disk_image mnt -o rw+,allow_other,uid=501,gid=20 || die "could not mount filesystem"
|
|
elif [ "$(uname -s)" = "OpenBSD" ]; then
|
|
elif [ "$(uname -s)" = "OpenBSD" ]; then
|
|
@@ -45,14 +46,23 @@ elif [ "$(uname -s)" = "OpenBSD" ]; then
|
|
elif [ "$(uname -s)" = "FreeBSD" ]; then
|
|
elif [ "$(uname -s)" = "FreeBSD" ]; then
|
|
fuse-ext2 -o rw+ "/dev/${MD}" mnt/ || die "could not mount filesystem"
|
|
fuse-ext2 -o rw+ "/dev/${MD}" mnt/ || die "could not mount filesystem"
|
|
else
|
|
else
|
|
- mount _disk_image mnt/ || die "could not mount filesystem"
|
|
|
|
|
|
+ if ! mount _disk_image mnt/ ; then
|
|
|
|
+ if command -v genext2fs 1>/dev/null ; then
|
|
|
|
+ echo "mount failed but genext2fs exists, use it instead"
|
|
|
|
+ use_genext2fs=1
|
|
|
|
+ else
|
|
|
|
+ die "could not mount filesystem and genext2fs is missing"
|
|
|
|
+ fi
|
|
|
|
+ fi
|
|
fi
|
|
fi
|
|
echo "done"
|
|
echo "done"
|
|
|
|
|
|
cleanup() {
|
|
cleanup() {
|
|
if [ -d mnt ]; then
|
|
if [ -d mnt ]; then
|
|
- printf "unmounting filesystem... "
|
|
|
|
- umount mnt || ( sleep 1 && sync && umount mnt )
|
|
|
|
|
|
+ if [ $use_genext2fs = 0 ] ; then
|
|
|
|
+ printf "unmounting filesystem... "
|
|
|
|
+ umount mnt || ( sleep 1 && sync && umount mnt )
|
|
|
|
+ fi
|
|
rm -rf mnt
|
|
rm -rf mnt
|
|
if [ "$(uname -s)" = "OpenBSD" ]; then
|
|
if [ "$(uname -s)" = "OpenBSD" ]; then
|
|
vnconfig -u "$VND"
|
|
vnconfig -u "$VND"
|
|
@@ -65,3 +75,13 @@ cleanup() {
|
|
trap cleanup EXIT
|
|
trap cleanup EXIT
|
|
|
|
|
|
./build-root-filesystem.sh
|
|
./build-root-filesystem.sh
|
|
|
|
+
|
|
|
|
+if [ $use_genext2fs = 1 ]; then
|
|
|
|
+ # regenerate new image, since genext2fs is unable to reuse the previously written image.
|
|
|
|
+ # genext2fs is very slow in generating big images, so I use a smaller image here. size can be updated
|
|
|
|
+ # if it's not enough.
|
|
|
|
+ # not using "-i 128" since it hangs. Serenity handles whatever default this uses instead.
|
|
|
|
+ genext2fs -b 250000 -d mnt _disk_image || die "try increasing image size (genext2fs -b)"
|
|
|
|
+ # if using docker with shared mount, file is created as root, so make it writable for users
|
|
|
|
+ chmod 0666 _disk_image
|
|
|
|
+fi
|