瀏覽代碼

Changed OTFE filesystem to ext4

Maxim Kammerer 10 年之前
父節點
當前提交
44c88a42a5
共有 3 個文件被更改,包括 23 次插入47 次删除
  1. 1 0
      doc/changelog.txt
  2. 11 11
      src/etc/init.d/liberte
  3. 11 36
      src/usr/local/sbin/otfe-resize

+ 1 - 0
doc/changelog.txt

@@ -17,6 +17,7 @@
   * Added "gentoo=obfs" boot parameter for obfsproxy Tor bridges
   * Added "gentoo=obfs" boot parameter for obfsproxy Tor bridges
   * Added "gentoo=xkms" boot parameter for forcing X modesetting driver
   * Added "gentoo=xkms" boot parameter for forcing X modesetting driver
   * More robust Xorg autoconfiguration with sequential fallbacks
   * More robust Xorg autoconfiguration with sequential fallbacks
+  * Changed OTFE filesystem to ext4
   * Added ASCII virtual keyboard table for OTFE password entry
   * Added ASCII virtual keyboard table for OTFE password entry
   * Added preformatted man pages
   * Added preformatted man pages
 
 

+ 11 - 11
src/etc/init.d/liberte

@@ -46,7 +46,7 @@ boot=/mnt/boot
 live=/mnt/live
 live=/mnt/live
 autos=/var/run/auto.media
 autos=/var/run/auto.media
 otfefile=${boot}${OTFEFILE}
 otfefile=${boot}${OTFEFILE}
-ntfsflags=noatime,nosuid,nodev,compression,usermapping=/etc/ntfs-3g.map
+otfeflags=noatime,nosuid,nodev,acl,user_xattr
 
 
 
 
 start() {
 start() {
@@ -84,7 +84,7 @@ start() {
         # Add an OTFE line to /etc/fstab, so that autofs won't mount the LVM
         # Add an OTFE line to /etc/fstab, so that autofs won't mount the LVM
         # device later, and for otfe-resize script to be able to mount it
         # device later, and for otfe-resize script to be able to mount it
         if ! grep -q "^/dev/mapper/${OTFEVOLUME} " /etc/fstab; then
         if ! grep -q "^/dev/mapper/${OTFEVOLUME} " /etc/fstab; then
-            echo "/dev/mapper/${OTFEVOLUME} ${lmount} ntfs-3g noauto,${ntfsflags} 0 0" >> /etc/fstab
+            echo "/dev/mapper/${OTFEVOLUME} ${lmount} ext4 noauto,${otfeflags} 0 0" >> /etc/fstab
         fi
         fi
 
 
         # Initialize LUKS image mapping (create if it doesn't exist)
         # Initialize LUKS image mapping (create if it doesn't exist)
@@ -96,12 +96,13 @@ start() {
             freespace=$((`stat -fc '%a*%S' ${boot}`))
             freespace=$((`stat -fc '%a*%S' ${boot}`))
             otfesize=$((freespace * ${OTFESIZE} / (1024*1024)))
             otfesize=$((freespace * ${OTFESIZE} / (1024*1024)))
 
 
-            #    3 MiB is the minimum possible size (rounded up to MiB)
-            # 4095 MiB is the maximum possible file size on FAT32 (2^32-1 B)
-            if [ ${otfesize} -lt 3 ]; then
-                otfesize=3
-            elif [ ${otfesize} -gt 4095 ]; then
-                otfesize=4095
+            #   4 MiB is the minimum possible size (rounded up to MiB)
+            # 256 MiB is the limit here to avoid long OTFE creation times
+            # (see /usr/local/sbin/otfe-resize)
+            if [ ${otfesize} -lt 4 ]; then
+                otfesize=4
+            elif [ ${otfesize} -gt 256 ]; then
+                otfesize=256
             fi
             fi
 
 
             # FAT has no sparse files, so insufficient space will fail here
             # FAT has no sparse files, so insufficient space will fail here
@@ -133,9 +134,8 @@ start() {
                     cryptsetup luksHeaderBackup --header-backup-file ${otfefile}-hdr.bak ${otfefile}
                     cryptsetup luksHeaderBackup --header-backup-file ${otfefile}-hdr.bak ${otfefile}
                     eend $?
                     eend $?
 
 
-                    # LC_ALL enables UTF-8 label support
-                    ebegin Formatting encrypted storage as NTFS: ${otfefile}
-                    LC_ALL=en_GB.UTF-8 mkntfs -qfCIU -L "${OTFELABEL}" -p 0 -H 0 -S 0 /dev/mapper/${OTFEVOLUME}
+                    ebegin Formatting encrypted storage: ${otfefile}
+                    mke2fs -qF -t ext4 -T small -L "${OTFELABEL}" -m 0 /dev/mapper/${OTFEVOLUME}
                     eend $?
                     eend $?
                 else
                 else
                     rm ${otfefile}
                     rm ${otfefile}

+ 11 - 36
src/usr/local/sbin/otfe-resize

@@ -45,20 +45,6 @@ mount_fs() {
 }
 }
 
 
 
 
-# Resizing a filesystem with a dry run
-do_resize() {
-    echo ">> Performing a dry run"
-    if ! ntfsresize -n "$@"; then
-        return 1
-    else
-        # last command sets pipe's error status
-        # pipe must come last, so that function can be used in an "if"
-        echo ">> Performing actual resize"
-        echo y | ntfsresize "$@"
-    fi
-}
-
-
 # Accept only single parameter
 # Accept only single parameter
 if [ $# != 1 ]; then
 if [ $# != 1 ]; then
     cat<<EOF
     cat<<EOF
@@ -72,9 +58,6 @@ on subsequent steps to succeed.
 
 
 The OTFE header is unaffected by the resize, so any existing header
 The OTFE header is unaffected by the resize, so any existing header
 backup is still valid.
 backup is still valid.
-
-WARNING: Disconnect all network interfaces before running otfe-resize
-         in order to avoid interfering with cables communication.
 EOF
 EOF
     exit 1
     exit 1
 fi
 fi
@@ -103,14 +86,14 @@ oldsize=`du -b "${file}" | cut -f1`
 
 
 
 
 # More sanity checks
 # More sanity checks
-# Minimum is (1M + 512B) for NTFS, and (1M + 8K) for OTFE
-if [ ${oldsize} -lt $((2*1024*1024 + 512 + 8*1024)) ]; then
+# Minimum is 2M for ext4, and (1M + 8K) for OTFE
+if [ "${oldsize}" -lt $((3*1024*1024 + 8*1024)) ]; then
     error "Sanity check failed: ${file} is too small"
     error "Sanity check failed: ${file} is too small"
 fi
 fi
 
 
 # Check that OTFE offset+size add up (assume 512B sectors)
 # Check that OTFE offset+size add up (assume 512B sectors)
 # This also ensures that OTFE file size is a multiple of 512
 # This also ensures that OTFE file size is a multiple of 512
-if [ ${oldsize} -ne $(((otfeoffset + otfesize) * 512)) ]; then
+if [ "${oldsize}" -ne $(((otfeoffset + otfesize) * 512)) ]; then
     error "Sanity check failed: [${OTFEVOLUME}] size and offset don't match size of ${file}"
     error "Sanity check failed: [${OTFEVOLUME}] size and offset don't match size of ${file}"
 fi
 fi
 
 
@@ -147,8 +130,8 @@ fi
 
 
 
 
 # See the calculation above for the minimum possible size
 # See the calculation above for the minimum possible size
-if [ ${size} -lt 3 ]; then
-    error "Minimum supported size is 3 MiB"
+if [ ${size} -lt 4 ]; then
+    error "Minimum supported size is 4 MiB"
 fi
 fi
 size=$((size * 1024 * 1024))
 size=$((size * 1024 * 1024))
 
 
@@ -162,18 +145,11 @@ if [ ${size} -ge ${oldsize} ]; then
     fi
     fi
 
 
 
 
-    # The filesystem can be unmounted just prior to
-    # NTFS resize, but there is no point in growing
-    # the file and the OTFE volume if umount fails
-    umount_fs
-
-
     # Increase OTFE file size
     # Increase OTFE file size
     echo ">> Growing ${file} to ${size} bytes"
     echo ">> Growing ${file} to ${size} bytes"
     if ! truncate -s ${size} "${file}"; then
     if ! truncate -s ${size} "${file}"; then
         echo ">> Restoring the original size of ${file}"
         echo ">> Restoring the original size of ${file}"
         truncate -s ${oldsize} "${file}"
         truncate -s ${oldsize} "${file}"
-        mount_fs
         exit 1
         exit 1
     fi
     fi
 
 
@@ -188,20 +164,19 @@ if [ ${size} -ge ${oldsize} ]; then
     cryptsetup resize ${OTFEVOLUME}
     cryptsetup resize ${OTFEVOLUME}
 
 
 
 
-    # Resize the NTFS filesystem on encrypted volume
-    echo ">> Growing the NTFS filesystem on ${otfe}"
-    do_resize -fP "${otfe}"
-    mount_fs
+    # Resize the filesystem on encrypted volume
+    echo ">> Growing the filesystem on ${otfe}"
+    resize2fs -f "${otfe}"
 
 
 else
 else
 
 
     sizediff=$((oldsize - size))
     sizediff=$((oldsize - size))
 
 
-    # Resize the NTFS filesystem on encrypted volume
+    # Resize the filesystem on encrypted volume
     # (assuming 512B sectors - see sanity checks above)
     # (assuming 512B sectors - see sanity checks above)
     umount_fs
     umount_fs
-    echo ">> Shrinking the NTFS filesystem on ${otfe}"
-    if ! do_resize -fP -s $((otfesize*512 - sizediff)) "${otfe}"; then
+    echo ">> Shrinking the filesystem on ${otfe}"
+    if ! resize2fs -f "${otfe}" $((otfesize - sizediff/512))s; then
         mount_fs
         mount_fs
         exit 1
         exit 1
     fi
     fi