SHARE
TWEET

Untitled

a guest Oct 21st, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function add_drive () {
  2.   local name="$1"
  3.   local label="$2"
  4.   local size="$3"
  5.   local filename="$4"
  6.  
  7.   log_progress "Allocating ${size}K for $filename..."
  8.   fallocate -l "$size"K "$filename"
  9.   echo "type=83" | sfdisk "$filename" > /dev/null
  10.   local partition_offset=$(first_partition_offset "$filename")
  11.   losetup -o $partition_offset loop0 "$filename"
  12.   log_progress "Creating filesystem with label '$label'"
  13.   mkfs.ext4 /dev/loop0
  14.   e2label /dev/loop0 "$label"
  15.   losetup -d /dev/loop0
  16.  
  17.   local mountpoint=/mnt/"$name"
  18.  
  19.   if [ ! -e "$mountpoint" ]
  20.   then
  21.     mkdir "$mountpoint"
  22.   fi
  23.   sed -i "\@^$filename .*@d" /etc/fstab
  24.   echo "$filename $mountpoint ext4 utf8,noauto,users,umask=000,offset=$partition_offset 0 0" >> /etc/fstab
  25.   log_progress "updated /etc/fstab for $mountpoint"
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top