diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2017-11-22 14:42:51 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2017-11-22 14:54:00 +0000 |
commit | 5ed0f8e6c705179b3a7d82c3b7dc62c05ab15fc9 (patch) | |
tree | 0260633b3751fd5ddfd80be816799c010a216d9a /setup-disk.in | |
parent | 7d226111c9315db4900461d3482f0bcb8f3c9c34 (diff) | |
download | alpine-conf-5ed0f8e6c705179b3a7d82c3b7dc62c05ab15fc9.zip |
setup-disk: use uuid for swap in fstab
also fix potential issue where we may have multiple swap devices
Diffstat (limited to 'setup-disk.in')
-rw-r--r-- | setup-disk.in | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/setup-disk.in b/setup-disk.in index 1d1c1e1..208cffa 100644 --- a/setup-disk.in +++ b/setup-disk.in @@ -439,9 +439,12 @@ install_mounted_root() { mv "$mnt"/etc/fstab "$mnt"/etc/fstab.old fi enumerate_fstab "$mnt" >> "$mnt"/etc/fstab - if [ -n "$SWAP_DEVICE" ]; then - echo -e "${SWAP_DEVICE}\tswap\tswap\tdefaults\t0 0" \ - >> "$mnt"/etc/fstab + if [ -n "$SWAP_DEVICES" ]; then + local swap_dev + for swap_dev in $SWAP_DEVICES; do + echo -e "$(uuid_or_device ${swap_dev})\tswap\tswap\tdefaults\t0 0" \ + >> "$mnt"/etc/fstab + done fi cat >>"$mnt"/etc/fstab <<-__EOF__ /dev/cdrom /media/cdrom iso9660 noauto,ro 0 0 @@ -766,11 +769,12 @@ setup_lvm_volume_group() { setup_swap_dev() { local swap_dev= sed -i -e '/swap/d' /etc/fstab + SWAP_DEVICES= for swap_dev in "$@"; do mkswap $swap_dev >/dev/null - echo -e "$swap_dev\tswap\t\tswap\tdefaults 0 0" >> /etc/fstab + echo -e "$(uuid_or_device $swap_dev)\tswap\t\tswap\tdefaults 0 0" >> /etc/fstab + SWAP_DEVICES="$SWAP_DEVICES $swap_dev" done - SWAP_DEVICE="$(uuid_or_device $swap_dev)" swapon -a rc-update --quiet add swap boot } |