Merge pull request #3508 from federico-pellegatta/extend-pkg-gpt-support

Add GUID Partition Table (GPT) support to `extend` and `mount` packages
This commit is contained in:
Avi Deitcher 2020-04-24 16:16:50 +03:00 committed by GitHub
commit 6d1ffc9118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 137 additions and 34 deletions

View File

@ -17,7 +17,7 @@ onboot:
- name: format
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
services:

View File

@ -16,7 +16,7 @@ onboot:
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format", "/dev/sda"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/dev/sda1", "/var/external"]
- name: loop
image: linuxkit/losetup:0730b61ac5c8803ba73318c2dd5121dc15cfbf34
@ -25,7 +25,7 @@ onboot:
image: linuxkit/dm-crypt:0ea63bfd97b719d185b69994b4856d97fbc8a2dd
command: ["/usr/bin/crypto", "crypt_loop_dev", "/dev/loop0"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/dev/mapper/crypt_loop_dev", "/var/secure_storage"]
- name: bbox
image: busybox

View File

@ -19,7 +19,7 @@ onboot:
image: linuxkit/dm-crypt:0ea63bfd97b719d185b69994b4856d97fbc8a2dd
command: ["/usr/bin/crypto", "crypt_dev", "/dev/sda1"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/dev/mapper/crypt_dev", "/var/secure_storage"]
- name: bbox
image: busybox

View File

@ -22,7 +22,7 @@ onboot:
- name: format
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib"]
# make a swap file on the mounted disk
- name: swap

View File

@ -14,7 +14,7 @@ onboot:
- name: format
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
services:
- name: getty

View File

@ -15,7 +15,7 @@ onboot:
- name: format
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/external"]
- name: swap
image: linuxkit/swap:2cf5c3f08c4b238bb5fe231fd59ce19faee0fbc6

View File

@ -82,7 +82,10 @@ func extend(d, fsType string) error {
}
partition := f.PartitionTable.Partitions[0]
if partition.Type != "83" {
// fail on anything that isn't a Linux partition
// 83 -> MBR/DOS Linux Partition ID
// 0FC63DAF-8483-4772-8E79-3D69D8477DE4 -> GPT Linux Partition GUID
if partition.Type != "83" && partition.Type != "0FC63DAF-8483-4772-8E79-3D69D8477DE4" {
return fmt.Errorf("Partition 1 on disk %s is not a Linux Partition", d)
}
@ -176,7 +179,7 @@ func createPartition(d string, partition Partition) error {
}
createCmd := exec.Command("sfdisk", "-q", d)
createCmd.Stdin = strings.NewReader(fmt.Sprintf("%d,,83;", partition.Start))
createCmd.Stdin = strings.NewReader(fmt.Sprintf("%d,,%s;", partition.Start, partition.Type))
if err := createCmd.Run(); err != nil {
return fmt.Errorf("Error creating partition table: %v", err)
}

View File

@ -98,7 +98,9 @@ func findFirst(drives []string) (string, error) {
for _, partition := range f.PartitionTable.Partitions {
// ignore anything that isn't a Linux partition
if partition.Type != "83" {
// 83 -> MBR/DOS Linux Partition ID
// 0FC63DAF-8483-4772-8E79-3D69D8477DE4 -> GPT Linux Partition GUID
if partition.Type != "83" && partition.Type != "0FC63DAF-8483-4772-8E79-3D69D8477DE4" {
continue
}
if _, ok := mounted[partition.Node]; ok {

View File

@ -17,7 +17,7 @@ onboot:
- name: format
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
services:
- name: getty

View File

@ -17,7 +17,7 @@ onboot:
- name: format
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
services:
- name: getty

View File

@ -14,7 +14,7 @@ onboot:
- name: format
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
services:
- name: rngd

View File

@ -15,7 +15,7 @@ onboot:
- name: format
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib"]
- name: test
image: linuxkit/test-containerd:fa781a2ec490a63140a2e90f9c8d13c735dd4c5f

View File

@ -9,5 +9,5 @@ function failed {
[ -f /var/lib/docker/bar ] || failed
touch /var/lib/docker/foo || failed
df -h | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
df -h | grep /var/lib/docker | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
printf "extend test suite PASSED\n" >&1

View File

@ -8,7 +8,7 @@ onboot:
- name: format
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -6,9 +6,9 @@ init:
- linuxkit/runc:1eef77f5963e44e491abfe392206769037d47ae2
onboot:
- name: extend
image: linuxkit/extend:1ea3b8f198bf564e8ae6c71481715aadadd4e242
image: linuxkit/extend:10bc501a6890be931c6f6602c8caca31337eafeb
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -9,5 +9,5 @@ function failed {
[ -f /var/lib/docker/bar ] || failed
touch /var/lib/docker/foo || failed
df -h | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
df -h | grep /var/lib/docker | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
printf "extend test suite PASSED\n" >&1

View File

@ -12,7 +12,7 @@ onboot:
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format", "-type", "btrfs" ]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -9,10 +9,10 @@ onboot:
image: linuxkit/modprobe:944769462b9d10b1b1506498d3eb03dcc5416f7f
command: ["modprobe", "btrfs"]
- name: extend
image: linuxkit/extend:1ea3b8f198bf564e8ae6c71481715aadadd4e242
image: linuxkit/extend:10bc501a6890be931c6f6602c8caca31337eafeb
command: ["/usr/bin/extend", "-type", "btrfs"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -9,5 +9,5 @@ function failed {
[ -f /var/lib/docker/bar ] || failed
touch /var/lib/docker/foo || failed
df -h | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
df -h | grep /var/lib/docker | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
printf "extend test suite PASSED\n" >&1

View File

@ -9,7 +9,7 @@ onboot:
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format", "-type", "xfs"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -6,10 +6,10 @@ init:
- linuxkit/runc:1eef77f5963e44e491abfe392206769037d47ae2
onboot:
- name: extend
image: linuxkit/extend:1ea3b8f198bf564e8ae6c71481715aadadd4e242
image: linuxkit/extend:10bc501a6890be931c6f6602c8caca31337eafeb
command: ["/usr/bin/extend", "-type", "xfs"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -0,0 +1,13 @@
#!/bin/sh
set -x
function failed {
printf "extend test suite FAILED\n" >&1
exit 1
}
[ -f /var/lib/docker/bar ] || failed
touch /var/lib/docker/foo || failed
df -h | grep /var/lib/docker | grep -qE "[4-5][0-9]{2}\.[0-9]{1,}M" || failed
printf "extend test suite PASSED\n" >&1

View File

@ -0,0 +1,25 @@
kernel:
image: linuxkit/kernel:5.4.30
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:f670045ecb6ec31ea37dd10114366e9a1e915013
- linuxkit/runc:1eef77f5963e44e491abfe392206769037d47ae2
onboot:
- name: format
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format", "-partition", "gpt"]
- name: mount
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11
binds:
- /var/lib/docker:/var/lib/docker
command: ["touch", "/var/lib/docker/bar"]
- name: poweroff
image: linuxkit/poweroff:06dd4e46c62fbe79123a028835c921f80e4855d3
command: ["/bin/sh", "/poweroff.sh", "10"]
trust:
org:
- linuxkit
- library

View File

@ -0,0 +1,32 @@
#!/bin/sh
# SUMMARY: Check that a partition on a GPT partitioned disk can be extended
# LABELS:
# REPEAT:
set -ex
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME_CREATE=create-gpt
NAME_EXTEND=extend-gpt
DISK=disk.img
clean_up() {
rm -rf ${NAME_CREATE}-* ${NAME_EXTEND}-* ${DISK}
}
trap clean_up EXIT
# Test code goes here
linuxkit build -name "${NAME_CREATE}" -format kernel+initrd test-create.yml
linuxkit run -disk file="${DISK}",format=raw,size=256M "${NAME_CREATE}"
[ -f "${DISK}" ] || exit 1
# osx takes issue with bs=1M
dd if=/dev/zero bs=1048576 count=256 >> "${DISK}"
linuxkit build -format kernel+initrd -name ${NAME_EXTEND} test.yml
RESULT="$(linuxkit run -disk file=${DISK} ${NAME_EXTEND})"
echo "${RESULT}"
echo "${RESULT}" | grep -q "suite PASSED"
exit 0

View File

@ -0,0 +1,28 @@
kernel:
image: linuxkit/kernel:5.4.30
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:f670045ecb6ec31ea37dd10114366e9a1e915013
- linuxkit/runc:1eef77f5963e44e491abfe392206769037d47ae2
onboot:
- name: extend
image: linuxkit/extend:10bc501a6890be931c6f6602c8caca31337eafeb
- name: mount
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11
binds:
- /var/lib/docker:/var/lib/docker
- /check.sh:/check.sh
command: ["sh", "./check.sh"]
- name: poweroff
image: linuxkit/poweroff:06dd4e46c62fbe79123a028835c921f80e4855d3
command: ["/bin/sh", "/poweroff.sh", "10"]
files:
- path: check.sh
source: ./check.sh
trust:
org:
- linuxkit
- library

View File

@ -9,7 +9,7 @@ onboot:
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -9,7 +9,7 @@ onboot:
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format", "-label", "docker"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "-label", "docker", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -9,7 +9,7 @@ onboot:
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format", "@DEVICE@"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "-device", "@DEVICE@1", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -12,7 +12,7 @@ onboot:
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format", "-type", "btrfs" ]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -9,7 +9,7 @@ onboot:
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format", "-type", "xfs" ]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -9,7 +9,7 @@ onboot:
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format", "-partition", "gpt"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "/var/lib/docker"]
- name: test
image: alpine:3.11

View File

@ -12,10 +12,10 @@ onboot:
image: linuxkit/format:0b75e494eea0312f3015e6c6f7c5927620d56c96
command: ["/usr/bin/format", "-label", "foo"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "-label", "docker", "/var/lib/docker"]
- name: mount
image: linuxkit/mount:8363f4f1744e1df2557ec260a4cc94227178fd69
image: linuxkit/mount:19fa297189166206ac97261679c3e31fb140d48f
command: ["/usr/bin/mountie", "-label", "foo", "/var/foo"]
- name: test
image: alpine:3.11