Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk/partition.py
diff options
context:
space:
mode:
authorDylan M. Taylor <dylan@dylanmtaylor.com>2021-11-22 11:22:51 -0500
committerGitHub <noreply@github.com>2021-11-22 17:22:51 +0100
commit0c96ae049dd188c0df247c29ea36715e92428d3a (patch)
tree1a49b9add857a3c6fd7d6a4a2cdb5e486dbc2d78 /archinstall/lib/disk/partition.py
parent29d0b3d15570a12ad89feff8b49dd9be478e69c2 (diff)
NTFS Root Filesystem Support (#748)
* For fun, allow NTFS as a root filesystem type Add ability to format a filesystem as NTFS Try to force filesystem type Fix FAT mounting * Split out mount fs type method * Handle rootfstype on non-GRUB bootloaders * Add -Q to mkfs.ntfs command line for quick formatting * I believe this will fix GRUB with NTFS root * Remove the fsck hook if NTFS is used as the root partition * Looks like the string is ntfs3 not ntfs so this logic wasn't running
Diffstat (limited to 'archinstall/lib/disk/partition.py')
-rw-r--r--archinstall/lib/disk/partition.py48
1 files changed, 33 insertions, 15 deletions
diff --git a/archinstall/lib/disk/partition.py b/archinstall/lib/disk/partition.py
index e2083649..4aea3832 100644
--- a/archinstall/lib/disk/partition.py
+++ b/archinstall/lib/disk/partition.py
@@ -13,6 +13,7 @@ from ..exceptions import DiskError, SysCallError, UnknownFilesystemFormat
from ..output import log
from ..general import SysCommand
+
class Partition:
def __init__(self, path: str, block_device: BlockDevice, part_id=None, size=-1, filesystem=None, mountpoint=None, encrypted=False, autodetect_filesystem=True):
if not part_id:
@@ -71,17 +72,17 @@ class Partition:
def __dump__(self):
return {
- 'type' : 'primary',
- 'PARTUUID' : self._safe_uuid,
- 'wipe' : self.allow_formatting,
- 'boot' : self.boot,
- 'ESP' : self.boot,
- 'mountpoint' : self.target_mountpoint,
- 'encrypted' : self._encrypted,
- 'start' : self.start,
- 'size' : self.end,
- 'filesystem' : {
- 'format' : get_filesystem_type(self.path)
+ 'type': 'primary',
+ 'PARTUUID': self._safe_uuid,
+ 'wipe': self.allow_formatting,
+ 'boot': self.boot,
+ 'ESP': self.boot,
+ 'mountpoint': self.target_mountpoint,
+ 'encrypted': self._encrypted,
+ 'start': self.start,
+ 'size': self.end,
+ 'filesystem': {
+ 'format': get_filesystem_type(self.path)
}
}
@@ -98,7 +99,7 @@ class Partition:
for partition in output.get('partitiontable', {}).get('partitions', []):
if partition['node'] == self.path:
- return partition['start']# * self.sector_size
+ return partition['start'] # * self.sector_size
@property
def end(self):
@@ -107,7 +108,7 @@ class Partition:
for partition in output.get('partitiontable', {}).get('partitions', []):
if partition['node'] == self.path:
- return partition['size']# * self.sector_size
+ return partition['size'] # * self.sector_size
@property
def boot(self):
@@ -301,6 +302,13 @@ class Partition:
raise DiskError(f"Could not format {path} with {filesystem} because: {handle.decode('UTF-8')}")
self.filesystem = filesystem
+ elif filesystem == 'ntfs':
+ options = ['-f'] + options
+
+ if (handle := SysCommand(f"/usr/bin/mkfs.ntfs -Q {' '.join(options)} {path}")).exit_code != 0:
+ raise DiskError(f"Could not format {path} with {filesystem} because: {handle.decode('UTF-8')}")
+ self.filesystem = filesystem
+
elif filesystem == 'crypto_LUKS':
# from ..luks import luks2
# encrypted_partition = luks2(self, None, None)
@@ -333,13 +341,15 @@ class Partition:
raise DiskError(f'Need to format (or define) the filesystem on {self} before mounting.')
fs = self.filesystem
+ fs_type = get_mount_fs_type(fs)
+
pathlib.Path(target).mkdir(parents=True, exist_ok=True)
try:
if options:
- mnt_handle = SysCommand(f"/usr/bin/mount -o {options} {self.path} {target}")
+ mnt_handle = SysCommand(f"/usr/bin/mount -t {fs_type} -o {options} {self.path} {target}")
else:
- mnt_handle = SysCommand(f"/usr/bin/mount {self.path} {target}")
+ mnt_handle = SysCommand(f"/usr/bin/mount -t {fs_type} {self.path} {target}")
# TODO: Should be redundant to check for exit_code
if mnt_handle.exit_code != 0:
@@ -382,3 +392,11 @@ class Partition:
except UnknownFilesystemFormat as err:
raise err
return True
+
+
+def get_mount_fs_type(fs):
+ if fs == 'ntfs':
+ return 'ntfs3' # Needed to use the Paragon R/W NTFS driver
+ elif fs == 'fat32':
+ return 'vfat' # This is the actual type used for fat32 mounting.
+ return fs