diff options
author | Andrew Cady <d@jerkface.net> | 2020-05-31 00:12:23 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-05-31 00:12:23 -0400 |
commit | ea6de9aeee6173363384b3b3a1dc4d37a900f961 (patch) | |
tree | f3902fe9e9a4f083332259ae5cd4ac26c9c0ff07 | |
parent | 3267d4e1180a4c65026e759bf267c905aa221ad5 (diff) |
always run setupLoopDevices before mount -t btrfs
-rw-r--r-- | fsmgr.hs | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -181,6 +181,7 @@ buildInitialImage DiskImageConfig{..} mountpoint out = do | |||
181 | cmd_ "truncate -s" [show n, out] | 181 | cmd_ "truncate -s" [show n, out] |
182 | cmd_ "fallocate -l" [show n, out] | 182 | cmd_ "fallocate -l" [show n, out] |
183 | 183 | ||
184 | setupLoopDevices parent | ||
184 | idempotentMountImage parent mountpoint | 185 | idempotentMountImage parent mountpoint |
185 | 186 | ||
186 | addImageToBtrfs out mountpoint | 187 | addImageToBtrfs out mountpoint |
@@ -189,6 +190,8 @@ buildInitialImage DiskImageConfig{..} mountpoint out = do | |||
189 | cmd_ "truncate -s" [show n] [out] | 190 | cmd_ "truncate -s" [show n] [out] |
190 | cmd_ "mkfs.btrfs" [out] | 191 | cmd_ "mkfs.btrfs" [out] |
191 | cmd_ "mkdir -p" [mountpoint] | 192 | cmd_ "mkdir -p" [mountpoint] |
193 | |||
194 | setupLoopDevices out | ||
192 | cmd_ "mount -t btrfs" [out] mountpoint | 195 | cmd_ "mount -t btrfs" [out] mountpoint |
193 | 196 | ||
194 | -- create new default subvolume, and then remount with it | 197 | -- create new default subvolume, and then remount with it |
@@ -218,6 +221,7 @@ idempotentMountImage imageFile mountPoint = do | |||
218 | cmd_ "mkdir -p" [mountPoint] | 221 | cmd_ "mkdir -p" [mountPoint] |
219 | mounted <- cmd "mountpoint -q" [mountPoint] <&> (== ExitSuccess) | 222 | mounted <- cmd "mountpoint -q" [mountPoint] <&> (== ExitSuccess) |
220 | when mounted $ cmd_ "umount" [mountPoint] | 223 | when mounted $ cmd_ "umount" [mountPoint] |
224 | |||
221 | cmd_ "mount -o compress,ro -t btrfs" [imageFile, mountPoint] | 225 | cmd_ "mount -o compress,ro -t btrfs" [imageFile, mountPoint] |
222 | 226 | ||
223 | addImageToBtrfs :: FilePath -> FilePath -> Action () | 227 | addImageToBtrfs :: FilePath -> FilePath -> Action () |
@@ -313,6 +317,8 @@ chrootImage target args = | |||
313 | cmd_ "cp --reflink=always" [inp, tmp] | 317 | cmd_ "cp --reflink=always" [inp, tmp] |
314 | cmd_ "btrfstune -S0 -f" tmp | 318 | cmd_ "btrfstune -S0 -f" tmp |
315 | cmd_ "mkdir" [mnt] | 319 | cmd_ "mkdir" [mnt] |
320 | |||
321 | setupLoopDevices target | ||
316 | cmd_ "mount -t btrfs" [tmp, mnt] | 322 | cmd_ "mount -t btrfs" [tmp, mnt] |
317 | let (umount :: IO ()) = do | 323 | let (umount :: IO ()) = do |
318 | cmd_ "umount" [mnt] | 324 | cmd_ "umount" [mnt] |