Skip to content

Commit

Permalink
Find free losetup devices automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
kost committed Feb 11, 2020
1 parent 1caa809 commit 3858181
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions scripts/createimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# create image from rootfs.tar.gz

# Use losetup -f to find free `loop devices
LOOP_DEVICE1=/dev/loop20
LOOP_DEVICE2=/dev/loop21

# Create a 32MB image file
rm image
Expand All @@ -12,13 +10,11 @@ dd if=/dev/zero of=image bs=1M count=32
# Create 1 Linux partition
fdisk image <fdisk.cmd

# Detach loop devices
sudo losetup -d ${LOOP_DEVICE1}
sudo losetup -d ${LOOP_DEVICE2}

LOOP_DEVICE1=`losetup -f`
# Set loop device 1 to the whole file
sudo losetup ${LOOP_DEVICE1} image

LOOP_DEVICE2=`losetup -f`
# Set loop device 2 to the start of partition
sudo losetup -o $((512*2048)) ${LOOP_DEVICE2} ${LOOP_DEVICE1}

Expand Down

0 comments on commit 3858181

Please sign in to comment.