]>
git.zerfleddert.de Git - m1-debian/blob - files/rc.local
651a9086464a78047e6806c3b92391553cf7e6a5
3 # [x] resize root filesystem
4 # [x] find root fs uuid
5 # [ ] find boot partition
9 # [ ] extract wifi firmware
10 # [ ] reboots if grub or wifi firmware has changed
12 my $root_block_device = undef;
13 my $root_fs_uuid = undef;
14 my $efi_block_device = undef;
19 open(MOUNT
, '<', '/proc/mounts') || die ("Can not open /proc/mounts for reading: $!");
24 if (/^([\S]+)+ \/ /) {
29 die("Could not find root device");
33 find_fs_uuid_of_device
35 my $dev = shift || die;
36 my $blkid_output = `blkid ${dev}`;
37 # /dev/nvme0n1p5: LABEL="/" UUID="fe9c5ac8-edf4-442e-a09e-e0451606898e" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="primary" PARTUUID="03378b79-346d-42f9-b404-44b22bc6798f"
38 if ($blkid_output =~ /UUID="([^"]+)"/) {
42 die("Could not find fs uuid of $dev");
48 my $uuid_in_grub_cfg = shift || die;
51 my $efi_parition = undef;
54 if (/^([\S]+):.*TYPE="vfat"/) {
55 push(@candidates, $1);
59 for my $dev (@candidates) {
60 system("mount -o ro $dev /mnt");
61 if (-f
'/mnt/EFI/boot/grub.cfg') {
62 open(GRUBCFG
, '<', '/mnt/EFI/boot/grub.cfg') || die ("Can't open /mnt/EFI/boot/grub.cfg: $!");
63 my @lines = <GRUBCFG
>;
65 if (/${uuid_in_grub_cfg}/) {
71 system("umount /mnt");
72 last if defined $efi_parition;
75 die ("No efi parition found") unless defined $efi_parition;
81 $root_block_device = find_root_device
();
82 # system("resize2fs $root_block_device");
84 $root_fs_uuid = find_fs_uuid_of_device
($root_block_device);
85 $efi_block_device = find_efi_parition
($root_fs_uuid);