]>
cvs.zerfleddert.de Git - m1-debian/blob - files/rc.local
3 # [x] resize root filesystem
4 # [x] find root fs uuid
5 # [x] find boot partition
9 # [ ] extract wifi firmware
10 # [ ] reboots if grub or wifi firmware has changed
15 open(MOUNT
, '<', '/proc/mounts') || die ("Can not open /proc/mounts for reading: $!");
20 if (/^([\S]+)+ \/ /) {
25 die("Could not find root device");
29 find_fs_uuid_of_device
31 my $dev = shift || die;
32 my $blkid_output = `blkid ${dev}`;
33 # /dev/nvme0n1p5: LABEL="/" UUID="fe9c5ac8-edf4-442e-a09e-e0451606898e" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="primary" PARTUUID="03378b79-346d-42f9-b404-44b22bc6798f"
34 if ($blkid_output =~ /UUID="([^"]+)"/) {
38 die("Could not find fs uuid of $dev");
44 my $uuid_in_grub_cfg = shift || die;
47 my $efi_parition = undef;
50 if (/^([\S]+):.*TYPE="vfat"/) {
51 push(@candidates, $1);
55 for my $dev (@candidates) {
56 system("mount -o ro $dev /mnt");
57 if (-f
'/mnt/EFI/boot/grub.cfg') {
58 open(GRUBCFG
, '<', '/mnt/EFI/boot/grub.cfg') || die ("Can't open /mnt/EFI/boot/grub.cfg: $!");
59 my @lines = <GRUBCFG
>;
61 if (/${uuid_in_grub_cfg}/) {
67 system("umount /mnt");
68 last if defined $efi_parition;
71 die ("No efi parition found") unless defined $efi_parition;
79 my $root_fs_uuid = shift || die;
80 my $efi_fs_uuid = shift || die;
82 open(FSTAB
, '>', '/etc/fstab') || die ("Can not open fstab");
85 UUID="$root_fs_uuid" / ext4 defaults 0 0
86 UUID="$efi_fs_uuid" /boot/efi vfat defaults 0 0
91 my $root_block_device = undef;
92 my $root_fs_uuid = undef;
93 my $efi_block_device = undef;
94 my $efi_fs_uuid = undef;
96 unless (-f
'/etc/fstab') {
97 $root_block_device = find_root_device
();
98 system("resize2fs $root_block_device");
99 $root_fs_uuid = find_fs_uuid_of_device
($root_block_device);
100 $efi_block_device = find_efi_parition
($root_fs_uuid);
101 $efi_fs_uuid = find_fs_uuid_of_device
($efi_block_device);
102 generate_fstab
($root_fs_uuid, $efi_fs_uuid);
103 system('mount /boot/efi');