#1112 PR merged: Support partitioning and formatting huge USB devices

Labels: enhancement, fixed / solved / done

jsmeix opened issue at 2016-12-07 16:29:

To support partitioning and formatting a huge medium
by the format workflow there are new variables:
USB_DEVICE_FILESYSTEM specifies the filesystem
to use when formatting a medium via the format workflow.
USB_DEVICE_FILESYSTEM_PERCENTAGE specifies the
percentage of the whole medium that is used for ReaR partitions
when formatting a medium via the format workflow.
For details see conf/default.conf
Cf. https://github.com/rear/rear/issues/1105

jsmeix commented at 2016-12-08 12:36:

The current code seems to work well for me.
On my virtual machine I use a second virtual disk /dev/sdb
for the 'format' workflow.
What I tested so far:

# cat etc/rear/local.conf

USB_DEVICE_PARTED_LABEL=gpt
USB_DEVICE_FILESYSTEM=ext4
USB_DEVICE_FILESYSTEM_PERCENTAGE=90
USB_UEFI_PART_SIZE=""
MESSAGE_PREFIX="$$: "
...

# usr/sbin/rear -d -D format /dev/sdb
Relax-and-Recover 1.19 / Git
Using log file: /root/rear/var/log/rear/rear-f79.log
USB device /dev/sdb is not formatted with ext2/3/4 or btrfs filesystem
Type exactly 'Yes' to format /dev/sdb with ext4 filesystem: Yes
2360: Repartitioning '/dev/sdb'
2360: Creating partition table of type 'gpt' on '/dev/sdb'
2360: Creating ReaR data partition up to 90% of '/dev/sdb'
2360: Creating ext4 filesystem with label 'REAR-000' on '/dev/sdb1'
2360: Adjusting filesystem parameters on '/dev/sdb1'

# parted -s /dev/sdb unit % print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 100%
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 
Number  Start  End    Size   File system  Name     Flags
 1      0.00%  90.0%  90.0%  ext4         primary  boot

# export EFI="y"

# usr/sbin/rear -d -D format /dev/sdb
Relax-and-Recover 1.19 / Git
Using log file: /root/rear/var/log/rear/rear-f79.log
USB device /dev/sdb is not formatted with ext2/3/4 or btrfs filesystem
Type exactly 'Yes' to format /dev/sdb with ext4 filesystem: Yes
2886: Repartitioning '/dev/sdb'
2886: The --efi toggle was used with format - making an EFI bootable device '/dev/sdb'
Enter size for EFI system partition on '/dev/sdb' in MB (plain 'Enter' defaults to 100 MB): 
2886: Creating GUID partition table (GPT) on '/dev/sdb'
2886: Creating EFI system partition with size 100 MB on '/dev/sdb'
2886: Creating ReaR data partition up to 90% of '/dev/sdb'
2886: Creating vfat filesystem on EFI system partition on '/dev/sdb1'
2886: Creating ext4 filesystem with label 'REAR-000' on '/dev/sdb2'
2886: Adjusting filesystem parameters on '/dev/sdb2'

# parted -s /dev/sdb unit % print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 100%
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 
Number  Start  End    Size   File system  Name     Flags
 1      0.00%  1.63%  1.63%  fat16        primary  boot
 2      1.63%  90.0%  88.4%  ext4         primary

# usr/sbin/rear -d -D format /dev/sdb
Relax-and-Recover 1.19 / Git
Using log file: /root/rear/var/log/rear/rear-f79.log
USB device /dev/sdb is not formatted with ext2/3/4 or btrfs filesystem
Type exactly 'Yes' to format /dev/sdb with ext4 filesystem: Yes
3518: Repartitioning '/dev/sdb'
3518: The --efi toggle was used with format - making an EFI bootable device '/dev/sdb'
Enter size for EFI system partition on '/dev/sdb' in MB (plain 'Enter' defaults to 100 MB): -120
Invalid EFI system partition size value '-120' (must be unsigned integer larger than 0)
Enter size for EFI system partition on '/dev/sdb' in MB (plain 'Enter' defaults to 100 MB): 12o
Invalid EFI system partition size value '12o' (must be unsigned integer larger than 0)
Enter size for EFI system partition on '/dev/sdb' in MB (plain 'Enter' defaults to 100 MB): 12 0
Invalid EFI system partition size value '12 0' (must be unsigned integer larger than 0)
Enter size for EFI system partition on '/dev/sdb' in MB (plain 'Enter' defaults to 100 MB): 120
3518: Creating GUID partition table (GPT) on '/dev/sdb'
3518: Creating EFI system partition with size 120 MB on '/dev/sdb'
3518: Creating ReaR data partition up to 90% of '/dev/sdb'
3518: Creating vfat filesystem on EFI system partition on '/dev/sdb1'
3518: Creating ext4 filesystem with label 'REAR-000' on '/dev/sdb2'
3518: Adjusting filesystem parameters on '/dev/sdb2'

# parted -s /dev/sdb unit % print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 100%
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 
Number  Start  End    Size   File system  Name     Flags
 1      0.00%  1.95%  1.95%  fat16        primary  boot
 2      1.95%  90.0%  88.1%  ext4         primary

jsmeix commented at 2016-12-08 12:39:

I think I will merge the current state
so that others can easily test it and
provide feedback if something does not work.

jsmeix commented at 2016-12-08 12:41:

@gozora
what do you think:
Should I prefix the interactive 'echo' messages
with ${MESSAGE_PREFIX} or not?

gozora commented at 2016-12-08 13:12:

@jsmeix
As you stated in your comment in default.conf

...
basically a requirement when workflows are run 
simultaneously to get distinguishable messages
...

I don't think prefix would be of any use here.

jsmeix commented at 2016-12-08 13:25:

Of course the 'format' workflow is not intended to
be run simultaneously with other workflows.

What I meant was:
When the user has specified a MESSAGE_PREFIX
(as I did during my above tests), shouldn't then all
messages that are output from ReaR respect this
user setting?

gozora commented at 2016-12-08 13:28:

Yes, maybe you are right, logging should be uniform...


[Export of Github issue for rear/rear.]