@@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize};
22
22
23
23
use super :: MountSpec ;
24
24
use super :: RootSetup ;
25
- use super :: State ;
25
+ use super :: RUN_BOOTC ;
26
26
use super :: RW_KARG ;
27
27
use crate :: lsm:: lsm_label;
28
28
use crate :: mount;
@@ -156,10 +156,7 @@ fn mkfs<'a>(
156
156
}
157
157
158
158
#[ context( "Creating rootfs" ) ]
159
- pub ( crate ) fn install_create_rootfs (
160
- state : & State ,
161
- opts : InstallBlockDeviceOpts ,
162
- ) -> Result < RootSetup > {
159
+ pub ( crate ) fn install_create_rootfs ( opts : InstallBlockDeviceOpts ) -> Result < RootSetup > {
163
160
// Verify that the target is empty (if not already wiped in particular, but it's
164
161
// also good to verify that the wipe worked)
165
162
let device = crate :: blockdev:: list_dev ( & opts. device ) ?;
@@ -181,13 +178,26 @@ pub(crate) fn install_create_rootfs(
181
178
) ;
182
179
}
183
180
181
+ let run_bootc = Utf8Path :: new ( RUN_BOOTC ) ;
182
+ let mntdir = run_bootc. join ( "mounts" ) ;
183
+ if mntdir. exists ( ) {
184
+ std:: fs:: remove_dir_all ( & mntdir) ?;
185
+ }
186
+ let devdir = mntdir. join ( "dev" ) ;
187
+ std:: fs:: create_dir_all ( & devdir) ?;
188
+ Task :: new_and_run (
189
+ "Mounting devtmpfs" ,
190
+ "mount" ,
191
+ [ "devtmpfs" , "-t" , "devtmpfs" , devdir. as_str ( ) ] ,
192
+ ) ?;
193
+
184
194
// Now at this point, our /dev is a stale snapshot because we don't have udev running.
185
195
// So from hereon after, we prefix devices with our temporary devtmpfs mount.
186
196
let reldevice = opts
187
197
. device
188
198
. strip_prefix ( "/dev/" )
189
199
. context ( "Absolute device path in /dev/ required" ) ?;
190
- let device = state . devdir . join ( reldevice) ;
200
+ let device = devdir. join ( reldevice) ;
191
201
192
202
let root_size = opts
193
203
. root_size
@@ -198,9 +208,9 @@ pub(crate) fn install_create_rootfs(
198
208
199
209
// Create a temporary directory to use for mount points. Note that we're
200
210
// in a mount namespace, so these should not be visible on the host.
201
- let rootfs = state . mntdir . join ( "rootfs" ) ;
211
+ let rootfs = mntdir. join ( "rootfs" ) ;
202
212
std:: fs:: create_dir_all ( & rootfs) ?;
203
- let bootfs = state . mntdir . join ( "boot" ) ;
213
+ let bootfs = mntdir. join ( "boot" ) ;
204
214
std:: fs:: create_dir_all ( bootfs) ?;
205
215
206
216
// Run sgdisk to create partitions.
0 commit comments