From bc6045c8b5333ac5d407e8f4b96bb0d9f50dfa9a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 6 Jan 2018 14:48:34 -0400 Subject: changes to allow GPT BIOS boot partitions * Parted: Allow partitions to have no filesystem, for eg, GPT BIOS boot partitions. (API change) * Added rawPartition to PartSpec, for specifying partitions with no filesystem. * Added BiosGrubFlag to PartFlag. Note that man parted does not list the "bios_boot" flag, but I found it in its html documentation. Other flags may also be missing. This commit was sponsored by Boyd Stephen Smith Jr. on Patreon. --- debian/changelog | 7 +++++- ...nt_18_adea3a8a65cf954a5244bbb47a1636e4._comment | 26 ++++++++++++++++++++++ src/Propellor/Property/DiskImage.hs | 2 +- src/Propellor/Property/DiskImage/PartSpec.hs | 9 ++++++-- src/Propellor/Property/Installer/Target.hs | 4 ++-- src/Propellor/Property/Parted.hs | 18 ++++++++------- src/Propellor/Property/Parted/Types.hs | 7 +++--- 7 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 doc/forum/imageBuiltFor_mount_points_not_automatically_created/comment_18_adea3a8a65cf954a5244bbb47a1636e4._comment diff --git a/debian/changelog b/debian/changelog index 8923b94a..4545bcd1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,13 @@ -propellor (5.2.1) UNRELEASED; urgency=medium +propellor (5.3.0) UNRELEASED; urgency=medium * Avoid bogus warning about new upstream version when /usr/bin/propellor is run on a Debian system, but ~/.propellor was not cloned from the Debian git bundle. + * Parted: Allow partitions to have no filesystem, for eg, GPT BIOS boot + partitions. (API change) + * Added rawPartition to PartSpec, for specifying partitions with no + filesystem. + * Added BiosGrubFlag to PartFlag. -- Joey Hess Tue, 02 Jan 2018 13:06:45 -0400 diff --git a/doc/forum/imageBuiltFor_mount_points_not_automatically_created/comment_18_adea3a8a65cf954a5244bbb47a1636e4._comment b/doc/forum/imageBuiltFor_mount_points_not_automatically_created/comment_18_adea3a8a65cf954a5244bbb47a1636e4._comment new file mode 100644 index 00000000..8a9a380e --- /dev/null +++ b/doc/forum/imageBuiltFor_mount_points_not_automatically_created/comment_18_adea3a8a65cf954a5244bbb47a1636e4._comment @@ -0,0 +1,26 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 18""" + date="2018-01-06T17:51:05Z" + content=""" +I don't know much about GPT boot stuff. I found mention of a BIOS boot +partition for GPT here: + + + +So, 1 mb partition with no filesystem and a "bios_grub" flag. + +Propellor's partitioning DSL will need to be extended in order to +support that. Currently, `Partition` has a `Fs` that is one of the common +filesystems or swap. Now we need no filesystem, so either add a NoFs to Fs, +or change it to use `Maybe Fs`. I chose the latter, because with NoFs, +Partition.formatted would be a no-op, which would be kinda surprising. + +I've made a commit adding all the stuff you should need, but I have not +tested making a BIOS boot partition with it. Should look +something like this: + + & hasPartition (rawPartition (MegaBytes 1) `setFlag` BiosGrubFlag) + +If you get it working, it would be good to add an example to propellor's docs. +"""]] diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs index 24459476..289de151 100644 --- a/src/Propellor/Property/DiskImage.hs +++ b/src/Propellor/Property/DiskImage.hs @@ -420,7 +420,7 @@ imageFinalized final img mnts mntopts devs (PartTable _ _ parts) = orderedmntsdevs = sortBy (compare `on` fst) $ zip mnts (zip mntopts devs) swaps = map (SwapPartition . partitionLoopDev . snd) $ - filter ((== LinuxSwap) . partFs . fst) $ + filter ((== Just LinuxSwap) . partFs . fst) $ zip parts devs mountall top = forM_ orderedmntsdevs $ \(mp, (mopts, loopdev)) -> case mp of diff --git a/src/Propellor/Property/DiskImage/PartSpec.hs b/src/Propellor/Property/DiskImage/PartSpec.hs index 942cfa3e..b78e4280 100644 --- a/src/Propellor/Property/DiskImage/PartSpec.hs +++ b/src/Propellor/Property/DiskImage/PartSpec.hs @@ -9,6 +9,7 @@ module Propellor.Property.DiskImage.PartSpec ( partition, -- * PartSpec combinators swapPartition, + rawPartition, mountedAt, addFreeSpace, setSize, @@ -48,11 +49,15 @@ import Data.Ord -- The partition is not mounted anywhere by default; use the combinators -- below to configure it. partition :: Monoid t => Fs -> PartSpec t -partition fs = (Nothing, mempty, mkPartition fs, mempty) +partition fs = (Nothing, mempty, mkPartition (Just fs), mempty) -- | Specifies a swap partition of a given size. swapPartition :: Monoid t => PartSize -> PartSpec t -swapPartition sz = (Nothing, mempty, const (mkPartition LinuxSwap sz), mempty) +swapPartition sz = (Nothing, mempty, const (mkPartition (Just LinuxSwap) sz), mempty) + +-- | Specifies a partition without any filesystem, of a given size. +rawPartition :: Monoid t => PartSize -> PartSpec t +rawPartition sz = (Nothing, mempty, const (mkPartition Nothing sz), mempty) -- | Specifies where to mount a partition. mountedAt :: PartSpec t -> MountPoint -> PartSpec t diff --git a/src/Propellor/Property/Installer/Target.hs b/src/Propellor/Property/Installer/Target.hs index 62ec4082..80e660ad 100644 --- a/src/Propellor/Property/Installer/Target.hs +++ b/src/Propellor/Property/Installer/Target.hs @@ -246,10 +246,10 @@ fstabLists userinput (TargetPartTable _ partspecs) = setup doNothing partitions = map (\(mp, _, mkpart, _) -> (mp, mkpart mempty)) partspecs mnts = mapMaybe fst $ - filter (\(_, p) -> partFs p /= LinuxSwap) partitions + filter (\(_, p) -> partFs p /= Just LinuxSwap && partFs p /= Nothing) partitions swaps targetdev = map (Fstab.SwapPartition . diskPartition targetdev . snd) $ - filter (\((_, p), _) -> partFs p == LinuxSwap) + filter (\((_, p), _) -> partFs p == Just LinuxSwap) (zip partitions partNums) -- | Make the target bootable using whatever bootloader is installed on it. diff --git a/src/Propellor/Property/Parted.hs b/src/Propellor/Property/Parted.hs index 97cf815e..81b84972 100644 --- a/src/Propellor/Property/Parted.hs +++ b/src/Propellor/Property/Parted.hs @@ -62,8 +62,10 @@ partitioned eep disk parttable@(PartTable _ _ parts) = property' desc $ \w -> do where desc = disk ++ " partitioned" formatl devs = combineProperties desc (toProps $ map format (zip parts devs)) - format (p, dev) = Partition.formatted' (partMkFsOpts p) - Partition.YesReallyFormatPartition (partFs p) dev + format (p, dev) = case partFs p of + Just fs -> Partition.formatted' (partMkFsOpts p) + Partition.YesReallyFormatPartition fs dev + Nothing -> doNothing -- | Gets the total size of the disk specified by the partition table. partTableSize :: PartTable -> ByteSize @@ -81,12 +83,12 @@ calcPartedParamsSize (PartTable tabletype alignment parts) = , pval f , pval b ] - mkpart partnum startpos endpos p = - [ "mkpart" - , pval (partType p) - , pval (partFs p) - , partposexact startpos - , partposfuzzy endpos + mkpart partnum startpos endpos p = catMaybes + [ Just "mkpart" + , Just $ pval (partType p) + , fmap pval (partFs p) + , Just $ partposexact startpos + , Just $ partposfuzzy endpos ] ++ case partName p of Just n -> ["name", show partnum, n] Nothing -> [] diff --git a/src/Propellor/Property/Parted/Types.hs b/src/Propellor/Property/Parted/Types.hs index e5c62739..cfd8760d 100644 --- a/src/Propellor/Property/Parted/Types.hs +++ b/src/Propellor/Property/Parted/Types.hs @@ -31,7 +31,7 @@ instance Monoid PartTable where data Partition = Partition { partType :: PartType , partSize :: PartSize - , partFs :: Partition.Fs + , partFs :: Maybe Partition.Fs , partMkFsOpts :: Partition.MkfsOpts , partFlags :: [(PartFlag, Bool)] -- ^ flags can be set or unset (parted may set some flags by default) , partName :: Maybe String -- ^ optional name for partition (only works for GPT, PC98, MAC) @@ -39,7 +39,7 @@ data Partition = Partition deriving (Show) -- | Makes a Partition with defaults for non-important values. -mkPartition :: Partition.Fs -> PartSize -> Partition +mkPartition :: Maybe Partition.Fs -> PartSize -> Partition mkPartition fs sz = Partition { partType = Primary , partSize = sz @@ -105,7 +105,7 @@ fromAlignment :: Alignment -> ByteSize fromAlignment (Alignment n) = n -- | Flags that can be set on a partition. -data PartFlag = BootFlag | RootFlag | SwapFlag | HiddenFlag | RaidFlag | LvmFlag | LbaFlag | LegacyBootFlag | IrstFlag | EspFlag | PaloFlag +data PartFlag = BootFlag | RootFlag | SwapFlag | HiddenFlag | RaidFlag | LvmFlag | LbaFlag | LegacyBootFlag | IrstFlag | EspFlag | PaloFlag | BiosGrubFlag deriving (Show) instance PartedVal PartFlag where @@ -120,6 +120,7 @@ instance PartedVal PartFlag where pval IrstFlag = "irst" pval EspFlag = "esp" pval PaloFlag = "palo" + pval BiosGrubFlag = "bios_grub" instance PartedVal Bool where pval True = "on" -- cgit v1.2.3