Skip to content

Commit

Permalink
use kpartx instead of partprobe (close #19)
Browse files Browse the repository at this point in the history
Signed-off-by: Adphi <[email protected]>
  • Loading branch information
Adphi committed Feb 15, 2023
1 parent 8659907 commit 618b5bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ RUN apt-get update && \
util-linux \
udev \
parted \
kpartx \
e2fsprogs \
mount \
tar \
Expand Down
7 changes: 5 additions & 2 deletions builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ func (b *builder) mountImg(ctx context.Context) error {
return err
}
b.loDevice = strings.TrimSuffix(o, "\n")
if err := exec.Run(ctx, "partprobe", b.loDevice); err != nil {
if err := exec.Run(ctx, "kpartx", "-a", b.loDevice); err != nil {
return err
}
b.loPart = fmt.Sprintf("%sp1", b.loDevice)
b.loPart = fmt.Sprintf("/dev/mapper/%sp1", filepath.Base(b.loDevice))
logrus.Infof("creating raw image file system")
if err := exec.Run(ctx, "mkfs.ext4", b.loPart); err != nil {
return err
Expand All @@ -285,6 +285,9 @@ func (b *builder) unmountImg(ctx context.Context) error {
if err := exec.Run(ctx, "umount", b.mntPoint); err != nil {
merr = multierr.Append(merr, err)
}
if err := exec.Run(ctx, "kpartx", "-d", b.loDevice); err != nil {
merr = multierr.Append(merr, err)
}
if err := exec.Run(ctx, "losetup", "-d", b.loDevice); err != nil {
merr = multierr.Append(merr, err)
}
Expand Down

0 comments on commit 618b5bc

Please sign in to comment.