# Data partition extension to end of sd card

**URL:** https://hub.mender.io/t/data-partition-extension-to-end-of-sd-card/379
**Category:** General Discussions
**Created:** [March 15, 2019, 9:35pm UTC](https://hub.mender.io/t/data-partition-extension-to-end-of-sd-card/379 "2019-03-15T21:35:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [March 15, 2019, 9:35pm UTC](https://hub.mender.io/t/data-partition-extension-to-end-of-sd-card/379/1 "2019-03-15T21:35:19Z")

</div>

Hi,

I would like to runtime extend data partition when board if first time booted. I have a case where SD cards have size 4 or 8GB. Mender image with app is ~2,5G and rest should be used for data. As I don’t want to extend size of sdimg (also not possible to have different SD card sizes). I was thinking about creating some systemd service which will do the trick but then realized that /data and /uboot are added to /etc/fstab and in this case systemd mount it. Was thinking about disabling autom ounting and add systemd mount scripts (based on label like e.g.)

```auto
[Unit]
Description=Mount data partition mountpoint

[Mount]
What=/dev/disk/by-label/data
Where=/mnt/data
Type=ext4

[Install]
WantedBy=multi-user.target

```

Then I can add dependent service file which will extend data partition to the end of sd card. Does anyone else have already some solution, ideas? Thanks.

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [March 15, 2019, 9:56pm UTC](https://hub.mender.io/t/data-partition-extension-to-end-of-sd-card/379/2 "2019-03-15T21:56:12Z")

</div>

It should be pretty safe to do a resize while it is mounted as you are adding space and if you are using ext4 filesystem it supports “live resizing”.

Examples doing this (these are typically for root part but can be easily modified to resize data part)

> **[96boards/96boards-tools](https://github.com/96boards/96boards-tools)**
>
> Tools and settings to help provide a common 96Boards developer experience - 96boards/96boards-tools

[http://git.toradex.com/cgit/meta-toradex-bsp-common.git/tree/recipes-core/fs-init/files?h=rocko](http://git.toradex.com/cgit/meta-toradex-bsp-common.git/tree/recipes-core/fs-init/files?h=rocko)

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [March 15, 2019, 9:58pm UTC](https://hub.mender.io/t/data-partition-extension-to-end-of-sd-card/379/3 "2019-03-15T21:58:01Z")

</div>

We are also thinking about adding something to meta-mender to simplify this as it is a pretty common use-case,

[https://tracker.mender.io/browse/MEN-2337](https://tracker.mender.io/browse/MEN-2337)

---

<div class="post-metadata">

### Author: ![tuupola](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/tuupola/32/187_2.png) [@tuupola](https://hub.mender.io/u/tuupola)
#### Post date: [April 8, 2019, 6:48am UTC](https://hub.mender.io/t/data-partition-extension-to-end-of-sd-card/379/4 "2019-04-08T06:48:24Z")

</div>

I use this with Raspbian images created with mender-convert.

```
[Unit]
Description=Expand data filesystem
ConditionPathExists=/dev/mmcblk0p4

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/resize2fs /dev/mmcblk0p4

[Install]
WantedBy=multi-user.target
```

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [April 8, 2019, 6:50am UTC](https://hub.mender.io/t/data-partition-extension-to-end-of-sd-card/379/5 "2019-04-08T06:50:53Z")

</div>

@tuupola thanks for sharing 👍 and welcome
