From patchwork Fri Jan 19 18:08:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quirin Gylstorff X-Patchwork-Id: 3309 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Fri, 19 Jan 2024 19:08:44 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-qv1-f55.google.com (mail-qv1-f55.google.com [209.85.219.55]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 40JI8h54015697 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 19 Jan 2024 19:08:43 +0100 Received: by mail-qv1-f55.google.com with SMTP id 6a1803df08f44-67f8c9542c6sf15003296d6.0 for ; Fri, 19 Jan 2024 10:08:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705687717; cv=pass; d=google.com; s=arc-20160816; b=Tv4lSrhr8zOs9GxiTaxPdFIrRfZqNMcBuhMFGmp/u47xLykjCYXtmL5S+6DplpvMfs EnTLPnpF85JssIf//rP9+Src2D4bZVryXEswUDWGBc5WK3AXfoWnIihTHtfzVVe7veZx aUJRJ2h+clJTv8jDVlsqEOFlP0au+MmhObz0vVNSa/ZqqEiAejbVa+u6LuO9fC4gQH9I lsJgx+HlwduXfC1DuZ+9mEVOJzBX7pSoJZnPmvWE9X6Sj1k9C+Br8t0X4ERAiJuvUqJO fy8X/E0TtEJHAlONYjXIpP8hOjxJO0Njdau/32Xxnw82jmlTFxo2bhITWcZ4/VGAUNGs 5xbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:feedback-id:mime-version :message-id:date:subject:to:from:dkim-signature; bh=z6z3pkzWdL8XuBQZc+XDi2eZeQdwciH6c1p1IoJwRRs=; fh=7tclEdh7YbwSQowgJ6LNq720O7H5HTEaqj22NJWRE2E=; b=d4UtSHSJmw6c1ITQ9zXUzbIU43Lzg2wQNpcEI/d5QBZw+YtP4tvyNQO6Tg9fewsznF Nl2OmatvpLaGtAcUCschepdMlqBQbeRwVBSLeIqOa6OxVX5JNFYvYxH2HtWtOmDLh8+2 1Hr/S+piZ4H0Id8dJ68iqcvSIZtvW7cEhd6ZL5hYDs+i5Zw6lJ6/wXXaavhlI5k7tZj9 WTWjcu5xFNGr+/v+SE4iSt6FjT11eWAtP35uMSFlrf+svw7znQZ2qy3YS4oW7BVRaUwA WhzE9sDSoZcHvRbJzHNokB/l9w77QD1xTeWRrsyQPVE/p/e0xOy0KI4aPmhvoOzlMWOU WA5A== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=kQt4hjPm; spf=pass (google.com: domain of fm-51332-202401191808349bf79a3469ad0e7f00-_vzd9p@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-51332-202401191808349bf79a3469ad0e7f00-_VZd9P@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1705687717; x=1706292517; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=z6z3pkzWdL8XuBQZc+XDi2eZeQdwciH6c1p1IoJwRRs=; b=hxtql939NafByrsTq2Ope2t6ZjsecK//TOFg0FvJP6RemlnEao+Ei6fAu7zyKW92P9 OSKkJULKSoBYDjl5E6WgzTBVxAiGfGySaeGBkRs6r7U6TuNxjwJ/Di6bkLuC0+1/z/xe 1/X8vdJlGzvh1xs1TUmtrMtK7njxNZW2UcQPoa/a6vDTW0iYxvCsxZow7SfVAsXdGIwm pXxgQYUsDehl4584wKBtFOxbxdPd00SXR6ChUvJoUmiZuUHy3t9TiR0owT60SL6x8XdO m6GfSGGgWjW+gzDy0JR5jKnvZtzVjP01mwkmwLxSZ6zT5x0p9VMc5qVGfSDin8gnw5Nn 28EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705687717; x=1706292517; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:message-id:date:subject:to:from:x-beenthere :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z6z3pkzWdL8XuBQZc+XDi2eZeQdwciH6c1p1IoJwRRs=; b=MDXZr6aKWzjP98xqpb0gfv6fQsaaoi//lhXbhfQ8aSAuQIytfjStCncVFrDMHj6BfH jtgslFCr6isgx0kVxd398zqpv357adm3VhOW+u5+05377h6cTmaIzlwffFf7GzToVZV2 p53ufG418p7Tf7Dw7DW9ym9FArDvXGJY5HQxxQI7IHgmazgFpeMka7snjI9ezwVHpGJm bijFOr1pf5dZbzE8ipRANHrrwPdoVt1Q18wf2woOQis5KRb6Q3H6ylQG1l1sQIVFetRD KeoH/cB/N/t83SUCNjIts/YHDdaFZnrTabPzl+Ub6GvMkU/f7F+UlvHdnd5U87BVdFwS ss+w== X-Gm-Message-State: AOJu0YxmkTFFeLxBb6sQAxZ9pGyuWZa44gEIYBbLHvlxcdQi/8QUswQ6 IXd5Xbn7UEoxPOldoI4oCfEOB72IplGr7Wm0ZeQsYQvmpLZF+MY+ X-Google-Smtp-Source: AGHT+IGt/vbBG44vpub4d8IXDSt371VyiTua77nbyNxz2aVTBZzWpJCN2cXliDa4nTyts80s4DDH2A== X-Received: by 2002:a0c:f513:0:b0:681:6f49:17bb with SMTP id j19-20020a0cf513000000b006816f4917bbmr209913qvm.124.1705687717229; Fri, 19 Jan 2024 10:08:37 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a0c:b345:0:b0:67a:203f:dbc7 with SMTP id a5-20020a0cb345000000b0067a203fdbc7ls1779770qvf.1.-pod-prod-06-us; Fri, 19 Jan 2024 10:08:36 -0800 (PST) X-Received: by 2002:ac5:cbf5:0:b0:4b7:8d7c:347d with SMTP id i21-20020ac5cbf5000000b004b78d7c347dmr107283vkn.10.1705687716283; Fri, 19 Jan 2024 10:08:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705687716; cv=none; d=google.com; s=arc-20160816; b=0T2XutiM6S1PBc2/Q8pc70URDxdWrGuel5qpqG3ElPSEajK5G8rXWIDYqSMCKrYhyg c2uHGsSx/lMT6/tggEe2c4p9l+bBq6A+YM5Nd5i1SCaD42a1vAZ4dPQvevp5BOyCGZkM KU6geWmIUgWpHpG2lTDL25gmQeH2PWbFsU2gRidRLPA38nCVXSRlR6tEBBxqxsYExvTT ZCJVe1PSENyxZnxDG/ybuFr/dLhx2rIMqnU28IdHZxBX+g8SEJN4zLghTrFVFrgp02i+ MJT/gIuQUXETWM/nXOx+YAaLPjMyzNWpepSxWu+FXX/oPsarefq9iQ4hoNSLibKmSZqN H8iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:message-id:date :subject:to:from:dkim-signature; bh=o6Y7c4e3ZNLDbqJT/P1smMpCN4kasX4z9vq5OGIJRx8=; fh=7tclEdh7YbwSQowgJ6LNq720O7H5HTEaqj22NJWRE2E=; b=QkX8urrP7PvC7SKynOWhxwrpqY+wUAfDSw+uc/edbtyq65uFs/wys+dvL7oDjrSJVg GYr3JjiKxMyVILK8ryPDPCqfjre6KGtaLOFKsxLA88emK7ZPRAZu5k5TLsaPH/imQK78 wYEAuCnjQ5w0o6ejh3ipyU19rs/O4OqcWFI7CxxThUr2PpJSMgz66DzLZJMNOUOdB3YJ QgDnnjIA34Qu2+vpg4sEh0R2igMNWEqilqwGhnmSY1DaIdon317U+bneCrEBaAbBm9O0 d7ZXI2BOr5mDmqKnOkkTK0p/m/RNcYZv72cpkILPLgmV184bi2azhbaBDbaMqM2qjMk8 K8dA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=kQt4hjPm; spf=pass (google.com: domain of fm-51332-202401191808349bf79a3469ad0e7f00-_vzd9p@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-51332-202401191808349bf79a3469ad0e7f00-_VZd9P@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-65-226.siemens.flowmailer.net (mta-65-226.siemens.flowmailer.net. [185.136.65.226]) by gmr-mx.google.com with ESMTPS id p129-20020a1fd887000000b004b7487bda5asi2223635vkg.3.2024.01.19.10.08.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jan 2024 10:08:36 -0800 (PST) Received-SPF: pass (google.com: domain of fm-51332-202401191808349bf79a3469ad0e7f00-_vzd9p@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) client-ip=185.136.65.226; Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 202401191808349bf79a3469ad0e7f00 for ; Fri, 19 Jan 2024 19:08:34 +0100 X-Patchwork-Original-From: "'Quirin Gylstorff' via isar-users" From: Quirin Gylstorff To: isar-users@googlegroups.com Subject: [PATCH] expand-on-first-boot: Expand crypto_LUKS partition Date: Fri, 19 Jan 2024 19:08:11 +0100 Message-ID: <20240119180833.2097721-1-Quirin.Gylstorff@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-51332:519-21489:flowmailer X-Original-Sender: quirin.gylstorff@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=kQt4hjPm; spf=pass (google.com: domain of fm-51332-202401191808349bf79a3469ad0e7f00-_vzd9p@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-51332-202401191808349bf79a3469ad0e7f00-_VZd9P@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Quirin Gylstorff Reply-To: Quirin Gylstorff Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: Quirin Gylstorff Add the option to expand a encrypted LUKS partition. A passphrase is required to resize the partition. If cryptsetup is not installed the service still fails with an error message. Signed-off-by: Quirin Gylstorff --- .../files/expand-last-partition.sh | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh index 7d658864..94962e40 100755 --- a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh +++ b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh @@ -65,14 +65,28 @@ fi # some filesystems need to be mounted i.e. btrfs, but mounting also helps # detect the filesystem type without having to wait for udev # mount $LAST_PART out of tree, so we won't conflict with other mounts -MOUNT_POINT=$(mktemp -d -p "" "$(basename "$0").XXXXXXXXXX") -mount "${LAST_PART}" "${MOUNT_POINT}" - ret=0 # Determine the filesystem type and perform the appropriate resize function -FS_TYPE=$(findmnt -fno FSTYPE "${MOUNT_POINT}" ) +FS_TYPE=$(blkid --output value --match-tag TYPE "${LAST_PART}" ) +MOUNT_POINT=$(mktemp -d -p "" "$(basename "$0").XXXXXXXXXX") +if [ "$FS_TYPE" = "crypto_LUKS" ]; then + if [ ! -x /usr/sbin/cryptsetup ]; then + echo "'cryptsetup' is missing cannot resize last partition as it is from type 'crypto_LUKS'" + exit 1 + fi + last_part_device_name=${LAST_PART#\/dev/} + + mapping_name=$(cat /sys/class/block/"$last_part_device_name"/holders/*/dm/name) + cryptsetup resize "$mapping_name" + mount /dev/mapper/"$mapping_name" "${MOUNT_POINT}" + FS_TYPE=$(findmnt -fno FSTYPE "${MOUNT_POINT}" ) + LAST_PART=/dev/mapper/"$mapping_name" +else + mount "${LAST_PART}" "${MOUNT_POINT}" +fi case ${FS_TYPE} in ext*) + # Do not fail resize2fs if no mtab entry is found, e.g., # when using systemd mount units. export EXT2FS_NO_MTAB_OK=1