forked from Bitmessage/sysdeploy
add: partitioning functionality
This commit is contained in:
parent
6e8fc65465
commit
7ac8630a57
25
drive.inc
Normal file
25
drive.inc
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
function setup_drive
|
||||
{
|
||||
local drive="$1"
|
||||
parted -s "$drive" -- \
|
||||
mklabel gpt \
|
||||
unit MiB \
|
||||
mkpart '"EFI system partition"' fat32 1 1024 \
|
||||
set 1 esp on \
|
||||
mkpart '"root unused"' ext4 1025 2048 \
|
||||
mkpart '"root unused"' ext4 2049 3072 \
|
||||
mkpart '"root unused"' ext4 3073 4096 \
|
||||
mkpart Encrypted ext4 4097 -1
|
||||
}
|
||||
|
||||
function rename_partition
|
||||
{
|
||||
local drive="$1"
|
||||
local partition="$2"
|
||||
local new_label="$3"
|
||||
parted -s "$drive" -- name "$partition" '"'"$new_label"'"'
|
||||
}
|
||||
|
||||
# vim: set ft=sh:
|
22
tests/drive.sh
Executable file
22
tests/drive.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
function test_partitioning()
|
||||
{
|
||||
local img
|
||||
img=$(mktemp -u)
|
||||
qemu-img create -f qcow2 "$img" 16G
|
||||
sudo modprobe nbd
|
||||
sudo qemu-nbd -c /dev/nbd0 "$img"
|
||||
sudo setup_drive /dev/nbd0
|
||||
sudo parted -ms /deb/nbd0 -- print
|
||||
sudo qemu-nbd -d /dev/nbd0
|
||||
rm -f "$img"
|
||||
}
|
||||
|
||||
function oneTimeSetUp()
|
||||
{
|
||||
. drive.inc
|
||||
}
|
||||
|
||||
# Load shUnit2.
|
||||
. /usr/bin/shunit2
|
Loading…
Reference in New Issue
Block a user