@@ -126,9 +126,11 @@ fn mkfs<'a>(
126
126
label : & str ,
127
127
opts : impl IntoIterator < Item = & ' a str > ,
128
128
) -> Result < uuid:: Uuid > {
129
+ let devinfo = crate :: blockdev:: list_dev ( dev. into ( ) ) ?;
130
+ let size = devinfo. size . as_deref ( ) . unwrap_or ( "(unknown)" ) ;
129
131
let u = uuid:: Uuid :: new_v4 ( ) ;
130
132
let mut t = Task :: new (
131
- & format ! ( "Creating {label} filesystem ({fs})" ) ,
133
+ & format ! ( "Creating {label} filesystem ({fs}) on device {dev} (size={size}) " ) ,
132
134
format ! ( "mkfs.{fs}" ) ,
133
135
) ;
134
136
match fs {
@@ -170,6 +172,8 @@ pub(crate) fn install_create_rootfs(
170
172
// Verify that the target is empty (if not already wiped in particular, but it's
171
173
// also good to verify that the wipe worked)
172
174
let device = crate :: blockdev:: list_dev ( & opts. device ) ?;
175
+ // Canonicalize devpath
176
+ let devpath: Utf8PathBuf = device. path ( ) . into ( ) ;
173
177
174
178
// Handle wiping any existing data
175
179
if opts. wipe {
@@ -193,20 +197,6 @@ pub(crate) fn install_create_rootfs(
193
197
if mntdir. exists ( ) {
194
198
std:: fs:: remove_dir_all ( & mntdir) ?;
195
199
}
196
- let devdir = mntdir. join ( "dev" ) ;
197
- std:: fs:: create_dir_all ( & devdir) ?;
198
- Task :: new ( "Mounting devtmpfs" , "mount" )
199
- . args ( [ "devtmpfs" , "-t" , "devtmpfs" , devdir. as_str ( ) ] )
200
- . quiet ( )
201
- . run ( ) ?;
202
-
203
- // Now at this point, our /dev is a stale snapshot because we don't have udev running.
204
- // So from hereon after, we prefix devices with our temporary devtmpfs mount.
205
- let reldevice = opts
206
- . device
207
- . strip_prefix ( "/dev/" )
208
- . context ( "Absolute device path in /dev/ required" ) ?;
209
- let device = devdir. join ( reldevice) ;
210
200
211
201
// Use the install configuration to find the block setup, if we have one
212
202
let block_setup = if let Some ( config) = state. install_config . as_ref ( ) {
@@ -245,7 +235,7 @@ pub(crate) fn install_create_rootfs(
245
235
// sgdisk is too verbose
246
236
sgdisk. cmd . stdout ( Stdio :: null ( ) ) ;
247
237
sgdisk. cmd . arg ( "-Z" ) ;
248
- sgdisk. cmd . arg ( & device) ;
238
+ sgdisk. cmd . arg ( device. path ( ) ) ;
249
239
sgdisk. cmd . args ( [ "-U" , "R" ] ) ;
250
240
#[ allow( unused_assignments) ]
251
241
if cfg ! ( target_arch = "x86_64" ) {
@@ -316,27 +306,28 @@ pub(crate) fn install_create_rootfs(
316
306
{
317
307
let mut f = std:: fs:: OpenOptions :: new ( )
318
308
. write ( true )
319
- . open ( & device )
320
- . with_context ( || format ! ( "opening {device }" ) ) ?;
309
+ . open ( & devpath )
310
+ . with_context ( || format ! ( "opening {devpath }" ) ) ?;
321
311
crate :: blockdev:: reread_partition_table ( & mut f, true )
322
312
. context ( "Rereading partition table" ) ?;
323
313
}
324
314
315
+ // Full udev sync; it'd obviously be better to await just the devices
316
+ // we're targeting, but this is a simple coarse hammer.
325
317
crate :: blockdev:: udev_settle ( ) ?;
326
318
327
319
// Now inspect the partitioned device again so we can find the names of the child devices.
328
- let device_partitions = crate :: blockdev:: list_dev ( & device ) ?
320
+ let device_partitions = crate :: blockdev:: list_dev ( & devpath ) ?
329
321
. children
330
322
. ok_or_else ( || anyhow:: anyhow!( "Failed to find children after partitioning" ) ) ?;
331
323
// Given a partition number, return the path to its device.
332
324
let findpart = |idx : u32 | -> Result < String > {
333
325
// checked_sub is here because our partition numbers start at 1, but the vec starts at 0
334
- let devname = device_partitions
326
+ let devpath = device_partitions
335
327
. get ( idx. checked_sub ( 1 ) . unwrap ( ) as usize )
336
328
. ok_or_else ( || anyhow:: anyhow!( "Missing partition for index {idx}" ) ) ?
337
- . name
338
- . as_str ( ) ;
339
- Ok ( devdir. join ( devname) . to_string ( ) )
329
+ . path ( ) ;
330
+ Ok ( devpath)
340
331
} ;
341
332
342
333
let base_rootdev = findpart ( rootpn) ?;
@@ -440,7 +431,7 @@ pub(crate) fn install_create_rootfs(
440
431
} ;
441
432
Ok ( RootSetup {
442
433
luks_device,
443
- device,
434
+ device : devpath ,
444
435
rootfs,
445
436
rootfs_fd,
446
437
rootfs_uuid : Some ( root_uuid. to_string ( ) ) ,
0 commit comments